-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bundle libs internaly; implement twilio over http lib #143
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,65 @@ | |||
_BASE_URL = "https://api.twilio.com/2010-04-01" | |||
|
|||
def connect(conn, account_sid, auth_token=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a python reference for twilio sdk, I think we should stick with this standard instead of the connect option (rename connect to Client or NewClient)
from twilio.rest import Client
# Your Account SID and Auth Token from console.twilio.com
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)
message = client.messages.create(
to="+15558675309",
from_="+15017250604",
body="Hello from Python!")
print(message.sid)
def _url(path): | ||
return _BASE_URL + path | ||
|
||
def _post(path, body): | ||
resp = conn.post( | ||
_url(path), | ||
form_body=body, | ||
basic_auth=auth_token and (account_sid, auth_token) or None, | ||
) | ||
|
||
json = resp.body.json() | ||
|
||
if resp.status_code < 200 or resp.status_code >= 400: | ||
fail(json) | ||
|
||
return json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is probably shared utils for all http clients, can be lib/integrations/http
usable by itself
small effort to split it now and we can get a lot by reusing it
@@ -0,0 +1,16 @@ | |||
load("env", "TWILIO_ACCOUNT_SID", "TWILIO_AUTH_TOKEN", "TWILIO_MSG_SERVICE_SID") | |||
load("libs/integrations/twilio.star", "twilio") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is a predefined lib,
I think we can try (in a different ticket in the future) to add "libs" or "plugins" section to the manifest, and inject this code automatically
so
project:
libs:
- name: twilio
source: github/.... (optional, only if name is not auto resolved by ak core)
data:
account_sid: (from secret)
twilio_auth_token: (from secret)
then the script can just declare what it needs and start using it
without loading env and lib and setting up a client (although it can)
No description provided.