Skip to content

Commit

Permalink
Merge pull request #129 from averevki/invoice-payment-transactions
Browse files Browse the repository at this point in the history
Add credit card endpoints
  • Loading branch information
Marian Ganisin authored Oct 3, 2022
2 parents 8e05d3f + 4b088a9 commit 33b0512
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions threescale_api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,17 @@ def charge(self, entity_id: int):
return instance


class PaymentTransactions(DefaultClient):
def __init__(self, *args, entity_name='payment_transaction',
entity_collection='payment_transactions', **kwargs):
super().__init__(*args, entity_name=entity_name,
entity_collection=entity_collection, **kwargs)

@property
def url(self) -> str:
return self.parent.url + '/payment_transactions'


class FieldsDefinitions(DefaultClient):
def __init__(self, *args, entity_name='fields_definition',
entity_collection='fields_definitions', **kwargs):
Expand Down Expand Up @@ -1252,6 +1263,16 @@ def applications(self) -> Applications:
def users(self) -> AccountUsers:
return AccountUsers(parent=self, instance_klass=AccountUser)

def credit_card_set(self, params: dict = None, **kwargs):
url = self.url + "/credit_card"
response = self.client.rest.put(url=url, json=params, **kwargs)
return response

def credit_card_delete(self, params: dict = None, **kwargs):
url = self.url + "/credit_card"
response = self.client.rest.delete(url=url, json=params, **kwargs)
return response


class UserPermissions(DefaultResource):
pass
Expand Down Expand Up @@ -1416,6 +1437,15 @@ def state_update(self, state: InvoiceState):
def charge(self):
return self.client.charge(entity_id=self.entity_id)

@property
def payment_transactions(self) -> 'PaymentTransactions':
return PaymentTransactions(parent=self, instance_klass=PaymentTransaction)


class PaymentTransaction(DefaultResource):
def __init__(self, entity_name='name', **kwargs):
super().__init__(entity_name=entity_name, **kwargs)


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

0 comments on commit 33b0512

Please sign in to comment.