Class: ChatSDK::Twilio::ApiClient
- Inherits:
-
Object
- Object
- ChatSDK::Twilio::ApiClient
- Defined in:
- lib/chat_sdk/twilio/api_client.rb
Constant Summary collapse
- BASE_URL =
"https://api.twilio.com"
Instance Method Summary collapse
- #delete_message(message_sid:) ⇒ Object
-
#initialize(account_sid, auth_token) ⇒ ApiClient
constructor
A new instance of ApiClient.
- #list_messages(to: nil, from: nil, limit: 20) ⇒ Object
- #send_message(to:, body:, from: nil, messaging_service_sid: nil, media_url: nil) ⇒ Object
Constructor Details
#initialize(account_sid, auth_token) ⇒ ApiClient
Returns a new instance of ApiClient.
8 9 10 11 |
# File 'lib/chat_sdk/twilio/api_client.rb', line 8 def initialize(account_sid, auth_token) @account_sid = account_sid @auth_token = auth_token end |
Instance Method Details
#delete_message(message_sid:) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/chat_sdk/twilio/api_client.rb', line 31 def (message_sid:) response = connection.delete("/2010-04-01/Accounts/#{@account_sid}/Messages/#{}.json") return {} if response.status == 204 handle_response(response) end |
#list_messages(to: nil, from: nil, limit: 20) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/chat_sdk/twilio/api_client.rb', line 23 def (to: nil, from: nil, limit: 20) params = {"PageSize" => limit.to_s} params["To"] = to if to params["From"] = from if from response = connection.get(, params) handle_response(response) end |
#send_message(to:, body:, from: nil, messaging_service_sid: nil, media_url: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/chat_sdk/twilio/api_client.rb', line 13 def (to:, body:, from: nil, messaging_service_sid: nil, media_url: nil) params = {"To" => to, "Body" => body} params["From"] = from if from params["MessagingServiceSid"] = messaging_service_sid if messaging_service_sid params["MediaUrl"] = media_url if media_url response = connection.post(, URI.encode_www_form(params)) handle_response(response) end |