Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kstkn/dostavista
A PHP library for the dostavista.ru REST API
https://github.com/kstkn/dostavista
api dostavista php
Last synced: about 2 months ago
JSON representation
A PHP library for the dostavista.ru REST API
- Host: GitHub
- URL: https://github.com/kstkn/dostavista
- Owner: kstkn
- License: mit
- Created: 2016-11-14T15:05:30.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-02-23T17:23:15.000Z (almost 5 years ago)
- Last Synced: 2024-10-16T12:22:38.039Z (2 months ago)
- Topics: api, dostavista, php
- Language: PHP
- Homepage:
- Size: 20.5 KB
- Stars: 5
- Watchers: 4
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Dostavista API client
=====================Non-official PHP library for the dostavista.ru REST API
[![Latest Stable Version](https://poser.pugx.org/gietos/dostavista/version)](https://packagist.org/packages/gietos/dostavista)
[![Total Downloads](https://poser.pugx.org/gietos/dostavista/downloads)](https://packagist.org/packages/gietos/dostavista)
[![License](https://poser.pugx.org/gietos/dostavista/license)](https://packagist.org/packages/gietos/dostavista)[API documentation](https://docs.google.com/document/d/1-yjBzfkI9Zb44kkQB_rMcq5pNeLThyD6YbvXR9wl7IY/edit?usp=sharing)
## Installation
The suggested installation method is via [composer](https://getcomposer.org/):
```sh
composer require gietos/dostavista
```## Usage
```php
// 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
```php
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
```php
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
```php
use Dostavista\CancelRequest;$client->cancelOrder(new CancelRequest(
123456,
CancelRequest::SUBSTATUS_NOT_NEEDED
));
```