|
|
|
@ -12,7 +12,15 @@ __all__ = ("Receiver", "Sender")
|
|
|
|
|
|
|
|
|
|
BASE_URL = "https://api.sipgate.com/v2"
|
|
|
|
|
|
|
|
|
|
auth = HTTPBasicAuth(
|
|
|
|
|
inbound_auth = HTTPBasicAuth(
|
|
|
|
|
settings.SMS_SETTINGS.get(
|
|
|
|
|
"sipgate_incoming_token_id", settings.SIPGATE_INCOMING_TOKEN_ID
|
|
|
|
|
),
|
|
|
|
|
settings.SMS_SETTINGS.get(
|
|
|
|
|
"sipgate_incoming_token", settings.SIPGATE_INCOMING_TOKEN
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
outbound_auth = HTTPBasicAuth(
|
|
|
|
|
settings.SMS_SETTINGS.get("sipgate_token_id", settings.SIPGATE_TOKEN_ID),
|
|
|
|
|
settings.SMS_SETTINGS.get("sipgate_token", settings.SIPGATE_TOKEN),
|
|
|
|
|
)
|
|
|
|
@ -41,7 +49,9 @@ class Receiver(BaseReceiver):
|
|
|
|
|
total = 10
|
|
|
|
|
while offset < total:
|
|
|
|
|
r = requests.get(
|
|
|
|
|
f"{BASE_URL}/history", auth=auth, params=params | {"offset": offset}
|
|
|
|
|
f"{BASE_URL}/history",
|
|
|
|
|
auth=inbound_auth,
|
|
|
|
|
params=params | {"offset": offset},
|
|
|
|
|
)
|
|
|
|
|
r.raise_for_status()
|
|
|
|
|
|
|
|
|
@ -69,7 +79,7 @@ class Sender(BaseSender):
|
|
|
|
|
for message in messages:
|
|
|
|
|
r = requests.post(
|
|
|
|
|
f"{BASE_URL}/sessions/sms",
|
|
|
|
|
auth=auth,
|
|
|
|
|
auth=outbound_auth,
|
|
|
|
|
json={
|
|
|
|
|
"smsId": settings.SMS_SETTINGS.get(
|
|
|
|
|
"sipgate_sms_extension", settings.SIPGATE_SMS_EXTENSION
|
|
|
|
|