Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion target365_sdk/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def get_strex_transaction(self, transaction_id):
response = self.client.get(self.STREX_TRANSACTIONS + '/' + transaction_id)
response.raise_for_status()

return StrexTransaction(validate_keys=False, **response.json())
return StrexTransaction(**response.json())

def delete_strex_transaction(self, transaction_id):
"""
Expand Down
17 changes: 17 additions & 0 deletions target365_sdk/models/delivery_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from .model import Model

class DeliveryReport(Model):

def _accepted_params(self):
return [
'correlationId',
'transactionId',
'price',
'sender',
'recipient',
'operator',
'statusCode',
'detailedStatusCode',
'delivered',
'billed',
]
20 changes: 20 additions & 0 deletions target365_sdk/models/detailed_status_codes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class DetailedStatusCodes:
NONE = "None"
DELIVERED = "Delivered"
EXPIRED = "Expired"
UNDELIVERED = "Undelivered"
UNKNOWN_ERROR = "UnknownError"
REJECTED = "Rejected"
UNKNOWN_SUBSCRIBER = "UnknownSubscriber"
SUBSCRIBER_UNAVAILABLE = "SubscriberUnavailable"
SUBSCRIBER_BARRED = "SubscriberBarred"
INSUFFICIENT_FUNDS = "InsufficientFunds"
REGISTRATION_REQUIRED = "RegistrationRequired"
UNKNOWN_AGE = "UnknownAge"
DUPLICATE_TRANSACTION = "DuplicateTransaction"
SUBSCRIBER_LIMIT_EXCEEDED = "SubscriberLimitExceeded"
MAX_PIN_RETRY = "MaxPinRetry"
INVALID_AMOUNT = "InvalidAmount"
ONE_TIME_PASSWORD_EXPIRED = "OneTimePasswordExpired"
ONE_TIME_PASSWORD_FAILED = "OneTimePasswordFailed"
SUBSCRIBER_TOO_YOUNG = "SubscriberTooYoung"
10 changes: 3 additions & 7 deletions target365_sdk/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
class Model:
__metaclass__ = ABCMeta

def __init__(self, validate_keys=True, **kwargs):
def __init__(self, **kwargs):

args = self._init_preprocess(kwargs)

if type(args) is not dict:
raise Exception('_init_preprocess() must return a dict')

for key, value in args.items():

if validate_keys and key not in self._accepted_params():
raise Exception('This model does not allow parameter `' + key + '`')

setattr(self, key, value)

if key in self._accepted_params():
setattr(self, key, value)

def _init_preprocess(self, args):
"""
Expand Down
1 change: 1 addition & 0 deletions target365_sdk/models/out_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def _accepted_params(self):
'lastModified',
'created',
'statusCode',
'detailedStatusCode',
'delivered',
'tags',
'properties',
Expand Down
2 changes: 2 additions & 0 deletions target365_sdk/models/out_message_strex.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ def _accepted_params(self):
'invoiceText',
'price',
'billed',
'resultCode',
'resultDescription',
]
6 changes: 6 additions & 0 deletions target365_sdk/models/status_codes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class StatusCodes:
QUEUED = "Queued"
SENT = "Sent"
FAILED = "Failed"
OK = "Ok"
REVERSED = "Reversed"
1 change: 1 addition & 0 deletions target365_sdk/models/strex_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def _accepted_params(self):
'created',
'deliveryMode',
'statusCode',
'detailedStatusCode',
'accountId',
'billed',
'properties',
Expand Down
7 changes: 3 additions & 4 deletions target365_sdk/tests/test_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,23 +214,22 @@ def test_create_one_time_password(client, random_transaction_id):
client.create_one_time_password(one_time_password)


def test_get_time_password(client, transaction_id):
def test_get_one_time_password(client, transaction_id):
one_time_password = client.get_one_time_password(transaction_id)

assert one_time_password.transactionId == transaction_id


def test_strex_transaction_sequence(client, random_transaction_id):
strex_transaction_data = {
"created": "2018-11-02T12:00:00Z",
"invoiceText": "Thank you for your donation",
"lastModified": "2018-11-02T12:00:00Z",
"merchantId": "mer_test",
"price": 10,
"recipient": "+4798079008",
"serviceCode": "14002",
"shortNumber": "2001",
"transactionId": random_transaction_id
"transactionId": random_transaction_id,
"oneTimePassword": "1234"
}

strex_transaction = StrexTransaction(**strex_transaction_data)
Expand Down