https://github.com/tpmanc/crm-client
https://github.com/tpmanc/crm-client
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/tpmanc/crm-client
- Owner: tpmanc
- Created: 2018-08-12T13:18:23.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-27T11:39:15.000Z (over 5 years ago)
- Last Synced: 2025-02-13T19:29:01.499Z (2 months ago)
- Language: PHP
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CRM Client
## Install via Composer
Run the following command
```bash
$ composer require tpmanc/crmclient "*"
```or add
```bash
$ "tpmanc/crmclient": "*"
```to the require section of your `composer.json` file.
## Send orders
```php
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 protected]');
$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
```json
{
"result":"ok",
"orders":[
{"crmId":51,"orderId":107256},
{"crmId":52,"orderId":107257},
{"crmId":53,"orderId":107258},
{"crmId":54,"orderId":107259},
{"crmId":55,"orderId":107260}
]
}
```