Compare commits

..

No commits in common. "master" and "v5.1.0" have entirely different histories.

16 changed files with 213 additions and 238 deletions

View file

@ -1,67 +0,0 @@
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

5
.gitignore vendored
View file

@ -5,7 +5,4 @@
/dist/
/venv/
/.vscode/
/build/
.python-version
.coverage
coverage.xml
/build/

13
.travis.yml Normal file
View file

@ -0,0 +1,13 @@
language: python
python:
- '3.4'
- '3.5'
- '3.6'
- '3.7'
- '3.8'
before_install:
- pip install -r requirements.txt
script:
- nosetests -v --with-coverage --cover-xml
after_success:
- bash <(curl -s https://codecov.io/bash)

View file

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2015-2021 RetailDriver LLC
Copyright (c) 2015-2018 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

21
README
View file

@ -1,7 +1,7 @@
RetailCRM python API client
retailCRM python API client
===========================
This is python RetailCRM API client. This library allows to use all
This is python retailCRM API client. This library allows to use all
available API versions.
Install
@ -9,7 +9,7 @@ Install
::
pip3 install retailcrm
pip install retailcrm
Usage
-----
@ -22,7 +22,7 @@ Usage
import retailcrm
client = retailcrm.v3('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
client = retailcrm.v3('https://demo.retailcrm.ru', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
order = {
'firstName': 'John',
@ -42,7 +42,7 @@ Usage
import retailcrm
client = retailcrm.v4('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
client = retailcrm.v4('https://demo.retailcrm.ru', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
result = client.customers_history(filter={'sinceId': '1500', 'startDate': '2018-03-01'})
@ -56,7 +56,7 @@ Usage
import retailcrm
client = retailcrm.v5('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
client = retailcrm.v5('https://demo.retailcrm.ru', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
site = 'example-com'
task = {
'text': 'Product availability problem',
@ -68,3 +68,12 @@ Usage
}
result = client.task_create(task, site)
Documentation
-------------
- `English`_
- `Russian`_
.. _English: https://help.retailcrm.pro/Developers/Index
.. _Russian: https://help.retailcrm.ru/Developers/Index

View file

@ -1,18 +1,18 @@
[![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)
[![Build Status](https://img.shields.io/travis/retailcrm/api-client-python/master.svg?style=flat-square)](https://travis-ci.org/retailcrm/api-client-python)
[![Coverage](https://img.shields.io/codecov/c/gh/retailcrm/api-client-python/master.svg?style=flat-square)](https://codecov.io/gh/retailcrm/api-client-python)
[![PyPI](https://img.shields.io/pypi/v/retailcrm.svg?style=flat-square)](https://pypi.python.org/pypi/retailcrm)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/retailcrm.svg?style=flat-square)](https://pypi.python.org/pypi/retailcrm)
RetailCRM python API client
retailCRM python API client
===========================
This is Python RetailCRM API client. This library allows to use all available API versions.
This is python retailCRM API client. This library allows to use all available API versions.
## Install
```
pip3 install retailcrm
pip install retailcrm
```
## Usage
@ -25,7 +25,7 @@ pip3 install retailcrm
import retailcrm
client = retailcrm.v3('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
client = retailcrm.v3('https://demo.retailcrm.ru', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
order = {
'firstName': 'John',
@ -46,9 +46,9 @@ result = client.order_create(order)
import retailcrm
client = retailcrm.v4('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
client = retailcrm.v4('https://demo.retailcrm.ru', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
result = client.customers_history(filters={'sinceId': '1500', 'startDate': '2018-03-01'})
result = client.customers_history(filter={'sinceId': '1500', 'startDate': '2018-03-01'})
print(result['pagination']['totalCount'])
```
@ -61,7 +61,7 @@ print(result['pagination']['totalCount'])
import retailcrm
client = retailcrm.v5('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
client = retailcrm.v5('https://demo.retailcrm.ru', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
site = 'example-com'
task = {
'text': 'Product availability problem',
@ -74,3 +74,8 @@ task = {
result = client.task_create(task, site)
```
## Documentation
* [English](https://help.retailcrm.pro/Developers/Index)
* [Russian](https://help.retailcrm.ru/Developers/Index)

View file

@ -1,6 +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
requests==2.24.0
coverage==5.2.1
pook==1.0.1
setuptools==49.6.0

View file

@ -2,4 +2,4 @@
"""
Init
"""
"""

View file

@ -11,7 +11,7 @@ from retailcrm.response import Response
class Base(object):
"""RetailCRM API client"""
"""retailCRM API client"""
def __init__(self, crm_url, api_key, version):
self.api_url = crm_url + '/api'
@ -30,7 +30,6 @@ class Base(object):
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())
@ -43,8 +42,7 @@ class Base(object):
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):

View file

@ -10,7 +10,7 @@ from retailcrm.versions.base import Base
class Client(Base):
"""RetailCRM API client"""
"""retailCRM API client"""
apiVersion = 'v3'
@ -469,7 +469,7 @@ class Client(Base):
"""
if site is not None:
self.parameters['site'] = site
self.parameters['offers'] = json.dumps(offers)
return self.post('/store/inventories/upload')
@ -532,5 +532,5 @@ class Client(Base):
"""
:return: Response
"""
return self.get('/statistic/update')

View file

@ -10,7 +10,7 @@ from retailcrm.versions.base import Base
class Client(Base):
"""RetailCRM API client"""
"""retailCRM API client"""
apiVersion = 'v4'

View file

@ -10,7 +10,7 @@ from retailcrm.versions.base import Base
class Client(Base):
"""RetailCRM API client"""
"""retailCRM API client"""
apiVersion = 'v5'
@ -504,15 +504,11 @@ class Client(Base):
if site is not None:
self.parameters['site'] = site
return self.post("".join(
[
'/customers-corporate/',
str(uid_corporate),
'/addresses/',
str(address[entity_by]),
'/edit'
]
))
return self.post('/customers-corporate/' +
str(uid_corporate) +
'/addresses/' +
str(address[entity_by]) +
'/edit')
def customer_corporate_companies(self, uid, uid_type='externalId', limit=20, page=1, filters=None, site=None):
"""
@ -579,7 +575,8 @@ class Client(Base):
if site is not None:
self.parameters['site'] = site
return self.post('/customers-corporate/' + str(uid_corporate) + '/companies/' + str(company[entity_by]) + '/edit')
return self.post('/customers-corporate/' +
str(uid_corporate) + '/companies/' + str(company[entity_by]) + '/edit')
def customer_corporate_contacts(self, uid, uid_type='externalId', limit=20, page=1, filters=None, site=None):
"""
@ -646,7 +643,8 @@ class Client(Base):
if site is not None:
self.parameters['site'] = site
return self.post('/customers-corporate/' + str(uid_corporate) + '/contacts/' + str(contact[entity_by]) + '/edit')
return self.post('/customers-corporate/' +
str(uid_corporate) + '/contacts/' + str(contact[entity_by]) + '/edit')
def customer_corporate_edit(self, customer_corporate, uid_type='externalId', site=None):
"""

View file

@ -15,12 +15,12 @@ def read(filename):
setup(
name='retailcrm',
version='5.1.2',
description='RetailCRM API client',
version='5.1.0',
description='retailCRM API client',
long_description=read('README'),
url='https://github.com/retailcrm/api-client-python',
author='RetailCRM',
author_email='support@retailcrm.pro',
author='retailCRM',
author_email='integration@retailcrm.ru',
keywords='crm saas rest e-commerce',
license='MIT',
packages=['retailcrm', 'retailcrm/versions'],
@ -34,11 +34,11 @@ setup(
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'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',
]

View file

@ -2,7 +2,7 @@
"""
RetailCRM API client v3 tests
retailCRM API client v3 tests
"""
from urllib.parse import urlencode
@ -111,7 +111,8 @@ class TestVersion3(unittest.TestCase):
Setup
"""
self.client = retailcrm.v3(os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
self.client = retailcrm.v3(
os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
@staticmethod
def dictionaryEncode(key, dictionary):
@ -123,7 +124,7 @@ class TestVersion3(unittest.TestCase):
V3 Test wrong api url
"""
(pook.get('https://epoqq.retailcrm.pro' + '/api/v3/statistic/update')
(pook.get('https://epoqq.retailcrm.ru' + '/api/v3/statistic/update')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.reply(404)
.headers(self.__header)
@ -135,7 +136,7 @@ class TestVersion3(unittest.TestCase):
)
)
client = retailcrm.v3('https://epoqq.retailcrm.pro', os.getenv('RETAILCRM_KEY'))
client = retailcrm.v3('https://epoqq.retailcrm.ru', os.getenv('RETAILCRM_KEY'))
response = client.statistic_update()
pook.off()
@ -168,6 +169,7 @@ class TestVersion3(unittest.TestCase):
"""
(pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/statistic/update')
.headers({'X-API-KEY': None})
.reply(200)
.headers(self.__header)
.json({'errorMsg': '"apiKey" is missing.'})
@ -1507,7 +1509,13 @@ class TestVersion3(unittest.TestCase):
(pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/telephony/call/event')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(urlencode({'hangupStatus': 'busy', 'phone': '+799999999', 'code': 'c2321', 'type': 'hangup'}))
.body(urlencode(
{
'hangupStatus': 'busy',
'phone': '+799999999',
'code': 'c2321',
'type': 'hangup'
}))
.reply(200)
.headers(self.__header)
.json({'success': 'true'})
@ -1564,7 +1572,7 @@ class TestVersion3(unittest.TestCase):
'firstName': 'yyy',
'lastName': 'xxxx',
'patronymic': 's789',
'email': 'mail@retailcrm.pro',
'email': 'mail@retailcrm.ru',
'code': 'ccc7'
},
'customer': {
@ -1573,7 +1581,7 @@ class TestVersion3(unittest.TestCase):
'firstName': 'ccc',
'lastName': 's789',
'patronymic': 's789',
'email': 'mail@retailcrm.pro',
'email': 'mail@retailcrm.ru',
'code': 'ccc7',
'phones': [{'number': '+71111111111'}]
},
@ -1601,20 +1609,21 @@ class TestVersion3(unittest.TestCase):
code = 'xxx'
(
pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/telephony/settings/' + code)
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(urlencode({
'code': code,
'clientId': '123x',
'makeCallUrl': 'url',
'active': 'active',
'name': 'name',
'image': 'url_image'}))
.reply(201)
.headers(self.__header)
.json({'success': 'true'})
)
(pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/telephony/settings/' + code)
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(urlencode(
{
'code': code,
'clientId': '123x',
'makeCallUrl': 'url',
'active': 'active',
'name': 'name',
'image': 'url_image'
}))
.reply(201)
.headers(self.__header)
.json({'success': 'true'})
)
response = self.client.telephony_settings(code, '123x', 'url', 'active', 'name', 'url_image')
pook.off()

View file

@ -2,7 +2,7 @@
"""
RetailCRM API client v4 tests
retailCRM API client v4 tests
"""
from urllib.parse import urlencode
@ -107,7 +107,8 @@ class TestVersion4(unittest.TestCase):
Setup
"""
self.client = retailcrm.v4(os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
self.client = retailcrm.v4(
os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
@staticmethod
def dictionaryEncode(key, dictionary):
@ -119,7 +120,7 @@ class TestVersion4(unittest.TestCase):
V4 Test wrong api url
"""
(pook.get('https://epoqq.retailcrm.pro' + '/api/v4/statistic/update')
(pook.get('https://epoqq.retailcrm.ru' + '/api/v4/statistic/update')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.reply(404)
.headers(self.__header)
@ -131,7 +132,7 @@ class TestVersion4(unittest.TestCase):
)
)
client = retailcrm.v4('https://epoqq.retailcrm.pro', os.getenv('RETAILCRM_KEY'))
client = retailcrm.v4('https://epoqq.retailcrm.ru', os.getenv('RETAILCRM_KEY'))
response = client.statistic_update()
pook.off()
@ -164,6 +165,7 @@ class TestVersion4(unittest.TestCase):
"""
(pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/statistic/update')
.headers({'X-API-KEY': None})
.reply(200)
.headers(self.__header)
.json({'errorMsg': '"apiKey" is missing.'})
@ -308,11 +310,11 @@ class TestVersion4(unittest.TestCase):
)
response = self.client.customers_history(
{
'sinceId': '1111',
'startDate': '2016-01-07',
'endDate': '2020-04-12'
}
{
'sinceId': '1111',
'startDate': '2016-01-07',
'endDate': '2020-04-12'
}
)
pook.off()
@ -708,11 +710,11 @@ class TestVersion4(unittest.TestCase):
)
response = self.client.orders_history(
{
'sinceId': '1111',
'startDate': '2016-01-07',
'endDate': '2020-04-12'
}
{
'sinceId': '1111',
'startDate': '2016-01-07',
'endDate': '2020-04-12'
}
)
pook.off()
@ -1688,7 +1690,7 @@ class TestVersion4(unittest.TestCase):
(pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/store/inventories')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.params({'filter[site]': 'https://retailcrm.pro'})
.params({'filter[site]': 'https://retailcrm.ru'})
.reply(200)
.headers(self.__header)
.json(
@ -1704,13 +1706,13 @@ class TestVersion4(unittest.TestCase):
{
'id': 33937,
'externalId': 'werew',
'site': 'https://retailcrm.pro',
'site': 'https://retailcrm.ru',
'quantity': 102
},
{
'id': 33933,
'externalId': '46',
'site': 'https://retailcrm.pro',
'site': 'https://retailcrm.ru',
'quantity': 0
}
]
@ -1718,7 +1720,7 @@ class TestVersion4(unittest.TestCase):
)
)
response = self.client.inventories({'site': 'https://retailcrm.pro'})
response = self.client.inventories({'site': 'https://retailcrm.ru'})
pook.off()
self.assertTrue(response.is_successful(), True)
@ -1979,7 +1981,7 @@ class TestVersion4(unittest.TestCase):
'firstName': 'yyy',
'lastName': 'xxxx',
'patronymic': 'www',
'email': 'mail@retailcrm.pro',
'email': 'mail@retailcrm.ru',
'code': 'ccc7'
},
'customer': {
@ -1988,7 +1990,7 @@ class TestVersion4(unittest.TestCase):
'firstName': 'ccc',
'lastName': 'zzz',
'patronymic': 'sss',
'email': 'mail@retailcrm.pro',
'email': 'mail@retailcrm.ru',
'code': 'ccc7',
'phones': [{'number': '+71111111111'}]
},
@ -2025,7 +2027,7 @@ class TestVersion4(unittest.TestCase):
{
'success': 'true',
'configuration': {
'makeCallUrl': 'https://retailcrm.pro',
'makeCallUrl': 'https://retailcrm.ru',
'allowEdit': 'false',
'inputEventSupported': 'false',
'outputEventSupported': 'false',
@ -2054,7 +2056,7 @@ class TestVersion4(unittest.TestCase):
configuration = {
'code': 'www',
'clientId': '5604',
'makeCallUrl': 'https://retailcrm.pro'
'makeCallUrl': 'https://retailcrm.ru'
}
(pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/telephony/setting/' + configuration['code'] + '/edit')
@ -2148,7 +2150,7 @@ class TestVersion4(unittest.TestCase):
'id': 777,
'createdAt': '2020-04-05 11:23:46',
'active': 'true',
'email': 'mail@retailcrm.pro',
'email': 'mail@retailcrm.ru',
'firstName': 'yyy',
'lastName': 'xxxx',
'status': 'free',
@ -2187,7 +2189,7 @@ class TestVersion4(unittest.TestCase):
'id': 777,
'createdAt': '2020-04-05 11:23:46',
'active': 'true',
'email': 'mail@retailcrm.pro',
'email': 'mail@retailcrm.ru',
'firstName': 'yyy',
'lastName': 'xxxx',
'status': 'free',

View file

@ -1,7 +1,8 @@
# coding=utf-8
"""
RetailCRM API client v5 tests
retailCRM API client v5 tests
"""
from urllib.parse import urlencode
@ -188,7 +189,8 @@ class TestVersion5(unittest.TestCase):
Setup
"""
self.client = retailcrm.v5(os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
self.client = retailcrm.v5(
os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
@staticmethod
def dictionaryEncode(key, dictionary):
@ -200,7 +202,7 @@ class TestVersion5(unittest.TestCase):
V5 Test wrong api url
"""
(pook.get('https://epoqq.retailcrm.pro' + '/api/v5/statistic/update')
(pook.get('https://epoqq.retailcrm.ru' + '/api/v5/statistic/update')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.reply(404)
.headers(self.__header)
@ -212,7 +214,7 @@ class TestVersion5(unittest.TestCase):
)
)
client = retailcrm.v5('https://epoqq.retailcrm.pro', os.getenv('RETAILCRM_KEY'))
client = retailcrm.v5('https://epoqq.retailcrm.ru', os.getenv('RETAILCRM_KEY'))
response = client.statistic_update()
pook.off()
@ -245,6 +247,7 @@ class TestVersion5(unittest.TestCase):
"""
(pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/statistic/update')
.headers({'X-API-KEY': None})
.reply(200)
.headers(self.__header)
.json({'errorMsg': '"apiKey" is missing.'})
@ -410,7 +413,7 @@ class TestVersion5(unittest.TestCase):
self.assertTrue(response.get_status_code() < 400, True)
@pook.on
def test_costs_delete_v5(self):
def test_costs_delete(self):
"""
V5 Test method costs_delete
"""
@ -614,18 +617,17 @@ class TestVersion5(unittest.TestCase):
'elements': [{'name': 'fear', 'code': 'e456'}]
}
(pook.post("".join(
[
os.getenv('RETAILCRM_URL'),
'/api/v5/custom-fields/dictionaries/',
custom_dictionary['code'],
'/edit'
]))
(pook.post(
os.getenv('RETAILCRM_URL') +
'/api/v5/custom-fields/dictionaries/' +
custom_dictionary['code'] +
'/edit')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(self.dictionaryEncode('customDictionary', custom_dictionary))
.reply(200)
.headers(self.__header)
.json({'success': 'true', 'code': 'test'}))
.json({'success': 'true', 'code': 'test'})
)
response = self.client.custom_dictionary_edit(custom_dictionary)
pook.off()
@ -881,13 +883,12 @@ class TestVersion5(unittest.TestCase):
)
response = self.client.customers_history(
{
'sinceId': '1111',
'startDate': '2016-01-07',
'endDate': '2020-04-12'
}
{
'sinceId': '1111',
'startDate': '2016-01-07',
'endDate': '2020-04-12'
}
)
pook.off()
self.assertTrue(response.is_successful(), True)
@ -1144,7 +1145,7 @@ class TestVersion5(unittest.TestCase):
self.assertTrue(response.get_status_code() < 400, True)
@pook.on
def test_customers_history_v5(self):
def test_customers_history(self):
"""
V5 Test method customers_corporate_history
"""
@ -1198,11 +1199,11 @@ class TestVersion5(unittest.TestCase):
)
response = self.client.customers_corporate_history(
{
'sinceId': '1111',
'startDate': '2016-01-07',
'endDate': '2020-04-12'
}
{
'sinceId': '1111',
'startDate': '2016-01-07',
'endDate': '2020-04-12'
}
)
pook.off()
@ -1363,7 +1364,7 @@ class TestVersion5(unittest.TestCase):
'success': 'true',
'addresses': [{
'id': 3995,
'text': '123123, Russian Federation, Moscow, Kubuntu 14',
'text': '123123, Russian Federation, Moscow, Kutuzovski 14',
'isMain': 'true',
'name': 'Test'
}],
@ -1391,12 +1392,15 @@ class TestVersion5(unittest.TestCase):
address = {'isMain': 'true', 'name': 'Test', 'externalId': 'cc_9'}
(pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + address['externalId'] + '/addresses/create')
(pook.post(
os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + address[
'externalId'] + '/addresses/create')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(self.dictionaryEncode('address', address))
.reply(200)
.headers(self.__header)
.json({'success': 'true', 'id': 9717}))
.json({'success': 'true', 'id': 9717})
)
response = self.client.customer_corporate_addresses_create(address)
pook.off()
@ -1492,7 +1496,9 @@ class TestVersion5(unittest.TestCase):
company = {'isMain': 'true', 'name': 'TestN', 'externalId': 'cc_9'}
(pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + company['externalId'] + '/companies/create')
(pook.post(
os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + company[
'externalId'] + '/companies/create')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(self.dictionaryEncode('company', company))
.reply(200)
@ -1582,7 +1588,9 @@ class TestVersion5(unittest.TestCase):
contact = {'isMain': 'true', 'name': 'TestM', 'externalId': 'cc_9'}
(pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + contact['externalId'] + '/contacts/create')
(pook.post(
os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + contact[
'externalId'] + '/contacts/create')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(self.dictionaryEncode('contact', contact))
.reply(200)
@ -1662,7 +1670,8 @@ class TestVersion5(unittest.TestCase):
(pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/delivery/generic/' + code + '/tracking')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(self.dictionaryEncode('statusUpdate', delivery_id))
.body(self.dictionaryEncode(
'statusUpdate', delivery_id))
.reply(200)
.headers(self.__header)
.json({'success': 'true'})
@ -1998,29 +2007,30 @@ class TestVersion5(unittest.TestCase):
'currentPage': '1',
'totalPageCount': '87'
},
'integrationModule': {
'success': 'true',
'integrationModule': {
'code': 'xxx',
'integrationCode': 'xxx',
'active': 'true',
'freeze': 'false',
'name': 'test',
'native': 'false',
'actions': {},
'availableCountries': [],
'integrations': {
'store': {
'actions': [
{
'code': 'ccc',
'url': 'https://test'
}
]
'integrationModule':
{
'success': 'true',
'integrationModule': {
'code': 'xxx',
'integrationCode': 'xxx',
'active': 'true',
'freeze': 'false',
'name': 'test',
'native': 'false',
'actions': {},
'availableCountries': [],
'integrations': {
'store': {
'actions': [
{
'code': 'ccc',
'url': 'https://test'
}
]
}
}
}
}
}
}
)
)
@ -2252,11 +2262,11 @@ class TestVersion5(unittest.TestCase):
)
response = self.client.orders_history(
{
'sinceId': '1111',
'startDate': '2016-01-07',
'endDate': '2020-04-12'
}
{
'sinceId': '1111',
'startDate': '2016-01-07',
'endDate': '2020-04-12'
}
)
pook.off()
@ -2460,7 +2470,7 @@ class TestVersion5(unittest.TestCase):
self.assertTrue(response.get_status_code() < 400, True)
@pook.on
def test_orders_statuses_v5(self):
def test_orders_statuses(self):
"""
V5 Test method orders_statuses
"""
@ -2492,7 +2502,7 @@ class TestVersion5(unittest.TestCase):
self.assertTrue(response.get_status_code() < 400, True)
@pook.on
def test_orders_upload_v5(self):
def test_orders_upload(self):
"""
V5 Test method orders_upload
"""
@ -2523,7 +2533,7 @@ class TestVersion5(unittest.TestCase):
self.assertTrue(response.get_status_code() < 400, True)
@pook.on
def test_order_v5(self):
def test_order(self):
"""
V5 Test method order
"""
@ -4010,7 +4020,7 @@ class TestVersion5(unittest.TestCase):
(pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/store/inventories')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.params({'filter[site]': 'https://retailcrm.pro'})
.params({'filter[site]': 'https://retailcrm.ru'})
.reply(200)
.headers(self.__header)
.json(
@ -4026,13 +4036,13 @@ class TestVersion5(unittest.TestCase):
{
'id': 33937,
'externalId': '89387',
'site': 'https://retailcrm.pro',
'site': 'https://retailcrm.ru',
'quantity': 102
},
{
'id': 33933,
'externalId': '46',
'site': 'https://retailcrm.pro',
'site': 'https://retailcrm.ru',
'quantity': 0
}
]
@ -4040,7 +4050,7 @@ class TestVersion5(unittest.TestCase):
)
)
response = self.client.inventories({'site': 'https://retailcrm.pro'})
response = self.client.inventories({'site': 'https://retailcrm.ru'})
pook.off()
self.assertTrue(response.is_successful(), True)
@ -4467,7 +4477,7 @@ class TestVersion5(unittest.TestCase):
'firstName': 'John',
'lastName': 'Doe',
'patronymic': 'H.',
'email': 'mail@retailcrm.pro',
'email': 'mail@retailcrm.ru',
'code': 'ccc7'
},
'customer': {
@ -4476,7 +4486,7 @@ class TestVersion5(unittest.TestCase):
'firstName': 'John',
'lastName': 'Doe',
'patronymic': 'H.',
'email': 'mail@retailcrm.pro',
'email': 'mail@retailcrm.ru',
'code': 'ccc7',
'phones': [{'number': '+71111111111'}]
},
@ -4573,7 +4583,7 @@ class TestVersion5(unittest.TestCase):
'id': 777,
'createdAt': '2020-04-05 11:23:46',
'active': 'true',
'email': 'mail@retailcrm.pro',
'email': 'mail@retailcrm.ru',
'firstName': 'yyy',
'lastName': 'xxxx',
'status': 'free',
@ -4612,7 +4622,7 @@ class TestVersion5(unittest.TestCase):
'id': 777,
'createdAt': '2020-04-05 11:23:46',
'active': 'true',
'email': 'mail@retailcrm.pro',
'email': 'mail@retailcrm.ru',
'firstName': 'yyy',
'lastName': 'xxxx',
'status': 'free',
@ -4660,10 +4670,11 @@ class TestVersion5(unittest.TestCase):
"""
(pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/statistic/update')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.reply(200)
.headers(self.__header)
.json({'success': 'true'}))
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.reply(200)
.headers(self.__header)
.json({'success': 'true'})
)
response = self.client.statistic_update()
pook.off()