Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
wakirin committed Sep 6, 2024
1 parent c7adeff commit d13fc08
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions middleware/pingprophet/integrations/SMSEdgeSMSRoutes.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ async def integration_activated(self, data):
"clicks_webhook_url": clicks_webhook_url[0]['value'] if clicks_webhook_url is not None else None,
})

await self.create_route_rate_settings(sms_route['id'], {
"country": 1,
"mcc": 3,
"mnc": 4,
"rate": 5,
})

# create hub endpoint
pricing_email = os.getenv('HUB_PRICING_EMAIL').split('@')
route_email = pricing_email[0] + "+" + sms_route['id'] + "@" + pricing_email[1]
Expand Down Expand Up @@ -227,6 +234,25 @@ async def create_sms_route(self, payload):

return res['data']

async def create_route_rate_settings(self, sms_route_id, payload):
timeout = aiohttp.ClientTimeout(total=5)
async with aiohttp.ClientSession(timeout=timeout) as session:
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": f"Bearer {self.team_token}",
}
url = f"{self.url}/api/v1/sms/routing/routes/{sms_route_id}/rate-settings"
self.logger.debug("Creating route rate settings in Comm.com: %s (%s)", url, payload)
async with session.post(url, headers=headers, json=payload) as resp:
res = await resp.json()
self.logger.debug("Response from Comm.com: (%s) %s", resp.status, res)

if resp.status != 200:
raise ValueError("Failed to create route rate settings in Comm.com")

return res['data']

async def endpoint_send_pricing_update(self, endpoint_id):
timeout = aiohttp.ClientTimeout(total=5)
async with aiohttp.ClientSession(timeout=timeout) as session:
Expand Down

0 comments on commit d13fc08

Please sign in to comment.