<commit_before>Dostavista API client
=====================

A PHP library for the dostavista.ru REST API

[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' => '...'
]);
```

### 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('<NAME>')
        ->setNote('Комплекс "Сити-Бокс"'),
        
        (new Point(
            'Москва, Бобруйская, 28',
            new DateTime('18:00'),
            new DateTime('19:00'),
            '9261234567'
        ))
        ->setContactPerson('<NAME>')
        ->setNote('кв.66, домоф.1234')
        ->setTaking(3000),
    ]);
    
$orderId = $client->createOrder($orderRequest);
```

### Cancel order

```php
use Dostavista\CancelRequest;

$client->cancelOrder(new CancelRequest(
    123456,
    CancelRequest::SUBSTATUS_NOT_NEEDED
));
```<commit_msg>Add poser badges<commit_after>Dostavista API client
=====================

A 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' => '...'
]);
```

### 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('<NAME>')
        ->setNote('Комплекс "Сити-Бокс"'),
        
        (new Point(
            'Москва, Бобруйская, 28',
            new DateTime('18:00'),
            new DateTime('19:00'),
            '9261234567'
        ))
        ->setContactPerson('<NAME>')
        ->setNote('кв.66, домоф.1234')
        ->setTaking(3000),
    ]);
    
$orderId = $client->createOrder($orderRequest);
```

### Cancel order

```php
use Dostavista\CancelRequest;

$client->cancelOrder(new CancelRequest(
    123456,
    CancelRequest::SUBSTATUS_NOT_NEEDED
));
```
{'fraction_non_alphanumeric': 0.16506118198385836, 'fraction_numerical': 0.032803957302785736, 'mean_word_length': 3.351075877689694, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6825948', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1381, 'n_words': 224}