gietos / dostavista
Dostavista API client
Installs: 1 769
Dependents: 1
Suggesters: 0
Security: 0
Stars: 5
Watchers: 4
Forks: 5
Open Issues: 2
Requires
- php: >=7.0
- doctrine/inflector: ^1.1
- guzzlehttp/guzzle: ^6.2
README
Non-official PHP library for the dostavista.ru REST API
Installation
The suggested installation method is via composer:
composer require gietos/dostavista
Usage
// Note, that we use sandbox API URL here, change to production one after tests $client = new \Dostavista\Dostavista(new \GuzzleHttp\Client, [ 'baseUrl' => 'https://robotapitest.dostavista.ru/bapi', 'clientId' => '...', 'token' => '...' ]);
Calculate order
use Dostavista\OrderRequest; use Dostavista\Point; $orderRequest = (new OrderRequest('Весы')) ->setRequireCar(OrderRequest::DELIVERY_TYPE_FOOT) ->setBackpaymentMethod(OrderRequest::BACKPAYMENT_CARD) ->setBackpaymentDetails('Карта Сбербанка XXXX, получатель СЕРГЕЙ ИВАНОВИЧ П') ->setPoints([ (new Point( 'Москва, Магистральный пер., 1', new DateTime('17:00'), new DateTime('18:00'), '4951234567' )), (new Point( 'Москва, Бобруйская, 28', new DateTime('18:00'), new DateTime('19:00'), '9261234567' )) ->setTaking(3000), ]); $deliveryFee = $client->calculateOrder($orderRequest);
Create order
use Dostavista\OrderRequest; use Dostavista\Point; $orderRequest = (new OrderRequest('Весы')) ->setRequireCar(OrderRequest::DELIVERY_TYPE_FOOT) ->setBackpaymentMethod(OrderRequest::BACKPAYMENT_CARD) ->setBackpaymentDetails('Карта Сбербанка XXXX, получатель СЕРГЕЙ ИВАНОВИЧ П') ->setPoints([ (new Point( 'Москва, Магистральный пер., 1', new DateTime('17:00'), new DateTime('18:00'), '4951234567' )) ->setContactPerson('Менеджер Склада Иван') ->setNote('Комплекс "Сити-Бокс"'), (new Point( 'Москва, Бобруйская, 28', new DateTime('18:00'), new DateTime('19:00'), '9261234567' )) ->setContactPerson('Анна Иванова') ->setNote('кв.66, домоф.1234') ->setTaking(3000), ]); $orderId = $client->createOrder($orderRequest);
Cancel order
use Dostavista\CancelRequest; $client->cancelOrder(new CancelRequest( 123456, CancelRequest::SUBSTATUS_NOT_NEEDED ));