Compare commits

...

46 commits

Author SHA1 Message Date
Alex Lushpai
9429f1574c
update version matrix (#38)
* update python versions test matrix
* fix workflow file
* fix missing key tests
2024-05-24 22:19:21 +03:00
dependabot[bot]
f17fbc6801
--- (#37)
updated-dependencies:
- dependency-name: requests
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-21 18:42:44 +03:00
dependabot[bot]
bd3998f823
Bump requests from 2.21.0 to 2.31.0 (#35)
Bumps [requests](https://github.com/psf/requests) from 2.21.0 to 2.31.0.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](https://github.com/psf/requests/compare/v2.21.0...v2.31.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-16 18:23:07 +03:00
Alex Lushpai
d0a558a8fe
Update python version (#34) 2024-01-16 18:04:27 +03:00
Alex Lushpai
1c36f3464b
Readme fix 2022-06-17 11:55:02 +03:00
Dmitriy
2c7061d8bf
Bug fix
client.customers_history (and all methods of client) doesn't has parameter filter. It has filters!
2022-04-20 23:17:44 +03:00
Alex Lushpai
3582b077f4
Merge pull request #29 from gwinn/master
minor bump
2021-09-08 16:29:11 +03:00
Alex Lushpai
bfdb4cc554 minor bump 2021-09-08 16:28:10 +03:00
Alex Lushpai
27ff0849ec
Fix Base.parameters. Now they will refresh after making a requests 2021-03-18 15:57:50 +03:00
customr
c52f95e95f Fix Base.parameters. Now they will refresh after making a requests 2021-03-17 21:58:34 +04:00
Alex Lushpai
7c9a81d135
Update README.md 2020-12-18 01:04:43 +03:00
Alex Lushpai
d420bdb0b3
Gh actions (#22) 2020-12-18 01:01:56 +03:00
Alex Lushpai
e3e3de9e4b
Update README.md 2020-12-15 13:31:30 +03:00
Alex Lushpai
b488af91c7
Update product name, cleanup annotations (#21) 2020-12-15 13:31:03 +03:00
Alex Lushpai
963e779172
Downgrade setuptools 2020-08-20 20:43:09 +03:00
Alex Lushpai
f5b7e315bb
Update requirements.txt 2020-08-20 20:40:13 +03:00
Alex Lushpai
4d25347f95
Update requirements.txt 2020-08-20 20:38:19 +03:00
Alex Lushpai
12790245f9
Missed methods, tests (#19) 2020-08-20 14:44:41 +03:00
Alex Lushpai
41084fd4be
Merge pull request #17 from gwinn/master
fixes #14 issue with payment_edit method
2020-02-27 14:10:54 +03:00
Alex Lushpai
30c135380c fixes #14 issue with payment_edit method 2020-02-27 14:09:35 +03:00
Alex Lushpai
b85adb50ca
Update requirements.txt 2020-02-19 15:46:31 +03:00
Alex Lushpai
8dc72b6c90
Merge pull request #16 from gwinn/master
coverage
2020-02-19 15:43:43 +03:00
Alex Lushpai
c198372abb coverage badge 2020-02-19 15:42:36 +03:00
Alex Lushpai
ea22c7266a coverage 2020-02-19 15:40:53 +03:00
Alex Lushpai
6e51a8cfc9
Merge pull request #15 from gwinn/master
Fix tests
2020-02-19 15:30:40 +03:00
Alex Lushpai
a1da7796c4 fix tests 2020-02-19 15:28:27 +03:00
Alex Lushpai
2d45f82287 pyenv file 2020-02-19 14:29:13 +03:00
Alex Lushpai
d4bed324d3
Merge pull request #13 from Alkalit/master
правильная проверка на ошибки
2020-01-09 10:33:07 +03:00
Alex Lushpai
d87c5b3986
Merge pull request #11 from retailcrm/dependabot/pip/requests-2.20.0
Bump requests from 2.18.4 to 2.20.0
2020-01-09 10:32:52 +03:00
Alexey Kalinin
cfb2bb80db правильная проверка на ошибки 2020-01-08 18:49:10 +03:00
dependabot[bot]
a04e807f71
Bump requests from 2.18.4 to 2.20.0
Bumps [requests](https://github.com/requests/requests) from 2.18.4 to 2.20.0.
- [Release notes](https://github.com/requests/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/master/HISTORY.md)
- [Commits](https://github.com/requests/requests/compare/v2.18.4...v2.20.0)

Signed-off-by: dependabot[bot] <support@github.com>
2019-11-02 09:29:18 +00:00
Alex Lushpai
09c6a496e3
Merge pull request #10 from KMityai/master
small fixes
2019-08-16 14:21:46 +03:00
Круглов Дмитрий
15d772079e added init file in "versions" dir 2019-08-15 13:10:27 +03:00
Круглов Дмитрий
f9d81948bf added param "site" in inventories_upload 2019-08-15 11:52:15 +03:00
Alex Lushpai
361d2cc537
Merge pull request #9 from gwinn/master
fix post methods bug
2018-04-22 21:40:51 +03:00
Alex Lushpai
cde242118b fix post methods bug 2018-04-22 21:39:48 +03:00
Alex Lushpai
85aaec98a7
Merge pull request #7 from gwinn/master
fix setup file
2018-03-28 17:43:00 +03:00
Alex Lushpai
02c4a96087 fix setup file 2018-03-28 17:41:59 +03:00
Alex Lushpai
857aba1f5c
Merge pull request #6 from gwinn/master
Update package data for PyPi
2018-03-20 21:09:27 +03:00
Alex Lushpai
e233b97ed3 rst formatted README for pypi 2018-03-20 21:07:34 +03:00
Alex Lushpai
d96eadbc53 update meta-data for pypi 2018-03-20 21:07:34 +03:00
Alex Lushpai
f9a10e59c5
Merge pull request #5 from gwinn/master
fix readme & setup.py
2018-03-20 20:51:50 +03:00
Alex Lushpai
69384fdcf3 fix readme & setup.py 2018-03-20 20:50:26 +03:00
Alex Lushpai
5e154a2f02
Merge pull request #4 from gwinn/master
Support for v3, v4 & v5 API versions
2018-03-20 20:47:10 +03:00
Alex Lushpai
4b73be0e1e update requirements.txt for travis ci 2018-03-20 20:36:15 +03:00
Alex Lushpai
fe262b267d new major version with multiply API version support 2018-03-20 20:32:43 +03:00
18 changed files with 11645 additions and 670 deletions

67
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,67 @@
name: ci
on:
push:
branches:
- '**'
tags-ignore:
- '*.*'
pull_request:
env:
RETAILCRM_URL: https://test.retailcrm.pro
RETAILCRM_KEY: key
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
include:
- python-version: '3.12'
coverage: 1
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --ignore=F401
- name: Tests
env:
COVERAGE: ${{ matrix.coverage }}
if: env.COVERAGE != 1
run: python -m unittest tests/*.py
- name: Tests with coverage
env:
COVERAGE: ${{ matrix.coverage }}
if: env.COVERAGE == 1
run: |
coverage run -m unittest tests/*.py
- name: Coverage
env:
COVERAGE: ${{ matrix.coverage }}
if: env.COVERAGE == 1
run: |
bash <(curl -s https://codecov.io/bash)
rm .coverage coverage.xml

7
.gitignore vendored
View file

@ -1,4 +1,11 @@
*.swp
*.pyc
*.nose*
/*.egg-info
/dist/
/venv/
/.vscode/
/build/
.python-version
.coverage
coverage.xml

View file

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2015 RetailDriver LLC
Copyright (c) 2015-2021 RetailDriver LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

70
README Normal file
View file

@ -0,0 +1,70 @@
RetailCRM python API client
===========================
This is python RetailCRM API client. This library allows to use all
available API versions.
Install
-------
::
pip3 install retailcrm
Usage
-----
.. code:: python
# coding utf-8
import retailcrm
client = retailcrm.v3('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
order = {
'firstName': 'John',
'lastName': 'Doe',
'phone': '+79000000000',
'email': 'john@example.com',
'orderMethod': 'call-request',
}
result = client.order_create(order)
.. code:: python
# coding utf-8
import retailcrm
client = retailcrm.v4('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
result = client.customers_history(filter={'sinceId': '1500', 'startDate': '2018-03-01'})
print(result['pagination']['totalCount'])
.. code:: python
# coding utf-8
import retailcrm
client = retailcrm.v5('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
site = 'example-com'
task = {
'text': 'Product availability problem',
'commentary': 'Take a look ASAP',
'order': {
'externalId': '100500'
},
'performerId': 1
}
result = client.task_create(task, site)

View file

@ -1,31 +1,76 @@
retailCRM API python client
[![Build Status](https://github.com/retailcrm/api-client-python/workflows/ci/badge.svg)](https://github.com/retailcrm/api-client-python/actions)
[![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)
RetailCRM python API client
===========================
### Install
This is Python RetailCRM API client. This library allows to use all available API versions.
## Install
```
pip install retailcrm
pip3 install retailcrm
```
### Usage
## Usage
#### API version 3 order create
```python
# coding utf-8
import retailcrm
client = retailcrm.Client('https://demo.intarocrm.ru', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
client = retailcrm.v3('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
order = {
'firstName': 'Ivan',
'lastName': 'Ivanov',
'firstName': 'John',
'lastName': 'Doe',
'phone': '+79000000000',
'email': 'ivan@example.com',
'email': 'john@example.com',
'orderMethod': 'call-request',
}
result = crm.orders_create(order)
result = client.order_create(order)
```
### Documentation
#### API version 4 customers history
* http://www.retailcrm.pro/docs/Developers/ApiVersion3
```python
# coding utf-8
import retailcrm
client = retailcrm.v4('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
result = client.customers_history(filters={'sinceId': '1500', 'startDate': '2018-03-01'})
print(result['pagination']['totalCount'])
```
#### API version 5 task create
```python
# coding utf-8
import retailcrm
client = retailcrm.v5('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
site = 'example-com'
task = {
'text': 'Product availability problem',
'commentary': 'Take a look ASAP',
'order': {
'externalId': '100500'
},
'performerId': 1
}
result = client.task_create(task, site)
```

6
requirements.txt Normal file
View file

@ -0,0 +1,6 @@
multidimensional-urlencode==0.0.4
nose==1.3.7
requests==2.32.1
coverage==4.5.4
pook==1.3.0
setuptools==70.0.0

View file

@ -1,2 +1,9 @@
from client import Client
from response import Response
# coding=utf-8
"""
Init
"""
from retailcrm.versions.v3 import Client as v3
from retailcrm.versions.v4 import Client as v4
from retailcrm.versions.v5 import Client as v5

View file

@ -1,642 +0,0 @@
# coding=utf-8
import requests
import json
from response import Response
class Client(object):
"""retailCRM API client"""
apiVersion = '3'
def __init__(self, crm_url, api_key):
self.apiUrl = crm_url + '/api/v' + self.apiVersion + '/'
self.apiKey = api_key
self.parameters = {'apiKey': api_key}
def make_request(self, url, method='GET'):
"""
:param url: string
:param method: string
:return: Response
"""
global result
if method == 'GET':
result = requests.get(url, params=self.parameters)
elif method == 'POST':
result = requests.post(url, data=self.parameters)
response_code = result.status_code
response_body = result.json()
return Response(response_code, response_body)
def orders(self, filters, limit=20, page=1):
"""
:param filters: array
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
url = self.apiUrl + 'orders'
return self.make_request(url)
def orders_get(self, uid, by='externalId', site=None):
"""
:param uid: string
:param by: string
:param site: string
:return: Response
"""
url = self.apiUrl + 'orders/' + str(uid)
if site is not None:
self.parameters['site'] = site
if by != 'externalId':
self.parameters['by'] = by
return self.make_request(url)
def orders_create(self, order, site=None):
"""
:param order:
:param site:
:return:
"""
data_json = json.dumps(order)
self.parameters['order'] = data_json
if site is not None:
self.parameters['site'] = site
url = self.apiUrl + 'orders/create'
return self.make_request(url, 'POST')
def orders_edit(self, order, site=None):
"""
:param order:
:param site:
:return:
"""
data_json = json.dumps(order)
self.parameters['order'] = data_json
if site is not None:
self.parameters['site'] = site
url = self.apiUrl + 'orders/' + str(order['externalId']) + '/edit'
return self.make_request(url, 'POST')
def orders_upload(self, orders, site=None):
"""
:param orders:
:param site:
:return:
"""
data_json = json.dumps(orders)
self.parameters['orders'] = data_json
if site is not None:
self.parameters['site'] = site
url = self.apiUrl + 'orders/upload'
return self.make_request(url, 'POST')
def orders_fix_external_ids(self, orders, site=None):
"""
:param orders:
:param site:
:return:
"""
data_json = json.dumps(orders)
self.parameters['orders'] = data_json
if site is not None:
self.parameters['site'] = site
url = self.apiUrl + 'orders/fix-external-ids'
return self.make_request(url, 'POST')
def orders_statuses(self, ids, external_ids):
"""
:param ids:
:param external_ids:
:return:
"""
self.parameters['ids'] = ids
self.parameters['externalIds'] = external_ids
url = self.apiUrl + 'orders/statuses'
return self.make_request(url)
def orders_history(self, start_date=None, end_date=None, limit=100, offset=0, skip_my_changes=True):
"""
:param start_date:
:param end_date:
:param limit:
:param offset:
:param skip_my_changes:
:return:
"""
self.parameters['startDate'] = start_date
self.parameters['endDate'] = end_date
self.parameters['limit'] = limit
self.parameters['offset'] = offset
self.parameters['skipMyChanges'] = skip_my_changes
url = self.apiUrl + 'orders/history'
return self.make_request(url)
def customers(self, filters, limit=20, page=0):
"""
:param filters:
:param limit:
:param page:
:return:
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
url = self.apiUrl + 'customers'
return self.make_request(url)
def customers_get(self, uid, by='externalId', site=None):
"""
:param uid:
:param by:
:param site:
:return:
"""
url = self.apiUrl + 'customers/' + str(uid)
if by != 'externalId':
self.parameters['by'] = by
if site is not None:
self.parameters['site'] = site
return self.make_request(url)
def customers_create(self, customer, site=None):
"""
:param customer:
:param site:
:return:
"""
data_json = json.dumps(customer)
self.parameters['customer'] = data_json
if site is not None:
self.parameters['site'] = site
url = self.apiUrl + 'customers/create'
return self.make_request(url, 'POST')
def customers_edit(self, customer, site=None):
"""
:param customer:
:param site:
:return:
"""
data_json = json.dumps(customer)
self.parameters['customer'] = data_json
if site is not None:
self.parameters['site'] = site
url = self.apiUrl + 'customers/' + customer['externalId'] + '/edit'
return self.make_request(url, 'POST')
def customers_upload(self, customers, site=None):
"""
:param customers:
:param site:
:return:
"""
data_json = json.dumps(customers)
self.parameters['customers'] = data_json
if site is not None:
self.parameters['site'] = site
url = self.apiUrl + 'customers/upload'
return self.make_request(url, 'POST')
def customers_fix_external_ids(self, customers, site=None):
"""
:param customers:
:param site:
:return:
"""
data_json = json.dumps(customers)
self.parameters['customers'] = data_json
if site is not None:
self.parameters['site'] = site
url = self.apiUrl + 'customers/fix-external-ids'
return self.make_request(url, 'POST')
def inventories(self, filters, limit=20, page=1):
"""
:param filters:
:param limit:
:param page:
:return:
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
url = self.apiUrl + 'store/inventories'
return self.make_request(url)
def inventories_upload(self, offers):
"""
:param offers:
:return:
"""
data_json = json.dumps(offers)
self.parameters['offers'] = data_json
url = self.apiUrl + 'store/inventories/upload'
return self.make_request(url, 'POST')
def packs(self, filters, limit=20, page=1):
"""
:param filters:
:param limit:
:param page:
:return:
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
url = self.apiUrl + 'orders/packs'
return self.make_request(url)
def packs_get(self, uid):
"""
:param uid:
:return:
"""
url = self.apiUrl + 'orders/packs/' + str(uid)
return self.make_request(url)
def packs_create(self, pack):
"""
:param pack:
:return:
"""
data_json = json.dumps(pack)
self.parameters['pack'] = data_json
url = self.apiUrl + 'orders/packs/create'
return self.make_request(url, 'POST')
def packs_edit(self, pack, uid):
"""
:param pack:
:param uid:
:return:
"""
data_json = json.dumps(pack)
self.parameters['pack'] = data_json
url = self.apiUrl + 'orders/packs/' + str(uid) + '/edit'
return self.make_request(url, 'POST')
def packs_delete(self, uid):
"""
:param uid:
:return:
"""
url = self.apiUrl + 'orders/packs/' + str(uid) + '/delete'
return self.make_request(url, 'POST')
def packs_history(self, filters, limit=20, page=1):
"""
:param filters:
:param limit:
:param page:
:return:
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
url = self.apiUrl + 'orders/packs/history'
return self.make_request(url)
def countries(self):
"""
:return:
"""
url = self.apiUrl + 'reference/countries'
return self.make_request(url)
def delivery_types(self):
"""
:return:
"""
url = self.apiUrl + 'reference/delivery-types'
return self.make_request(url)
def delivery_types_edit(self, delivery_type):
"""
:param delivery_type:
:return:
"""
data_json = json.dumps(delivery_type)
self.parameters['deliveryType'] = data_json
url = self.apiUrl + 'reference/delivery-types/' + delivery_type['code'] + '/edit'
return self.make_request(url, 'POST')
def delivery_services(self):
"""
:return:
"""
url = self.apiUrl + 'reference/delivery-services'
return self.make_request(url)
def delivery_services_edit(self, delivery_service):
"""
:param delivery_service:
:return:
"""
data_json = json.dumps(delivery_service)
self.parameters['deliveryService'] = data_json
url = self.apiUrl + 'reference/delivery-services/' + delivery_service['code'] + '/edit'
return self.make_request(url, 'POST')
def payment_types(self):
"""
:return:
"""
url = self.apiUrl + 'reference/payment-types'
return self.make_request(url)
def payment_types_edit(self, payment_type):
"""
:param payment_type:
:return:
"""
data_json = json.dumps(payment_type)
self.parameters['paymentType'] = data_json
url = self.apiUrl + 'reference/payment-types/' + payment_type['code'] + '/edit'
return self.make_request(url, 'POST')
def payment_statuses(self):
"""
:return:
"""
url = self.apiUrl + 'reference/payment-statuses'
return self.make_request(url)
def payment_statuses_edit(self, payment_status):
"""
:param payment_status:
:return:
"""
data_json = json.dumps(payment_status)
self.parameters['paymentStatus'] = data_json
url = self.apiUrl + 'reference/payment-statuses/' + payment_status['code'] + '/edit'
return self.make_request(url, 'POST')
def product_statuses(self):
"""
:return:
"""
url = self.apiUrl + 'reference/product-statuses'
return self.make_request(url)
def product_statuses_edit(self, product_status):
"""
:param product_status:
:return:
"""
data_json = json.dumps(product_status)
self.parameters['productStatus'] = data_json
url = self.apiUrl + 'reference/product-statuses/' + product_status['code'] + '/edit'
return self.make_request(url, 'POST')
def order_types(self):
"""
:return:
"""
url = self.apiUrl + 'reference/order-types'
return self.make_request(url)
def order_types_edit(self, order_type):
"""
:param order_type:
:return:
"""
data_json = json.dumps(order_type)
self.parameters['orderType'] = data_json
url = self.apiUrl + 'reference/order-types/' + order_type['code'] + '/edit'
return self.make_request(url, 'POST')
def order_methods(self):
"""
:return:
"""
url = self.apiUrl + 'reference/order-methods'
return self.make_request(url)
def order_methods_edit(self, order_method):
"""
:param order_method:
:return:
"""
data_json = json.dumps(order_method)
self.parameters['orderMethod'] = data_json
url = self.apiUrl + 'reference/order-methods/' + order_method['code'] + '/edit'
return self.make_request(url, 'POST')
def status_groups(self):
"""
:return
"""
url = self.apiUrl + 'reference/status-groups'
return self.make_request(url)
def statuses(self):
"""
:return:
"""
url = self.apiUrl + 'reference/statuses'
return self.make_request(url)
def statuses_edit(self, status):
"""
:param status:
:return:
"""
data_json = json.dumps(status)
self.parameters['status'] = data_json
url = self.apiUrl + 'reference/statuses/' + status['code'] + '/edit'
return self.make_request(url, 'POST')
def stores(self):
"""
:return:
"""
url = self.apiUrl + 'reference/stores'
return self.make_request(url)
def stores_edit(self, store):
"""
:param store:
:return:
"""
data_json = json.dumps(store)
self.parameters['status'] = data_json
url = self.apiUrl + 'reference/stores/' + store['code'] + '/edit'
return self.make_request(url, 'POST')
def statistic_update(self):
"""
:return
"""
url = self.apiUrl + 'statistic/update'
return self.make_request(url)
def telephony_call_event(self, phone, call_type, code, status):
"""
:param phone:
:param call_type:
:param code:
:param status:
:return:
"""
self.parameters['hangupStatus'] = status
self.parameters['phone'] = phone
self.parameters['code'] = code
self.parameters['type'] = call_type
url = self.apiUrl + 'telephony/call/event'
return self.make_request(url, 'POST')
def telephony_calls_upload(self, calls):
"""
:param calls:
:return:
"""
data_json = json.dumps(calls)
self.parameters['calls'] = data_json
url = self.apiUrl + 'telephony/calls/upload'
return self.make_request(url, 'POST')
def telephony_settings(self, code, client_id, make_call_url, active, name, image):
"""
:param code:
:param client_id:
:param make_call_url:
:param active:
:param name:
:param image:
:return:
"""
self.parameters['code'] = code
self.parameters['clientId'] = client_id
self.parameters['makeCallUrl'] = make_call_url
self.parameters['active'] = active
self.parameters['name'] = name
self.parameters['image'] = image
url = self.apiUrl + 'telephony/settings/' + str(code)
return self.make_request(url, 'POST')
def telephony_manager(self, phone, details=True):
"""
:param phone:
:param details:
:return:
"""
self.parameters['phone'] = phone
self.parameters['details'] = details
url = self.apiUrl + 'telephony/manager'
return self.make_request(url)

View file

@ -1,5 +1,9 @@
# coding=utf-8
"""
Response class
"""
class Response(object):
"""
@ -7,23 +11,38 @@ class Response(object):
"""
def __init__(self, code, body):
self.response_body = body
self.status_code = code
self.__status_code = code
self.__response_body = body
def get_status_code(self):
"""
:return: integer
"""
return self.status_code
return self.__status_code
def get_response(self):
"""
:return: dict
:return: string
"""
return self.response_body
return self.__response_body
def is_successfull(self):
def is_successful(self):
"""
:return: boolean
"""
return int(self.status_code) < 400
return int(self.__status_code) < 400
def get_error_msg(self):
"""
:return: string
"""
return self.__response_body['errorMsg']
def get_errors(self):
"""
:return: collection
"""
errors = self.__response_body.get('errors', {})
return errors

View file

@ -0,0 +1,5 @@
# coding=utf-8
"""
Init
"""

View file

@ -0,0 +1,66 @@
# coding=utf-8
"""
API Client base class
"""
import requests
from multidimensional_urlencode import urlencode as query_builder
from retailcrm.response import Response
class Base(object):
"""RetailCRM API client"""
def __init__(self, crm_url, api_key, version):
self.api_url = crm_url + '/api'
self.api_key = api_key
self.api_version = version
self.parameters = {}
def get(self, url, version=True):
"""
Get request
:param url: string
:param version: boolean
:return: Response
"""
base_url = self.api_url + '/' + self.api_version if version else self.api_url
requests_url = base_url + url if not self.parameters else base_url + url + "?" + query_builder(self.parameters)
response = requests.get(requests_url, headers={
'X-API-KEY': self.api_key})
self.parameters = {}
return Response(response.status_code, response.json())
def post(self, url, version=True):
"""
Post request
:return: Response
"""
base_url = self.api_url + '/' + self.api_version if version else self.api_url
requests_url = base_url + url
response = requests.post(requests_url, data=self.parameters, headers={
'X-API-KEY': self.api_key})
self.parameters = {}
return Response(response.status_code, response.json())
def api_versions(self):
"""
:return: Response
"""
return self.get('/api-versions', False)
def api_credentials(self):
"""
:return: Response
"""
return self.get('/credentials', False)
def statistic_update(self):
"""
:return Response
"""
return self.get('/statistic/update')

536
retailcrm/versions/v3.py Normal file
View file

@ -0,0 +1,536 @@
# coding=utf-8
"""
API Client version 3
"""
import json
from retailcrm.versions.base import Base
class Client(Base):
"""RetailCRM API client"""
apiVersion = 'v3'
def __init__(self, crm_url, api_key):
Base.__init__(self, crm_url, api_key, self.apiVersion)
def customers(self, filters=None, limit=20, page=1):
"""
:param filters: object
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/customers')
def customer_create(self, customer, site=None):
"""
:param customer: object
:param site: string
:return: Response
"""
self.parameters['customer'] = json.dumps(customer)
if site is not None:
self.parameters['site'] = site
return self.post('/customers/create')
def customers_fix_external_ids(self, customers, site=None):
"""
:param customers: object
:param site: string
:return: Response
"""
self.parameters['customers'] = json.dumps(customers)
if site is not None:
self.parameters['site'] = site
return self.post('/customers/fix-external-ids')
def customers_upload(self, customers, site=None):
"""
:param customers: array of objects
:param site: string
:return: Response
"""
self.parameters['customers'] = json.dumps(customers)
if site is not None:
self.parameters['site'] = site
return self.post('/customers/upload')
def customer(self, uid, uid_type='externalId', site=None):
"""
:param uid: string
:param uid_type: string
:param site: string
:return: Response
"""
if uid_type != 'externalId':
self.parameters['by'] = uid_type
if site is not None:
self.parameters['site'] = site
return self.get('/customers/' + str(uid))
def customer_edit(self, customer, uid_type='externalId', site=None):
"""
:param customer: object
:param uid_type: string
:param site: string
:return: Response
"""
self.parameters['customer'] = json.dumps(customer)
if uid_type != 'externalId':
self.parameters['by'] = uid_type
if site is not None:
self.parameters['site'] = site
return self.post('/customers/' + customer[uid_type] + '/edit')
def orders(self, filters=None, limit=20, page=1):
"""
:param filters: object
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/orders')
def order_create(self, order, site=None):
"""
:param order: object
:param site: string
:return: Response
"""
self.parameters['order'] = json.dumps(order)
if site is not None:
self.parameters['site'] = site
return self.post('/orders/create')
def orders_fix_external_ids(self, orders, site=None):
"""
:param orders: object
:param site: string
:return: Response
"""
self.parameters['orders'] = json.dumps(orders)
if site is not None:
self.parameters['site'] = site
return self.post('/orders/fix-external-ids')
def orders_history(self, start=None, end=None, limit=100, offset=0, skip=True):
"""
:param start: DateTime
:param end: DateTime
:param limit: integer
:param offset: integer
:param skip: boolean
:return: Response
"""
self.parameters['startDate'] = start
self.parameters['endDate'] = end
self.parameters['limit'] = limit
self.parameters['offset'] = offset
self.parameters['skipMyChanges'] = skip
return self.get('/orders/history')
def orders_statuses(self, ids, external_ids):
"""
:param ids: array
:param external_ids: array
:return: Response
"""
self.parameters['ids'] = ids
self.parameters['externalIds'] = external_ids
return self.get('/orders/statuses')
def orders_upload(self, orders, site=None):
"""
:param orders: object
:param site: string
:return: Response
"""
self.parameters['orders'] = json.dumps(orders)
if site is not None:
self.parameters['site'] = site
return self.post('/orders/upload')
def order(self, uid, uid_type='externalId', site=None):
"""
:param uid: string
:param uid_type: string
:param site: string
:return: Response
"""
if site is not None:
self.parameters['site'] = site
if uid_type != 'externalId':
self.parameters['by'] = uid_type
return self.get('/orders/' + str(uid))
def order_edit(self, order, uid_type='externalId', site=None):
"""
:param order: object
:param uid_type: string
:param site: string
:return: Response
"""
self.parameters['order'] = json.dumps(order)
if site is not None:
self.parameters['site'] = site
if uid_type != 'externalId':
self.parameters['by'] = uid_type
return self.post('/orders/' + str(order[uid_type]) + '/edit')
def packs(self, filters=None, limit=20, page=1):
"""
:param filters: object
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/orders/packs')
def pack_create(self, pack):
"""
:param pack: object
:return: Response
"""
self.parameters['pack'] = json.dumps(pack)
return self.post('/orders/packs/create')
def packs_history(self, filters=None, limit=20, page=1):
"""
:param filters: object
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/orders/packs/history')
def pack(self, uid):
"""
:param uid: integer
:return: Response
"""
return self.get('/orders/packs/' + str(uid))
def pack_delete(self, uid):
"""
:param uid: integer
:return: Response
"""
return self.post('/orders/packs/' + str(uid) + '/delete')
def pack_edit(self, pack):
"""
:param pack: object
:return: Response
"""
self.parameters['pack'] = json.dumps(pack)
return self.post('/orders/packs/' + str(pack['id']) + '/edit')
def countries(self):
"""
:return: Response
"""
return self.get('/reference/countries')
def delivery_services(self):
"""
:return: Response
"""
return self.get('/reference/delivery-services')
def delivery_services_edit(self, delivery_service):
"""
:param delivery_service: object
:return: Response
"""
self.parameters['deliveryService'] = json.dumps(delivery_service)
return self.post('/reference/delivery-services/' + delivery_service['code'] + '/edit')
def delivery_types(self):
"""
:return: Response
"""
return self.get('/reference/delivery-types')
def delivery_types_edit(self, delivery_type):
"""
:param delivery_type: object
:return: Response
"""
self.parameters['deliveryType'] = json.dumps(delivery_type)
return self.post('/reference/delivery-types/' + delivery_type['code'] + '/edit')
def order_methods(self):
"""
:return: Response
"""
return self.get('/reference/order-methods')
def order_methods_edit(self, order_method):
"""
:param order_method: object
:return: Response
"""
self.parameters['orderMethod'] = json.dumps(order_method)
return self.post('/reference/order-methods/' + order_method['code'] + '/edit')
def order_types(self):
"""
:return: Response
"""
return self.get('/reference/order-types')
def order_types_edit(self, order_type):
"""
:param order_type: object
:return: Response
"""
self.parameters['orderType'] = json.dumps(order_type)
return self.post('/reference/order-types/' + order_type['code'] + '/edit')
def payment_statuses(self):
"""
:return: Response
"""
return self.get('/reference/payment-statuses')
def payment_statuses_edit(self, payment_status):
"""
:param payment_status: object
:return: Response
"""
self.parameters['paymentStatus'] = json.dumps(payment_status)
return self.post('/reference/payment-statuses/' + payment_status['code'] + '/edit')
def payment_types(self):
"""
:return: Response
"""
return self.get('/reference/payment-types')
def payment_types_edit(self, payment_type):
"""
:param payment_type: object
:return: Response
"""
self.parameters['paymentType'] = json.dumps(payment_type)
return self.post('/reference/payment-types/' + payment_type['code'] + '/edit')
def product_statuses(self):
"""
:return: Response
"""
return self.get('/reference/product-statuses')
def product_statuses_edit(self, product_status):
"""
:param product_status: object
:return: Response
"""
self.parameters['productStatus'] = json.dumps(product_status)
return self.post('/reference/product-statuses/' + product_status['code'] + '/edit')
def sites(self):
"""
:return: Response
"""
return self.get('/reference/sites')
def sites_edit(self, site):
"""
:param site: object
:return: Response
"""
self.parameters['site'] = json.dumps(site)
return self.post('/reference/sites/' + site['code'] + '/edit')
def status_groups(self):
"""
:return: Response
"""
return self.get('/reference/status-groups')
def statuses(self):
"""
:return: Response
"""
return self.get('/reference/statuses')
def statuses_edit(self, status):
"""
:param status: object
:return: Response
"""
self.parameters['status'] = json.dumps(status)
return self.post('/reference/statuses/' + status['code'] + '/edit')
def stores(self):
"""
:return: Response
"""
return self.get('/reference/stores')
def stores_edit(self, store):
"""
:param store: object
:return: Response
"""
self.parameters['store'] = json.dumps(store)
return self.post('/reference/stores/' + store['code'] + '/edit')
def inventories(self, filters=None, limit=20, page=1):
"""
:param filters: object
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/store/inventories')
def inventories_upload(self, offers, site=None):
"""
:param offers: array of objects
:param site: string
:return: Response
"""
if site is not None:
self.parameters['site'] = site
self.parameters['offers'] = json.dumps(offers)
return self.post('/store/inventories/upload')
def telephony_call_event(self, phone, call_type, code, status):
"""
:param phone: string
:param call_type: string
:param code: string
:param status: string
:return: Response
"""
self.parameters['hangupStatus'] = status
self.parameters['phone'] = phone
self.parameters['code'] = code
self.parameters['type'] = call_type
return self.post('/telephony/call/event')
def telephony_calls_upload(self, calls):
"""
:param calls: array of objects
:return: Response
"""
self.parameters['calls'] = json.dumps(calls)
return self.post('/telephony/calls/upload')
def telephony_manager(self, phone, details=True):
"""
:param phone: string
:param details: string
:return: Response string
"""
self.parameters['phone'] = phone
self.parameters['details'] = details
return self.get('/telephony/manager')
def telephony_settings(self, code, client_id, make_call_url, active, name, image):
"""
:param code: string
:param client_id: string
:param make_call_url: string
:param active: string
:param name: string
:param image: string
:return: Response
"""
self.parameters['code'] = code
self.parameters['clientId'] = client_id
self.parameters['makeCallUrl'] = make_call_url
self.parameters['active'] = active
self.parameters['name'] = name
self.parameters['image'] = image
return self.post('/telephony/settings/' + str(code))
def statistic_update(self):
"""
:return: Response
"""
return self.get('/statistic/update')

662
retailcrm/versions/v4.py Normal file
View file

@ -0,0 +1,662 @@
# coding=utf-8
"""
API Client version 4
"""
import json
from retailcrm.versions.base import Base
class Client(Base):
"""RetailCRM API client"""
apiVersion = 'v4'
def __init__(self, crm_url, api_key):
Base.__init__(self, crm_url, api_key, self.apiVersion)
def customers(self, filters=None, limit=20, page=1):
"""
:param filters: object
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/customers')
def customer_create(self, customer, site=None):
"""
:param customer: object
:param site: string
:return: Response
"""
self.parameters['customer'] = json.dumps(customer)
if site is not None:
self.parameters['site'] = site
return self.post('/customers/create')
def customers_fix_external_ids(self, customers, site=None):
"""
:param customers: array of objects
:param site: string
:return: Response
"""
self.parameters['customers'] = json.dumps(customers)
if site is not None:
self.parameters['site'] = site
return self.post('/customers/fix-external-ids')
def customers_history(self, filters=None, limit=20, page=1):
"""
:param filters: object
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/customers/history')
def customers_upload(self, customers, site=None):
"""
:param customers: array of objects
:param site: string
:return: Response
"""
self.parameters['customers'] = json.dumps(customers)
if site is not None:
self.parameters['site'] = site
return self.post('/customers/upload')
def customer(self, uid, uid_type='externalId', site=None):
"""
:param uid: string
:param uid_type: string
:param site: string
:return: Response
"""
if uid_type != 'externalId':
self.parameters['by'] = uid_type
if site is not None:
self.parameters['site'] = site
return self.get('/customers/' + str(uid))
def customer_edit(self, customer, uid_type='externalId', site=None):
"""
:param customer: object
:param uid_type: string
:param site: string
:return: Response
"""
self.parameters['customer'] = json.dumps(customer)
if uid_type != 'externalId':
self.parameters['by'] = uid_type
if site is not None:
self.parameters['site'] = site
return self.post('/customers/' + customer[uid_type] + '/edit')
def delivery_setting(self, code):
"""
:param code: string
:return: Response
"""
return self.get('/delivery/generic/setting/' + str(code))
def delivery_setting_edit(self, configuration):
"""
:param configuration: object
:return: Response
"""
self.parameters['configuration'] = json.dumps(configuration)
return self.post('/delivery/generic/setting/' + str(configuration['code']) + '/edit')
def delivery_tracking(self, code, status_update):
"""
:param code: string
:param status_update: array of objects
:return: Response
"""
self.parameters['statusUpdate'] = json.dumps(status_update)
return self.post('/delivery/generic/' + str(code) + '/tracking')
def marketplace_setting_edit(self, configuration):
"""
:param configuration: object
:return: Response
"""
self.parameters['configuration'] = json.dumps(configuration)
return self.post('/marketplace/external/setting/' + str(configuration['code']) + '/edit')
def orders(self, filters=None, limit=20, page=1):
"""
:param filters: object
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/orders')
def order_create(self, order, site=None):
"""
:param order: object
:param site: string
:return: Response
"""
self.parameters['order'] = json.dumps(order)
if site is not None:
self.parameters['site'] = site
return self.post('/orders/create')
def orders_fix_external_ids(self, orders, site=None):
"""
:param orders: array of objects
:param site: string
:return: Response
"""
self.parameters['orders'] = json.dumps(orders)
if site is not None:
self.parameters['site'] = site
return self.post('/orders/fix-external-ids')
def orders_history(self, filters=None, limit=20, page=1):
"""
:param filters: object
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/orders/history')
def orders_statuses(self, ids, external_ids):
"""
:param ids: array
:param external_ids: array
:return: Response
"""
self.parameters['ids'] = ids
self.parameters['externalIds'] = external_ids
return self.get('/orders/statuses')
def orders_upload(self, orders, site=None):
"""
:param orders: array of objects
:param site: string
:return: Response
"""
self.parameters['orders'] = json.dumps(orders)
if site is not None:
self.parameters['site'] = site
return self.post('/orders/upload')
def order(self, uid, uid_type='externalId', site=None):
"""
:param uid: string
:param uid_type: string
:param site: string
:return: Response
"""
if site is not None:
self.parameters['site'] = site
if uid_type != 'externalId':
self.parameters['by'] = uid_type
return self.get('/orders/' + str(uid))
def order_edit(self, order, uid_type='externalId', site=None):
"""
:param order: object
:param uid_type: string
:param site: string
:return: Response
"""
self.parameters['order'] = json.dumps(order)
if site is not None:
self.parameters['site'] = site
if uid_type != 'externalId':
self.parameters['by'] = uid_type
return self.post('/orders/' + str(order[uid_type]) + '/edit')
def packs(self, filters=None, limit=20, page=1):
"""
:param filters: object
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/orders/packs')
def pack_create(self, pack):
"""
:param pack: object
:return: Response
"""
self.parameters['pack'] = json.dumps(pack)
return self.post('/orders/packs/create')
def packs_history(self, filters=None, limit=20, page=1):
"""
:param filters: object
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/orders/packs/history')
def pack(self, uid):
"""
:param uid: integer
:return: Response
"""
return self.get('/orders/packs/' + str(uid))
def pack_delete(self, uid):
"""
:param uid: integer
:return: Response
"""
return self.post('/orders/packs/' + str(uid) + '/delete')
def pack_edit(self, pack):
"""
:param pack: object
:return: Response
"""
self.parameters['pack'] = json.dumps(pack)
return self.post('/orders/packs/' + str(pack['id']) + '/edit')
def countries(self):
"""
:return: Response
"""
return self.get('/reference/countries')
def delivery_services(self):
"""
:return: Response
"""
return self.get('/reference/delivery-services')
def delivery_services_edit(self, delivery_service):
"""
:param delivery_service: object
:return: Response
"""
self.parameters['deliveryService'] = json.dumps(delivery_service)
return self.post('/reference/delivery-services/' + delivery_service['code'] + '/edit')
def delivery_types(self):
"""
:return: Response
"""
return self.get('/reference/delivery-types')
def delivery_types_edit(self, delivery_type):
"""
:param delivery_type: object
:return: Response
"""
self.parameters['deliveryType'] = json.dumps(delivery_type)
return self.post('/reference/delivery-types/' + delivery_type['code'] + '/edit')
def order_methods(self):
"""
:return: Response
"""
return self.get('/reference/order-methods')
def order_methods_edit(self, order_method):
"""
:param order_method: object
:return: Response
"""
self.parameters['orderMethod'] = json.dumps(order_method)
return self.post('/reference/order-methods/' + order_method['code'] + '/edit')
def order_types(self):
"""
:return: Response
"""
return self.get('/reference/order-types')
def order_types_edit(self, order_type):
"""
:param order_type: object
:return: Response
"""
self.parameters['orderType'] = json.dumps(order_type)
return self.post('/reference/order-types/' + order_type['code'] + '/edit')
def payment_statuses(self):
"""
:return: Response
"""
return self.get('/reference/payment-statuses')
def payment_statuses_edit(self, payment_status):
"""
:param payment_status: object
:return: Response
"""
self.parameters['paymentStatus'] = json.dumps(payment_status)
return self.post('/reference/payment-statuses/' + payment_status['code'] + '/edit')
def payment_types(self):
"""
:return: Response
"""
return self.get('/reference/payment-types')
def payment_types_edit(self, payment_type):
"""
:param payment_type:
:return: Response
"""
self.parameters['paymentType'] = json.dumps(payment_type)
return self.post('/reference/payment-types/' + payment_type['code'] + '/edit')
def price_types(self):
"""
:return: Response
"""
return self.get('/reference/price-types')
def price_types_edit(self, price_type):
"""
:param price_type: object
:return: Response
"""
self.parameters['priceType'] = json.dumps(price_type)
return self.post('/reference/price-types/' + price_type['code'] + '/edit')
def product_statuses(self):
"""
:return: Response
"""
return self.get('/reference/product-statuses')
def product_statuses_edit(self, product_status):
"""
:param product_status: object
:return: Response
"""
self.parameters['productStatus'] = json.dumps(product_status)
return self.post('/reference/product-statuses/' + product_status['code'] + '/edit')
def sites(self):
"""
:return: Response
"""
return self.get('/reference/sites')
def sites_edit(self, site):
"""
:param site: object
:return: Response
"""
self.parameters['site'] = json.dumps(site)
return self.post('/reference/sites/' + site['code'] + '/edit')
def status_groups(self):
"""
:return
"""
return self.get('/reference/status-groups')
def statuses(self):
"""
:return: Response
"""
return self.get('/reference/statuses')
def statuses_edit(self, status):
"""
:param status: object
:return: Response
"""
self.parameters['status'] = json.dumps(status)
return self.post('/reference/statuses/' + status['code'] + '/edit')
def stores(self):
"""
:return: Response
"""
return self.get('/reference/stores')
def stores_edit(self, store):
"""
:param store: object
:return: Response
"""
self.parameters['store'] = json.dumps(store)
return self.post('/reference/stores/' + store['code'] + '/edit')
def inventories(self, filters=None, limit=20, page=1):
"""
:param filters: object
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/store/inventories')
def inventories_upload(self, offers, site=None):
"""
:param offers: array of objects
:param site: string
:return: Response
"""
if site is not None:
self.parameters['site'] = site
self.parameters['offers'] = json.dumps(offers)
return self.post('/store/inventories/upload')
def prices_upload(self, prices):
"""
:param prices: array of objects
:return: Response
"""
self.parameters['prices'] = json.dumps(prices)
return self.post('/store/prices/upload')
def products(self, filters=None, limit=20, page=1):
"""
:param filters: object
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/store/products')
def store_setting(self, code):
"""
:param code: string
:return: Response
"""
return self.get('/store/setting/' + str(code))
def store_setting_edit(self, configuration):
"""
:param configuration: object
:return: Response
"""
self.parameters['configuration'] = json.dumps(configuration)
return self.post('/store/setting/' + str(configuration['code']) + '/edit')
def telephony_call_event(self, event):
"""
:param event: object
:return: Response
"""
self.parameters['event'] = json.dumps(event)
return self.post('/telephony/call/event')
def telephony_calls_upload(self, calls):
"""
:param calls: array of objects
:return: Response
"""
self.parameters['calls'] = json.dumps(calls)
return self.post('/telephony/calls/upload')
def telephony_manager(self, phone, details=True, ignore_status=False):
"""
:param phone: string
:param details: string
:param ignore_status: string
:return: Response
"""
self.parameters['phone'] = phone
self.parameters['details'] = details
self.parameters['ignoreStatus'] = ignore_status
return self.get('/telephony/manager')
def telephony_setting(self, code):
"""
:param code: string
:return: Response
"""
return self.get('/telephony/setting/' + str(code))
def telephony_setting_edit(self, configuration):
"""
:param configuration: object
:return: Response
"""
self.parameters['configuration'] = json.dumps(configuration)
return self.post('/telephony/setting/' + str(configuration['code']) + '/edit')
def user_groups(self, limit=20, page=1):
"""
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/user-groups')
def users(self, filters=None, limit=20, page=1):
"""
:param filters: object
:param limit: integer
:param page: integer
:return: Response
"""
self.parameters['filter'] = filters
self.parameters['limit'] = limit
self.parameters['page'] = page
return self.get('/users')
def user(self, uid):
"""
:param uid: integer
:return: Response
"""
return self.get('/users/' + str(uid))
def statistic_update(self):
"""
:return: Response
"""
return self.get('/statistic/update')

1558
retailcrm/versions/v5.py Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,16 +1,45 @@
# coding=utf-8
"""
Setup file
"""
import os
from setuptools import setup
def read(filename):
"""Read readme for long description"""
return open(os.path.join(os.path.dirname(__file__), filename)).read()
setup(
name='retailcrm',
version='3.0.5',
description='Client for retailCRM API',
version='5.1.2',
description='RetailCRM API client',
long_description=read('README'),
url='https://github.com/retailcrm/api-client-python',
author='retailCRM',
author_email='integration@retailcrm.ru',
keywords='crm, saas, rest, e-commerce',
author='RetailCRM',
author_email='support@retailcrm.pro',
keywords='crm saas rest e-commerce',
license='MIT',
packages=['retailcrm'],
packages=['retailcrm', 'retailcrm/versions'],
package_data={},
install_requires=['requests']
install_requires=['requests', 'multidimensional_urlencode', 'nose', 'coverage', 'pook', 'setuptools'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Other Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Software Development :: Libraries :: Python Modules',
]
)

1642
tests/v3_tests.py Normal file

File diff suppressed because it is too large Load diff

2226
tests/v4_tests.py Normal file

File diff suppressed because it is too large Load diff

4672
tests/v5_tests.py Normal file

File diff suppressed because it is too large Load diff