2020-12-18 01:04:43 +03:00
|
|
|
[![Build Status](https://github.com/retailcrm/api-client-python/workflows/ci/badge.svg)](https://github.com/retailcrm/api-client-python/actions)
|
2020-12-15 13:31:03 +03:00
|
|
|
[![Coverage](https://img.shields.io/codecov/c/gh/retailcrm/api-client-python/master.svg?logo=codecov&logoColor=white)](https://codecov.io/gh/retailcrm/api-client-python)
|
|
|
|
[![PyPI](https://img.shields.io/pypi/v/retailcrm.svg?logo=pypi&logoColor=white)](https://pypi.python.org/pypi/retailcrm)
|
|
|
|
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/retailcrm.svg?logo=python&logoColor=white)](https://pypi.python.org/pypi/retailcrm)
|
2018-03-20 20:32:43 +03:00
|
|
|
|
|
|
|
|
2020-12-15 13:31:03 +03:00
|
|
|
RetailCRM python API client
|
2016-03-17 00:54:42 +03:00
|
|
|
===========================
|
2014-09-11 11:16:44 +04:00
|
|
|
|
2020-12-15 13:31:30 +03:00
|
|
|
This is Python RetailCRM API client. This library allows to use all available API versions.
|
2018-03-20 20:32:43 +03:00
|
|
|
|
|
|
|
## Install
|
2015-03-12 16:08:55 +03:00
|
|
|
|
|
|
|
```
|
2016-03-17 00:54:42 +03:00
|
|
|
pip install retailcrm
|
2015-03-12 16:08:55 +03:00
|
|
|
```
|
|
|
|
|
2018-03-20 20:32:43 +03:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
#### API version 3 order create
|
2015-03-12 16:08:55 +03:00
|
|
|
|
|
|
|
```python
|
2018-03-20 20:32:43 +03:00
|
|
|
# coding utf-8
|
|
|
|
|
2016-03-17 00:54:42 +03:00
|
|
|
import retailcrm
|
2015-03-12 16:08:55 +03:00
|
|
|
|
|
|
|
|
2020-12-15 13:31:03 +03:00
|
|
|
client = retailcrm.v3('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
|
2015-03-12 16:08:55 +03:00
|
|
|
|
|
|
|
order = {
|
2018-03-20 20:32:43 +03:00
|
|
|
'firstName': 'John',
|
|
|
|
'lastName': 'Doe',
|
2015-03-12 16:08:55 +03:00
|
|
|
'phone': '+79000000000',
|
2018-03-20 20:32:43 +03:00
|
|
|
'email': 'john@example.com',
|
2015-03-12 16:08:55 +03:00
|
|
|
'orderMethod': 'call-request',
|
|
|
|
}
|
|
|
|
|
2018-03-20 20:32:43 +03:00
|
|
|
result = client.order_create(order)
|
|
|
|
```
|
|
|
|
|
|
|
|
#### API version 4 customers history
|
|
|
|
|
|
|
|
```python
|
|
|
|
# coding utf-8
|
|
|
|
|
|
|
|
import retailcrm
|
|
|
|
|
|
|
|
|
2020-12-15 13:31:03 +03:00
|
|
|
client = retailcrm.v4('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
|
2018-03-20 20:32:43 +03:00
|
|
|
|
|
|
|
result = client.customers_history(filter={'sinceId': '1500', 'startDate': '2018-03-01'})
|
|
|
|
|
|
|
|
print(result['pagination']['totalCount'])
|
|
|
|
```
|
|
|
|
|
|
|
|
#### API version 5 task create
|
|
|
|
|
|
|
|
```python
|
|
|
|
# coding utf-8
|
|
|
|
|
|
|
|
import retailcrm
|
|
|
|
|
|
|
|
|
2020-12-15 13:31:03 +03:00
|
|
|
client = retailcrm.v5('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
|
2018-03-20 20:32:43 +03:00
|
|
|
site = 'example-com'
|
|
|
|
task = {
|
|
|
|
'text': 'Product availability problem',
|
|
|
|
'commentary': 'Take a look ASAP',
|
|
|
|
'order': {
|
|
|
|
'externalId': '100500'
|
|
|
|
},
|
|
|
|
'performerId': 1
|
|
|
|
}
|
|
|
|
|
|
|
|
result = client.task_create(task, site)
|
2015-03-12 16:08:55 +03:00
|
|
|
```
|