This repository has been archived by the owner on Jun 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from ttt246/feature/twilio_7
Feature/twilio 7
- Loading branch information
Showing
11 changed files
with
206 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,4 +100,5 @@ Werkzeug==2.2.3 | |
win32-setctime==1.1.0 | ||
wrapt==1.15.0 | ||
yarl==1.8.2 | ||
twilio==8.2.1 | ||
rising_plugin==0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
- id: global | ||
children: | ||
- id: variable | ||
name: protocol | ||
value: https:// | ||
- id: variable | ||
name: domain | ||
value: smartphone.herokuapp.com | ||
- id: variable | ||
name: endpoint | ||
value: /chat_rising | ||
- id: sets | ||
children: | ||
- id: set | ||
children: [] | ||
name: default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
assertions: | ||
- id: post | ||
children: | ||
- id: body | ||
contentType: application/json | ||
content: >- | ||
{ | ||
"token": "test_token", | ||
"uuid": "test_uuid", | ||
"history": [{ | ||
"role": "system", | ||
"content": "You are a helpful assistant." | ||
}, | ||
{ | ||
"role": "user", | ||
"content": "Who won the world series in 2020?" | ||
}, | ||
{ | ||
"role": "assistant", | ||
"content": "The Los Angeles Dodgers won the World Series in 2020." | ||
} | ||
], | ||
"user_input": "Where was it played?", | ||
"model": "gpt-3.5-turbo" | ||
} | ||
url: ${protocol}${domain}${endpoint} | ||
var: payload | ||
mode: json | ||
- id: assert-equals | ||
expression: payload_response.headers['Content-Type'] | ||
value: application/json | ||
- id: assert-exists | ||
expression: payload | ||
- id: assert-exists | ||
expression: payload.message | ||
- id: assert-exists | ||
expression: payload.result | ||
configs: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"""sms message model includes from, to and body""" | ||
from typing import Any | ||
|
||
|
||
class SMSModel: | ||
def __init__(self, _from="", _to="", body=""): | ||
self._from = _from | ||
self._to = _to | ||
self.body = body | ||
|
||
def get_sms_model(self, data: Any) -> None: | ||
self._from = data["from"] | ||
self._to = data["to"] | ||
self.body = data["body"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""service for sms using twilio apis""" | ||
import json | ||
from typing import Any | ||
|
||
from twilio.rest import Client | ||
|
||
from src.common.utils import ACCOUNT_SID, AUTH_TOKEN | ||
from src.logs import logger | ||
from src.model.sms_model import SMSModel | ||
|
||
|
||
class TwilioService: | ||
def __init__(self): | ||
self.client = Client(ACCOUNT_SID, AUTH_TOKEN) | ||
|
||
def send_sms(self, data: SMSModel) -> Any: | ||
message = self.client.messages.create( | ||
body=data.body, from_=data._from, to=data._to | ||
) | ||
logger.info( | ||
message=message.sid, | ||
title="sent twilio sms", | ||
) | ||
return message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters