Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Next Next commit
Add files of PoC, remove old ones
  • Loading branch information
strosek committed May 2, 2023
commit 9c625f06ce5e262bf7c1ab609e8b4957a240f0c5
File renamed without changes.
43 changes: 43 additions & 0 deletions api/sms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from collections.abc import Awaitable

from httpx import AsyncClient, Response

from models import SendRequestBody
from models.sms_preview_request import PreviewSMSRequestBody


class SMSClient:
PATH_PREVIEW_SMS = "/sms/1/preview"
PATH_SEND_SMS = "/sms/2/text/advanced"

def __init__(self, client: AsyncClient):
self.client = client
self.client.headers.update({"content-type": "application/json"})

def preview_message(
self, request_body: PreviewSMSRequestBody
) -> Awaitable[Response]:
"""Check how different message configurations will affect your message text, number of characters and message
parts.

:param request_body: Request body for previewing an SMS message
"""

return self.client.post(
self.PATH_PREVIEW_SMS,
json=request_body.to_dict(),
)

def send(
self,
request_body: SendRequestBody,
) -> Awaitable[Response]:
"""Send SMS message

:param request_body: Request body for sending an SMS message
"""

return self.client.post(
self.PATH_SEND_SMS,
json=request_body.to_dict(),
)
18 changes: 18 additions & 0 deletions client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from os import getenv
from httpx import AsyncClient
from api.sms import SMSClient


class InfobipAPIClient(AsyncClient):
def __init__(self, base_url=None, api_key: str = None):
if base_url is None:
base_url = getenv("IB_BASE_URL")
if api_key is None:
api_key = getenv("IB_API_KEY")

headers = {"Authorization": f"App {api_key}"}
headers.update({"User-Agent": "infobip-api-python-sdk/6.0.0"})

super().__init__(base_url=base_url, headers=headers)

self.SMS = SMSClient(self)
15 changes: 0 additions & 15 deletions infobip_channels/__init__.py

This file was deleted.

239 changes: 0 additions & 239 deletions infobip_channels/core/channel.py

This file was deleted.

Loading