tpmanc/crmclient

dev-master 2019-08-27 11:39 UTC

This package is not auto-updated.

Last update: 2024-04-17 13:16:53 UTC


README

Install via Composer

Run the following command

$ composer require tpmanc/crmclient "*"

or add

$ "tpmanc/crmclient": "*"

to the require section of your composer.json file.

Send orders

use tpmanc\crmclient\ApiClient;
use tpmanc\crmclient\Client;
use tpmanc\crmclient\Order;
use tpmanc\crmclient\OrderProduct;
use tpmanc\crmclient\OrderProducts;

...

$client = new Client(
    'Name 8', // name
    '+7 (952) 268-97-23' // phone
);
$client->setEmail('email@email.test');
$client->setAddress('Address');
$client->setDelivery('Delivery Type');
$client->setPayment('Payment Type');
$client->setComment('Comment');

$orderProducts = new OrderProducts();
$orderProducts->addProduct(new OrderProduct(
    1982, // product id
    5000 // product price
));
$orderProducts->addProduct(new OrderProduct(
    6571, // product id
    1000, // product price
    5 // amount
));

$orderMethod = 1;
$order = new Order(
    '5317263', // id
    $orderMethod,
    $client
);
$timestamp = time();
$order->setDate($timestamp);
$order->setStatus(3);
$order->setProducts($orderProducts);


$apiUrl = 'http://localhost:8080';
$token = '5XG2qsuKriI6Cq6sYX9krZb622rQ9w6O6XW833HZ';
$api = new ApiClient($apiUrl, $token);
$api->addOrder($order);

$result = $api->sendOrders();

Response

{
    "result":"ok",
    "orders":[
        {"crmId":51,"orderId":107256},
        {"crmId":52,"orderId":107257},
        {"crmId":53,"orderId":107258},
        {"crmId":54,"orderId":107259},
        {"crmId":55,"orderId":107260}
    ]
}