Skip to content

Commit 33b0512

Browse files
author
Marian Ganisin
authored
Merge pull request #129 from averevki/invoice-payment-transactions
Add credit card endpoints
2 parents 8e05d3f + 4b088a9 commit 33b0512

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

threescale_api/resources.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,17 @@ def charge(self, entity_id: int):
890890
return instance
891891

892892

893+
class PaymentTransactions(DefaultClient):
894+
def __init__(self, *args, entity_name='payment_transaction',
895+
entity_collection='payment_transactions', **kwargs):
896+
super().__init__(*args, entity_name=entity_name,
897+
entity_collection=entity_collection, **kwargs)
898+
899+
@property
900+
def url(self) -> str:
901+
return self.parent.url + '/payment_transactions'
902+
903+
893904
class FieldsDefinitions(DefaultClient):
894905
def __init__(self, *args, entity_name='fields_definition',
895906
entity_collection='fields_definitions', **kwargs):
@@ -1252,6 +1263,16 @@ def applications(self) -> Applications:
12521263
def users(self) -> AccountUsers:
12531264
return AccountUsers(parent=self, instance_klass=AccountUser)
12541265

1266+
def credit_card_set(self, params: dict = None, **kwargs):
1267+
url = self.url + "/credit_card"
1268+
response = self.client.rest.put(url=url, json=params, **kwargs)
1269+
return response
1270+
1271+
def credit_card_delete(self, params: dict = None, **kwargs):
1272+
url = self.url + "/credit_card"
1273+
response = self.client.rest.delete(url=url, json=params, **kwargs)
1274+
return response
1275+
12551276

12561277
class UserPermissions(DefaultResource):
12571278
pass
@@ -1416,6 +1437,15 @@ def state_update(self, state: InvoiceState):
14161437
def charge(self):
14171438
return self.client.charge(entity_id=self.entity_id)
14181439

1440+
@property
1441+
def payment_transactions(self) -> 'PaymentTransactions':
1442+
return PaymentTransactions(parent=self, instance_klass=PaymentTransaction)
1443+
1444+
1445+
class PaymentTransaction(DefaultResource):
1446+
def __init__(self, entity_name='name', **kwargs):
1447+
super().__init__(entity_name=entity_name, **kwargs)
1448+
14191449

14201450
class FieldsDefinition(DefaultResource):
14211451
def __init__(self, entity_name='name', **kwargs):

0 commit comments

Comments
 (0)