Skip to content

Commit d935066

Browse files
committed
Refactor of SMS XML method
1 parent e232b26 commit d935066

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

simpay/simpay.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from .__version__ import VERSION
22
from simpay.baseModel import RequestMethod, Response
33
from simpay.sms.client import SMSClient
4+
from simpay.sms_xml.client import SMSXMLClient
45
from simpay.directbilling.client import DirectBillingClient
56
import requests
67

@@ -42,6 +43,7 @@ def __init__(
4243
self._http_client.headers['X-SIM-PASSWORD'] = self.api_password
4344

4445
self.SMS: SMSClient = SMSClient(self)
46+
self.SMS_XML: SMSXMLClient = SMSXMLClient(self)
4547
self.DirectBilling: DirectBillingClient = DirectBillingClient(self)
4648

4749
def request(self, method: RequestMethod, uri: str, fields: dict[str, any] | None = None, headers: dict[str, any] | None = None, options: dict[str, any] | None = None) -> Response:

simpay/sms_xml/client.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
from typing import TYPE_CHECKING
12
import hashlib
23
import random
34
import string
45
import unicodedata
56
from simpay.sms_xml.models import PARAMS
67

8+
if TYPE_CHECKING:
9+
from simpay import Client
710

8-
class SMS_XML:
9-
def __init__(self, api_key):
10-
self.api_key = api_key
11+
class SMSXMLClient:
12+
def __init__(self, client: 'Client') -> None:
13+
self._client = client
1114

1215
def check_parameters(self, request):
1316
for param in PARAMS:
@@ -38,6 +41,6 @@ def sign(self, request):
3841
str(request.get("sms_from")) +
3942
str(request.get("send_number")) +
4043
str(request.get("send_time")) +
41-
str(self.api_key),
44+
str(self._client.api_key),
4245
encoding="utf8")
4346
).hexdigest()

0 commit comments

Comments
 (0)