venditan/rapport-client

此软件包最新版本(v1.0.0)没有可用的许可信息。

报告

v1.0.0 2015-12-22 08:43 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:58:22 UTC


README

http://www.venditan.com/rapport

目录

使用Composer安装

composer require venditan/rapport-client dev-master

示例

在下面的所有示例中,我们假设您已经创建了一个带有正确凭证的客户端对象,如下所示

// Create the client with your supplied client id and api key
$obj_client = new \Venditan\Rapport\Client('company', 'api-key');

订单派送

// Add and configure the target recipient/user
$obj_client->addUser()->id('1955')->name('Marty')->email('marty@mcfly.com')->mobile('07019551985');

// Set-up the transaction
$obj_client->addTransaction()->id('2015')->courier('Western Union')->tracking('ELB1885');

// Set the type of event and publish
$obj_client->event('order_dispatched')->send();

订单详情

也可以提供订单详情(行、配送地址、备注)。

这通常只会使用一次,通过order_detail事件提供。

// Set-up the transaction
$obj_txn = $obj_client->addTransaction()->id('2015');

// Address
$obj_txn->deliverTo('123 Street, Town, County, POST CODE');

// Notes
$obj_txn->notes('Will be delivered by hand');

// Line. Only the description is required, other fields are optional
$obj_txn->addLine()->describe('Paul Smith Shirt')->quantity(1)->image('https://a.b.c/d.jpg')->attribute('Colour', 'Red')->attribute('Size', '12');

// Set the type of event and publish
$obj_client->event('order_detail')->send();

预计送达日期

如果您的事件模板支持预计送达日期,则可以在请求中发送。

日期将按提供的方式进行包含,因此请发送您希望显示的日期。

// Add and configure the target recipient/user
$obj_client->addUser()->id('1955')->name('Marty')->email('marty@mcfly.com')->mobile('07019551985');

// Set-up the transaction
$obj_client->addTransaction()->id('2015')->estimatedDelivery('10th May 2016');

// Set the type of event and publish
$obj_client->event('stock_arrived')->send();

服务消息

// Add and configure the target recipient/user
$obj_client->addUser()->id('1955')->name('Marty')->email('marty@mcfly.com')->mobile('07019551985');

// Set-up the transaction (optional, useful context)
$obj_client->addTransaction()->id('2015');

// Set a service message
$obj_client->addMessage()->title('Order Update')->body('Hi Marty. I am safe in 1885.')->from('ELB');

// Set the type of event and publish
$obj_client->event('service_message')->send();

检索线程消息

线程存在于交易(订单)上下文或仅仅是用户(客户)上下文中。

// Retrieve any thread for Order "2015"
$obj_client->getThreadForTransaction('2015');

// Retrieve any thread for User "12345"
$obj_client->getThreadForUser('12345');

响应将是一个从以下JSON结构解码的stdClass对象

{
    "id": "oid-2015",
    "topic": "Order 2015",
    "last_read": "2015-01-01 12:00:00",
    "last_read_device": "Mobile, iPhone",
    "messages": [
        {
            "title": "Order Accepted",
            "message": "Thank you for your order.",
            "created": "2015-01-01 12:00:00"
        }
    ]
}

账户使用情况

// Retrieve basic account usage data
$obj_client->getAccountUsage();

响应将是一个从以下JSON结构解码的stdClass对象。

将来可能会添加更多使用统计信息。

{
    "this_month": {
        "name": "December 2015",
        "year": 2015,
        "month": 12,
        "sms": 199
    },
    "recent_months": [
        {
            "name": "October 2015",
            "year": 2015,
            "month": 10,
            "sms": 117
        },
        ...
    ]
}