Merge pull request #17 from gwinn/master

fixes #14 issue with payment_edit method
This commit is contained in:
Alex Lushpai 2020-02-27 14:10:54 +03:00 committed by GitHub
commit 41084fd4be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 6 deletions

View File

@ -1 +0,0 @@
3.7.3

View File

@ -476,7 +476,7 @@ class Client(Base):
return self.post('/orders/payments/' + str(uid) + '/delete')
def order_payment_edit(self, payment, uid_type='externalId', site=None):
def order_payment_edit(self, payment, uid_type='id', site=None):
"""
:param payment: object
:param uid_type: string
@ -484,13 +484,10 @@ class Client(Base):
:return: Response
"""
self.parameters['payment'] = json.dumps(payment)
self.parameters['by'] = uid_type
if site is not None:
self.parameters['site'] = site
if uid_type != 'externalId':
self.parameters['by'] = uid_type
return self.post('/orders/payments/' + str(payment[uid_type]) + '/edit')
def orders_statuses(self, ids, external_ids):

View File

@ -37,6 +37,7 @@ setup(
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Software Development :: Libraries :: Python Modules',
]

View File

@ -7,6 +7,7 @@ retailCRM API client v5 tests
import unittest
import os
import random
import retailcrm
@ -72,3 +73,43 @@ class TestVersion5(unittest.TestCase):
self.assertTrue(response.is_successful(), True)
self.assertTrue(response.get_status_code() < 400, True)
def test_check_order_payment(self):
rand = random.randint(10000, 99999)
ex_id = 'test-case-payment' + str(rand)
order = {
'firstName': 'John',
'lastName': 'Doe',
'phone': '+79000000000',
'email': 'john@example.com',
'orderMethod': 'call-request',
'delivery': {
'code': 'self-delivery'
},
'payments': [
{
'externalId': ex_id,
'amount': 100,
'type': 'cash'
}
]
}
response = self.client.order_create(order)
response_data = response.get_response()
payment_id = response_data['order']['payments'][0]['id']
print(payment_id)
self.assertTrue(response.is_successful(), True)
self.assertTrue(response.get_status_code() < 400, True)
payment_response = self.client.order_payment_edit({'externalId': ex_id, 'status': 'invoice'}, 'externalId')
self.assertTrue(payment_response.is_successful(), True)
self.assertTrue(payment_response.get_status_code() < 400, True)
payment_response = self.client.order_payment_edit({'id': payment_id, 'status': 'paid'})
self.assertTrue(payment_response.is_successful(), True)
self.assertTrue(payment_response.get_status_code() < 400, True)