mirror of
https://github.com/retailcrm/api-client-python.git
synced 2024-11-24 22:16:06 +03:00
commit
361d2cc537
@ -27,19 +27,19 @@ class Base(object):
|
||||
: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)
|
||||
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})
|
||||
|
||||
return Response(response.status_code, response.json())
|
||||
|
||||
def post(self, url):
|
||||
def post(self, url, version=True):
|
||||
"""
|
||||
Post request
|
||||
:return: Response
|
||||
"""
|
||||
requests_url = self.api_url + url
|
||||
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})
|
||||
|
||||
|
@ -312,7 +312,6 @@ class Client(Base):
|
||||
def pack_edit(self, pack):
|
||||
"""
|
||||
:param pack:
|
||||
:param uid:
|
||||
:return: Response
|
||||
"""
|
||||
self.parameters['pack'] = json.dumps(pack)
|
||||
|
@ -603,7 +603,6 @@ class Client(Base):
|
||||
def pack_edit(self, pack):
|
||||
"""
|
||||
:param pack:
|
||||
:param uid:
|
||||
:return: Response
|
||||
"""
|
||||
self.parameters['pack'] = json.dumps(pack)
|
||||
@ -1072,4 +1071,6 @@ class Client(Base):
|
||||
:return: Response
|
||||
"""
|
||||
|
||||
return self.post('/users/' + str(uid)) + '/' + status
|
||||
self.parameters['status'] = status
|
||||
|
||||
return self.post('/users/' + str(uid) + '/status')
|
||||
|
6
setup.py
6
setup.py
@ -8,14 +8,14 @@ import os
|
||||
from setuptools import setup
|
||||
|
||||
|
||||
def read(fname):
|
||||
def read(filename):
|
||||
"""Read readme for long description"""
|
||||
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
||||
return open(os.path.join(os.path.dirname(__file__), filename)).read()
|
||||
|
||||
|
||||
setup(
|
||||
name='retailcrm',
|
||||
version='5.0.2',
|
||||
version='5.0.3',
|
||||
description='retailCRM API client',
|
||||
long_description=read('README'),
|
||||
url='https://github.com/retailcrm/api-client-python',
|
||||
|
@ -27,7 +27,7 @@ class TestVersion5(unittest.TestCase):
|
||||
V5 Test wrong api url
|
||||
"""
|
||||
client = retailcrm.v5(
|
||||
'https://epoqwieqwpoieqpwoeiqpwoeiq.retailcrm.ru', '98sdf9sj8fsd9fjs9dfjs98')
|
||||
'https://epoqwieqwpoieqpwoeiqpwoeiq.retailcrm.ru', '98sdf9sj8fsd9fjs9answer98')
|
||||
response = client.statistic_update()
|
||||
|
||||
self.assertTrue(response.is_successful(), False)
|
||||
@ -37,8 +37,7 @@ class TestVersion5(unittest.TestCase):
|
||||
"""
|
||||
V5 Test wrong api key
|
||||
"""
|
||||
client = retailcrm.v5(os.getenv('RETAILCRM_URL'),
|
||||
'98sdf9sj8fsd9fjs9dfjs98')
|
||||
client = retailcrm.v5(os.getenv('RETAILCRM_URL'), '98sdf9sj8fsd9fjs9answer98')
|
||||
response = client.statistic_update()
|
||||
|
||||
self.assertEqual(response.get_error_msg(), 'Wrong "apiKey" value.')
|
||||
@ -67,3 +66,36 @@ class TestVersion5(unittest.TestCase):
|
||||
response = self.client.api_credentials()
|
||||
|
||||
self.assertTrue(response.is_successful(), True)
|
||||
|
||||
# def test_telephony_calls_upload(self):
|
||||
# """
|
||||
# V5 Test telephony calls upload
|
||||
# """
|
||||
#
|
||||
# calls = [
|
||||
# {
|
||||
# 'date': '2018-04-20 22:10:00',
|
||||
# 'type': 'in',
|
||||
# 'phone': '+79999999999',
|
||||
# 'userId': os.getenv('RETAILCRM_USER'),
|
||||
# 'result': 'answered'
|
||||
# },
|
||||
# {
|
||||
# 'date': '2018-04-20 22:10:00',
|
||||
# 'type': 'out',
|
||||
# 'phone': '+79999999999',
|
||||
# 'userId': os.getenv('RETAILCRM_USER'),
|
||||
# 'result': 'answered'
|
||||
# }
|
||||
# ]
|
||||
#
|
||||
# response = self.client.telephony_calls_upload(calls)
|
||||
#
|
||||
# self.assertTrue(response.is_successful(), True)
|
||||
# self.assertTrue(response.get_status_code() < 400, True)
|
||||
|
||||
def test_set_user_status(self):
|
||||
response = self.client.user_status(os.getenv('RETAILCRM_USER'), 'dinner')
|
||||
|
||||
self.assertTrue(response.is_successful(), True)
|
||||
self.assertTrue(response.get_status_code() < 400, True)
|
||||
|
Loading…
Reference in New Issue
Block a user