mirror of
https://github.com/retailcrm/api-client-python.git
synced 2025-04-01 20:26:10 +03:00
working orderGet
This commit is contained in:
parent
0fce38952d
commit
f50cd9e318
2 changed files with 2 additions and 38 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1,3 @@
|
||||||
*.swp
|
*.swp
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
|
38
IntaroApy.py
38
IntaroApy.py
|
@ -1,38 +0,0 @@
|
||||||
import requests
|
|
||||||
|
|
||||||
class IntaroApy:
|
|
||||||
'Intaro Api wrapper'
|
|
||||||
|
|
||||||
apiVersion = '3'
|
|
||||||
|
|
||||||
def __init__(self, crmUrl, apiKey):
|
|
||||||
self.crmUrl = crmUrl + '/api/v' + IntaroApy.apiVersion + '/'
|
|
||||||
self.apiKey = apiKey
|
|
||||||
self.parameters = { 'apiKey': apiKey }
|
|
||||||
|
|
||||||
def requestApi(self, url, method='GET', format='json'):
|
|
||||||
|
|
||||||
#TODO: catch http exceptions
|
|
||||||
if method == 'GET':
|
|
||||||
result = requests.get(url, params=self.parameters)
|
|
||||||
else if method == 'POST':
|
|
||||||
result = requests.post(url, data=self.parameters)
|
|
||||||
|
|
||||||
statusCode = result.status_code
|
|
||||||
r = result.json()
|
|
||||||
|
|
||||||
# reset params dict
|
|
||||||
self.parameters = { 'apiKey': apiKey }
|
|
||||||
|
|
||||||
if statusCode > 400 || r.has_key('success') && r['success'] == False :
|
|
||||||
#TODO: ApiException
|
|
||||||
|
|
||||||
if r.has_key('generatedAt') :
|
|
||||||
self.generatedAt = r['generatedAt']
|
|
||||||
del r['generatedAt']
|
|
||||||
|
|
||||||
del r['success']
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue