twilio-ruby 5.72.0 → 5.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/pr-lint.yml +8 -2
- data/.github/workflows/test-and-deploy.yml +3 -3
- data/CHANGES.md +234 -0
- data/CONTRIBUTING.md +1 -7
- data/LICENSE +1 -1
- data/README.md +132 -45
- data/advanced-examples/custom-http-client.md +170 -0
- data/lib/twilio-ruby/rest/api/v2010/account/address.rb +19 -3
- data/lib/twilio-ruby/rest/api/v2010/account/application.rb +22 -3
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/local.rb +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/machine_to_machine.rb +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/mobile.rb +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/national.rb +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/shared_cost.rb +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/voip.rb +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account/call/feedback.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/call/feedback_summary.rb +5 -5
- data/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account/call/user_defined_message.rb +160 -0
- data/lib/twilio-ruby/rest/api/v2010/account/call/user_defined_message_subscription.rb +251 -0
- data/lib/twilio-ruby/rest/api/v2010/account/call.rb +59 -0
- data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +56 -17
- data/lib/twilio-ruby/rest/api/v2010/account/conference/recording.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/conference.rb +5 -5
- data/lib/twilio-ruby/rest/api/v2010/account/message.rb +17 -1
- data/lib/twilio-ruby/rest/api/v2010/account/queue/member.rb +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account/queue.rb +6 -6
- data/lib/twilio-ruby/rest/api/v2010/account/recording/transcription.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/recording.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list/ip_address.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/transcription.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/all_time.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/daily.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/last_month.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/monthly.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/this_month.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/today.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/yearly.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/yesterday.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record.rb +1 -1
- data/lib/twilio-ruby/rest/autopilot/v1/assistant/task/task_statistics.rb +2 -2
- data/lib/twilio-ruby/rest/bulkexports/v1/export/day.rb +1 -1
- data/lib/twilio-ruby/rest/chat/v1/service/channel/message.rb +1 -1
- data/lib/twilio-ruby/rest/chat/v1/service/channel.rb +2 -2
- data/lib/twilio-ruby/rest/chat/v1/service/user.rb +1 -1
- data/lib/twilio-ruby/rest/chat/v1/service.rb +2 -2
- data/lib/twilio-ruby/rest/chat/v2/service/channel/message.rb +1 -1
- data/lib/twilio-ruby/rest/chat/v2/service/channel.rb +2 -2
- data/lib/twilio-ruby/rest/chat/v2/service/user.rb +1 -1
- data/lib/twilio-ruby/rest/chat/v2/service.rb +4 -4
- data/lib/twilio-ruby/rest/chat/v3/channel.rb +2 -2
- data/lib/twilio-ruby/rest/client.rb +14 -0
- data/lib/twilio-ruby/rest/content/v1/content/approval_fetch.rb +195 -0
- data/lib/twilio-ruby/rest/content/v1/content.rb +346 -0
- data/lib/twilio-ruby/rest/content/v1/content_and_approvals.rb +240 -0
- data/lib/twilio-ruby/rest/content/v1/legacy_content.rb +254 -0
- data/lib/twilio-ruby/rest/content/v1.rb +59 -0
- data/lib/twilio-ruby/rest/content.rb +59 -0
- data/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb +1 -1
- data/lib/twilio-ruby/rest/conversations/v1/conversation/message.rb +17 -2
- data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +43 -5
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb +1 -1
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +17 -2
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +43 -5
- data/lib/twilio-ruby/rest/events/v1/schema/version.rb +1 -1
- data/lib/twilio-ruby/rest/events/v1/schema.rb +1 -1
- data/lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb +1 -1
- data/lib/twilio-ruby/rest/flex_api/v1/assessments.rb +397 -0
- data/lib/twilio-ruby/rest/flex_api/v1/insights_assessments_comment.rb +314 -0
- data/lib/twilio-ruby/rest/flex_api/v1/insights_conversations.rb +216 -0
- data/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires.rb +394 -0
- data/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires_category.rb +313 -0
- data/lib/twilio-ruby/rest/flex_api/v1/insights_questionnaires_question.rb +390 -0
- data/lib/twilio-ruby/rest/flex_api/v1/insights_segments.rb +413 -0
- data/lib/twilio-ruby/rest/{preview/trusted_comms/brands_information.rb → flex_api/v1/insights_session.rb} +58 -55
- data/lib/twilio-ruby/rest/flex_api/v1/insights_settings_answersets.rb +144 -0
- data/lib/twilio-ruby/rest/flex_api/v1/insights_settings_comment.rb +130 -0
- data/lib/twilio-ruby/rest/{preview/trusted_comms/cps.rb → flex_api/v1/insights_user_roles.rb} +42 -54
- data/lib/twilio-ruby/rest/flex_api/v1.rb +122 -0
- data/lib/twilio-ruby/rest/flex_api/v2/web_channels.rb +133 -0
- data/lib/twilio-ruby/rest/flex_api/v2.rb +35 -0
- data/lib/twilio-ruby/rest/flex_api.rb +89 -0
- data/lib/twilio-ruby/rest/insights/v1/call/summary.rb +7 -0
- data/lib/twilio-ruby/rest/insights/v1/call_summaries.rb +16 -3
- data/lib/twilio-ruby/rest/insights/v1/room/participant.rb +1 -1
- data/lib/twilio-ruby/rest/insights/v1/room.rb +3 -3
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb +1 -1
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb +2 -2
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb +1 -1
- data/lib/twilio-ruby/rest/ip_messaging/v1/service.rb +2 -2
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb +1 -1
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb +2 -2
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb +1 -1
- data/lib/twilio-ruby/rest/ip_messaging/v2/service.rb +4 -4
- data/lib/twilio-ruby/rest/lookups/v2/phone_number.rb +88 -6
- data/lib/twilio-ruby/rest/media/v1/media_processor.rb +1 -1
- data/lib/twilio-ruby/rest/media/v1/media_recording.rb +2 -2
- data/lib/twilio-ruby/rest/media/v1/player_streamer.rb +1 -1
- data/lib/twilio-ruby/rest/messaging/v1/brand_registration/brand_registration_otp.rb +134 -0
- data/lib/twilio-ruby/rest/messaging/v1/brand_registration.rb +26 -3
- data/lib/twilio-ruby/rest/messaging/v1/domain_cert.rb +257 -0
- data/lib/twilio-ruby/rest/messaging/v1/domain_config.rb +242 -0
- data/lib/twilio-ruby/rest/messaging/v1/domain_config_messaging_service.rb +226 -0
- data/lib/twilio-ruby/rest/messaging/v1/linkshortening_messaging_service.rb +218 -0
- data/lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb +98 -3
- data/lib/twilio-ruby/rest/messaging/v1/service.rb +1 -1
- data/lib/twilio-ruby/rest/messaging/v1/tollfree_verification.rb +165 -1
- data/lib/twilio-ruby/rest/messaging/v1.rb +75 -0
- data/lib/twilio-ruby/rest/messaging.rb +36 -0
- data/lib/twilio-ruby/rest/microvisor/v1/account_config.rb +317 -0
- data/lib/twilio-ruby/rest/microvisor/v1/account_secret.rb +310 -0
- data/lib/twilio-ruby/rest/microvisor/v1/app/app_manifest.rb +192 -0
- data/lib/twilio-ruby/rest/microvisor/v1/app.rb +25 -0
- data/lib/twilio-ruby/rest/microvisor/v1/device/device_config.rb +342 -0
- data/lib/twilio-ruby/rest/microvisor/v1/device/device_secret.rb +335 -0
- data/lib/twilio-ruby/rest/microvisor/v1/device.rb +61 -0
- data/lib/twilio-ruby/rest/microvisor/v1.rb +32 -0
- data/lib/twilio-ruby/rest/microvisor.rb +16 -0
- data/lib/twilio-ruby/rest/notify/v1/service/notification.rb +1 -1
- data/lib/twilio-ruby/rest/numbers/v1/eligibility.rb +111 -0
- data/lib/twilio-ruby/rest/numbers/v1.rb +35 -0
- data/lib/twilio-ruby/rest/numbers.rb +13 -0
- data/lib/twilio-ruby/rest/oauth/v1/device_code.rb +153 -0
- data/lib/twilio-ruby/rest/oauth/v1/oauth.rb +162 -0
- data/lib/twilio-ruby/rest/oauth/v1/openid_discovery.rb +242 -0
- data/lib/twilio-ruby/rest/oauth/v1/token.rb +157 -0
- data/lib/twilio-ruby/rest/oauth/v1/user_info.rb +193 -0
- data/lib/twilio-ruby/rest/oauth/v1.rb +63 -0
- data/lib/twilio-ruby/rest/oauth.rb +68 -0
- data/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document/dependent_hosted_number_order.rb +2 -2
- data/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb +2 -2
- data/lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb +1 -1
- data/lib/twilio-ruby/rest/preview/understand/assistant/task/task_statistics.rb +2 -2
- data/lib/twilio-ruby/rest/preview/wireless/rate_plan.rb +1 -1
- data/lib/twilio-ruby/rest/preview.rb +0 -33
- data/lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb +1 -1
- data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +1 -14
- data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +5 -46
- data/lib/twilio-ruby/rest/proxy/v1/service.rb +1 -1
- data/lib/twilio-ruby/rest/studio/v1/flow.rb +1 -1
- data/lib/twilio-ruby/rest/studio/v2/flow/flow_revision.rb +1 -1
- data/lib/twilio-ruby/rest/studio/v2/flow.rb +1 -1
- data/lib/twilio-ruby/rest/supersim/v1/esim_profile.rb +21 -1
- data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +1 -1
- data/lib/twilio-ruby/rest/supersim/v1/ip_command.rb +5 -2
- data/lib/twilio-ruby/rest/supersim/v1/settings_update.rb +247 -0
- data/lib/twilio-ruby/rest/supersim/v1/sms_command.rb +3 -3
- data/lib/twilio-ruby/rest/supersim/v1/usage_record.rb +4 -4
- data/lib/twilio-ruby/rest/supersim/v1.rb +7 -0
- data/lib/twilio-ruby/rest/supersim.rb +6 -0
- data/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb +1 -1
- data/lib/twilio-ruby/rest/sync/v1/service.rb +1 -1
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb +1 -1
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb +18 -5
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +3 -3
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics.rb +12 -12
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics.rb +5 -5
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb +10 -4
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb +3 -3
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_cumulative_statistics.rb +6 -6
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_real_time_statistics.rb +1 -1
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +9 -3
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.rb +13 -13
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_real_time_statistics.rb +2 -2
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb +1 -1
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.rb +13 -13
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb +3 -3
- data/lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb +2 -2
- data/lib/twilio-ruby/rest/verify/v2/service/access_token.rb +1 -9
- data/lib/twilio-ruby/rest/verify/v2/service/entity/challenge/notification.rb +1 -7
- data/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb +0 -8
- data/lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb +0 -8
- data/lib/twilio-ruby/rest/verify/v2/service/entity/new_factor.rb +0 -6
- data/lib/twilio-ruby/rest/verify/v2/service/entity.rb +0 -8
- data/lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb +2 -2
- data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +12 -6
- data/lib/twilio-ruby/rest/verify/v2/service/webhook.rb +0 -8
- data/lib/twilio-ruby/rest/verify/v2/service.rb +4 -4
- data/lib/twilio-ruby/rest/verify/v2/template.rb +10 -3
- data/lib/twilio-ruby/rest/verify/v2/verification_attempts_summary.rb +4 -4
- data/lib/twilio-ruby/rest/video/v1/composition.rb +3 -3
- data/lib/twilio-ruby/rest/video/v1/recording.rb +2 -2
- data/lib/twilio-ruby/rest/video/v1/room/recording.rb +2 -2
- data/lib/twilio-ruby/rest/video/v1/room.rb +4 -4
- data/lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb +2 -2
- data/lib/twilio-ruby/rest/voice/v1/dialing_permissions/bulk_country_update.rb +1 -1
- data/lib/twilio-ruby/rest/voice/v1/ip_record.rb +1 -1
- data/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb +3 -3
- data/lib/twilio-ruby/rest/wireless/v1/sim/data_session.rb +2 -2
- data/lib/twilio-ruby/twiml/voice_response.rb +132 -33
- data/lib/twilio-ruby/version.rb +1 -1
- data/twilio-ruby.gemspec +1 -1
- metadata +48 -12
- data/lib/twilio-ruby/rest/preview/trusted_comms/branded_channel/channel.rb +0 -165
- data/lib/twilio-ruby/rest/preview/trusted_comms/branded_channel.rb +0 -225
- data/lib/twilio-ruby/rest/preview/trusted_comms/current_call.rb +0 -277
- data/lib/twilio-ruby/rest/preview/trusted_comms.rb +0 -65
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Custom HTTP Clients for the Twilio Ruby Helper Library
|
|
2
|
+
|
|
3
|
+
If you are working with the Twilio Ruby Helper Library, and you need to be able to modify the HTTP requests that the library makes to the Twilio servers, you’re in the right place. The most common need to alter the HTTP request is to connect and authenticate with an enterprise’s proxy server. We’ll provide sample code that you can drop right into your app to handle this use case.
|
|
4
|
+
|
|
5
|
+
Connect and authenticate with a proxy server
|
|
6
|
+
To connect and provide credentials to a proxy server that may be between your app and Twilio, you need a way to modify the HTTP requests that the Twilio helper library makes on your behalf to invoke the Twilio REST API.
|
|
7
|
+
|
|
8
|
+
The Twilio Ruby helper library uses the [Faraday](https://rubygems.org/gems/faraday) gem under the hood to make the HTTP requests. The following example shows a typical request, without a custom `http_client`:
|
|
9
|
+
|
|
10
|
+
```rb
|
|
11
|
+
@client = Twilio::REST::Client.new(account_sid, auth_token)
|
|
12
|
+
|
|
13
|
+
message = @client.messages
|
|
14
|
+
.create(
|
|
15
|
+
to: "+15558675310",
|
|
16
|
+
body: "Hey there!",
|
|
17
|
+
from: "+15017122661",
|
|
18
|
+
)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Out of the box, the helper library is creating a default `Twilio::Http::Client` for you, using the Twilio credentials you provide. However, you can create your own `Twilio::Http::Client`, and pass it to any Twilio REST API resource action you want.
|
|
22
|
+
|
|
23
|
+
Here’s an example of sending an SMS message with a custom client:
|
|
24
|
+
|
|
25
|
+
```rb
|
|
26
|
+
# Download the helper library from https://www.twilio.com/docs/ruby/install
|
|
27
|
+
require "rubygems"
|
|
28
|
+
require "twilio-ruby"
|
|
29
|
+
require "dotenv/load"
|
|
30
|
+
|
|
31
|
+
# Custom HTTP Client
|
|
32
|
+
require_relative "MyRequestClass"
|
|
33
|
+
|
|
34
|
+
# Your Account Sid and Auth Token from twilio.com/console
|
|
35
|
+
account_sid = ENV["ACCOUNT_SID"]
|
|
36
|
+
auth_token = ENV["AUTH_TOKEN"]
|
|
37
|
+
proxy_address = ENV["PROXY_ADDRESS"]
|
|
38
|
+
proxy_protocol = ENV["PROXY_PROTOCOL"]
|
|
39
|
+
proxy_port = ENV["PROXY_PORT"]
|
|
40
|
+
|
|
41
|
+
my_request_client = MyRequestClass.new(proxy_protocol, proxy_address, proxy_port)
|
|
42
|
+
|
|
43
|
+
@client = Twilio::REST::Client.new(account_sid, auth_token,
|
|
44
|
+
nil, nil, my_request_client)
|
|
45
|
+
|
|
46
|
+
message = @client.messages
|
|
47
|
+
.create(
|
|
48
|
+
to: "+593978613041",
|
|
49
|
+
body: "RB This is the ship that made the Kesssssel Run in fourteen parsecs?",
|
|
50
|
+
from: "+13212855389",
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
puts "Message SID: #{message.sid}"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Create your custom TwilioRestClient
|
|
57
|
+
|
|
58
|
+
When you take a closer look at the constructor for `Twilio::Http::Client`, you see that this class provides it to the Twilio helper library to make the necessary HTTP requests.
|
|
59
|
+
|
|
60
|
+
## Call Twilio through the proxy server
|
|
61
|
+
|
|
62
|
+
Now that we understand how all the components fit together, we can create our own `http_client` that can connect through a proxy server. To make this reusable, here’s a class that you can use to create this `http_client` whenever you need one.
|
|
63
|
+
|
|
64
|
+
```rb
|
|
65
|
+
class MyRequestClass
|
|
66
|
+
attr_accessor :adapter
|
|
67
|
+
attr_reader :timeout, :last_response, :last_request
|
|
68
|
+
|
|
69
|
+
def initialize(proxy_prot = nil, proxy_addr = nil, proxy_port = nil, timeout: nil)
|
|
70
|
+
@proxy_prot = proxy_prot
|
|
71
|
+
@proxy_addr = proxy_addr
|
|
72
|
+
@proxy_port = proxy_port
|
|
73
|
+
@timeout = timeout
|
|
74
|
+
@adapter = Faraday.default_adapter
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def _request(request)
|
|
78
|
+
@connection = Faraday.new(url: request.host + ":" + request.port.to_s, ssl: { verify: true }) do |f|
|
|
79
|
+
f.options.params_encoder = Faraday::FlatParamsEncoder
|
|
80
|
+
f.request :url_encoded
|
|
81
|
+
f.adapter @adapter
|
|
82
|
+
f.headers = request.headers
|
|
83
|
+
f.basic_auth(request.auth[0], request.auth[1])
|
|
84
|
+
if @proxy_addr
|
|
85
|
+
f.proxy = "#{@proxy_prot}://#{@proxy_addr}:#{@proxy_port}"
|
|
86
|
+
end
|
|
87
|
+
f.options.open_timeout = request.timeout || @timeout
|
|
88
|
+
f.options.timeout = request.timeout || @timeout
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
@last_request = request
|
|
92
|
+
@last_response = nil
|
|
93
|
+
response = @connection.send(request.method.downcase.to_sym,
|
|
94
|
+
request.url,
|
|
95
|
+
request.method == "GET" ? request.params : request.data)
|
|
96
|
+
|
|
97
|
+
if response.body && !response.body.empty?
|
|
98
|
+
object = response.body
|
|
99
|
+
elsif response.status == 400
|
|
100
|
+
object = { message: "Bad request", code: 400 }.to_json
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
twilio_response = Twilio::Response.new(response.status, object, headers: response.headers)
|
|
104
|
+
@last_response = twilio_response
|
|
105
|
+
|
|
106
|
+
twilio_response
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def request(host, port, method, url, params = {}, data = {}, headers = {}, auth = nil, timeout = nil)
|
|
110
|
+
request = Twilio::Request.new(host, port, method, url, params, data, headers, auth, timeout)
|
|
111
|
+
_request(request)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
In this example, we are using some environment variables loaded at the program startup to retrieve various configuration settings:
|
|
117
|
+
|
|
118
|
+
- Your Twilio Account Sid and Auth Token ([found here, in the Twilio console](https://console.twilio.com))
|
|
119
|
+
- A proxy address in the form of `http://127.0.0.1:8888`
|
|
120
|
+
|
|
121
|
+
These settings are located in a file like `.env` like so:
|
|
122
|
+
|
|
123
|
+
```env
|
|
124
|
+
ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
125
|
+
AUTH_TOKEN= your_auth_token
|
|
126
|
+
|
|
127
|
+
HTTPS_PROXY=https://127.0.0.1:8888
|
|
128
|
+
HTTP_PROXY=http://127.0.0.1:8888
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Here’s the full console program that sends a text message and shows how it all can work together. It loads the `.env` file.
|
|
132
|
+
|
|
133
|
+
```rb
|
|
134
|
+
# Download the helper library from https://www.twilio.com/docs/ruby/install
|
|
135
|
+
require "rubygems"
|
|
136
|
+
require "twilio-ruby"
|
|
137
|
+
require "dotenv/load"
|
|
138
|
+
|
|
139
|
+
# Custom HTTP Client
|
|
140
|
+
require_relative "MyRequestClass"
|
|
141
|
+
|
|
142
|
+
# Your Account Sid and Auth Token from twilio.com/console
|
|
143
|
+
account_sid = ENV["ACCOUNT_SID"]
|
|
144
|
+
auth_token = ENV["AUTH_TOKEN"]
|
|
145
|
+
proxy_address = ENV["PROXY_ADDRESS"]
|
|
146
|
+
proxy_protocol = ENV["PROXY_PROTOCOL"]
|
|
147
|
+
proxy_port = ENV["PROXY_PORT"]
|
|
148
|
+
|
|
149
|
+
my_request_client = MyRequestClass.new(proxy_protocol, proxy_address, proxy_port)
|
|
150
|
+
|
|
151
|
+
@client = Twilio::REST::Client.new(account_sid, auth_token,
|
|
152
|
+
nil, nil, my_request_client)
|
|
153
|
+
|
|
154
|
+
message = @client.messages
|
|
155
|
+
.create(
|
|
156
|
+
to: "+593978613041",
|
|
157
|
+
body: "RB This is the ship that made the Kesssssel Run in fourteen parsecs?",
|
|
158
|
+
from: "+13212855389",
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
puts "Message SID: #{message.sid}"
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## What else can this technique be used for?
|
|
165
|
+
|
|
166
|
+
Now that you know how to inject your own `http_client` into the Twilio API request pipeline, you could use this technique to add custom HTTP headers and authorization to the requests (perhaps as required by an upstream proxy server).
|
|
167
|
+
|
|
168
|
+
You could also implement your own `http_client` to mock the Twilio API responses so your unit and integration tests can run quickly without the need to make a connection to Twilio. In fact, there’s already an example online showing [how to do exactly that with Node.js and Prism](https://www.twilio.com/docs/openapi/mock-api-generation-with-twilio-openapi-spec).
|
|
169
|
+
|
|
170
|
+
We can’t wait to see what you build!
|
|
@@ -43,8 +43,10 @@ module Twilio
|
|
|
43
43
|
# the address. Can be: `true` or `false` and the default is `true`. If empty or
|
|
44
44
|
# `true`, we will correct the address you provide if necessary. If `false`, we
|
|
45
45
|
# won't alter the address you provide.
|
|
46
|
+
# @param [String] street_secondary The additional number and street address of the
|
|
47
|
+
# address.
|
|
46
48
|
# @return [AddressInstance] Created AddressInstance
|
|
47
|
-
def create(customer_name: nil, street: nil, city: nil, region: nil, postal_code: nil, iso_country: nil, friendly_name: :unset, emergency_enabled: :unset, auto_correct_address: :unset)
|
|
49
|
+
def create(customer_name: nil, street: nil, city: nil, region: nil, postal_code: nil, iso_country: nil, friendly_name: :unset, emergency_enabled: :unset, auto_correct_address: :unset, street_secondary: :unset)
|
|
48
50
|
data = Twilio::Values.of({
|
|
49
51
|
'CustomerName' => customer_name,
|
|
50
52
|
'Street' => street,
|
|
@@ -55,6 +57,7 @@ module Twilio
|
|
|
55
57
|
'FriendlyName' => friendly_name,
|
|
56
58
|
'EmergencyEnabled' => emergency_enabled,
|
|
57
59
|
'AutoCorrectAddress' => auto_correct_address,
|
|
60
|
+
'StreetSecondary' => street_secondary,
|
|
58
61
|
})
|
|
59
62
|
|
|
60
63
|
payload = @version.create('POST', @uri, data: data)
|
|
@@ -262,8 +265,10 @@ module Twilio
|
|
|
262
265
|
# the address. Can be: `true` or `false` and the default is `true`. If empty or
|
|
263
266
|
# `true`, we will correct the address you provide if necessary. If `false`, we
|
|
264
267
|
# won't alter the address you provide.
|
|
268
|
+
# @param [String] street_secondary The additional number and street address of the
|
|
269
|
+
# address.
|
|
265
270
|
# @return [AddressInstance] Updated AddressInstance
|
|
266
|
-
def update(friendly_name: :unset, customer_name: :unset, street: :unset, city: :unset, region: :unset, postal_code: :unset, emergency_enabled: :unset, auto_correct_address: :unset)
|
|
271
|
+
def update(friendly_name: :unset, customer_name: :unset, street: :unset, city: :unset, region: :unset, postal_code: :unset, emergency_enabled: :unset, auto_correct_address: :unset, street_secondary: :unset)
|
|
267
272
|
data = Twilio::Values.of({
|
|
268
273
|
'FriendlyName' => friendly_name,
|
|
269
274
|
'CustomerName' => customer_name,
|
|
@@ -273,6 +278,7 @@ module Twilio
|
|
|
273
278
|
'PostalCode' => postal_code,
|
|
274
279
|
'EmergencyEnabled' => emergency_enabled,
|
|
275
280
|
'AutoCorrectAddress' => auto_correct_address,
|
|
281
|
+
'StreetSecondary' => street_secondary,
|
|
276
282
|
})
|
|
277
283
|
|
|
278
284
|
payload = @version.update('POST', @uri, data: data)
|
|
@@ -342,6 +348,7 @@ module Twilio
|
|
|
342
348
|
'emergency_enabled' => payload['emergency_enabled'],
|
|
343
349
|
'validated' => payload['validated'],
|
|
344
350
|
'verified' => payload['verified'],
|
|
351
|
+
'street_secondary' => payload['street_secondary'],
|
|
345
352
|
}
|
|
346
353
|
|
|
347
354
|
# Context
|
|
@@ -450,6 +457,12 @@ module Twilio
|
|
|
450
457
|
@properties['verified']
|
|
451
458
|
end
|
|
452
459
|
|
|
460
|
+
##
|
|
461
|
+
# @return [String] The additional number and street address of the address
|
|
462
|
+
def street_secondary
|
|
463
|
+
@properties['street_secondary']
|
|
464
|
+
end
|
|
465
|
+
|
|
453
466
|
##
|
|
454
467
|
# Delete the AddressInstance
|
|
455
468
|
# @return [Boolean] true if delete succeeds, false otherwise
|
|
@@ -479,8 +492,10 @@ module Twilio
|
|
|
479
492
|
# the address. Can be: `true` or `false` and the default is `true`. If empty or
|
|
480
493
|
# `true`, we will correct the address you provide if necessary. If `false`, we
|
|
481
494
|
# won't alter the address you provide.
|
|
495
|
+
# @param [String] street_secondary The additional number and street address of the
|
|
496
|
+
# address.
|
|
482
497
|
# @return [AddressInstance] Updated AddressInstance
|
|
483
|
-
def update(friendly_name: :unset, customer_name: :unset, street: :unset, city: :unset, region: :unset, postal_code: :unset, emergency_enabled: :unset, auto_correct_address: :unset)
|
|
498
|
+
def update(friendly_name: :unset, customer_name: :unset, street: :unset, city: :unset, region: :unset, postal_code: :unset, emergency_enabled: :unset, auto_correct_address: :unset, street_secondary: :unset)
|
|
484
499
|
context.update(
|
|
485
500
|
friendly_name: friendly_name,
|
|
486
501
|
customer_name: customer_name,
|
|
@@ -490,6 +505,7 @@ module Twilio
|
|
|
490
505
|
postal_code: postal_code,
|
|
491
506
|
emergency_enabled: emergency_enabled,
|
|
492
507
|
auto_correct_address: auto_correct_address,
|
|
508
|
+
street_secondary: street_secondary,
|
|
493
509
|
)
|
|
494
510
|
end
|
|
495
511
|
|
|
@@ -61,8 +61,11 @@ module Twilio
|
|
|
61
61
|
# method to send message status information to your application.
|
|
62
62
|
# @param [String] friendly_name A descriptive string that you create to describe
|
|
63
63
|
# the new application. It can be up to 64 characters long.
|
|
64
|
+
# @param [Boolean] public_application_connect_enabled Whether to allow other
|
|
65
|
+
# Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or
|
|
66
|
+
# `false`.
|
|
64
67
|
# @return [ApplicationInstance] Created ApplicationInstance
|
|
65
|
-
def create(api_version: :unset, voice_url: :unset, voice_method: :unset, voice_fallback_url: :unset, voice_fallback_method: :unset, status_callback: :unset, status_callback_method: :unset, voice_caller_id_lookup: :unset, sms_url: :unset, sms_method: :unset, sms_fallback_url: :unset, sms_fallback_method: :unset, sms_status_callback: :unset, message_status_callback: :unset, friendly_name: :unset)
|
|
68
|
+
def create(api_version: :unset, voice_url: :unset, voice_method: :unset, voice_fallback_url: :unset, voice_fallback_method: :unset, status_callback: :unset, status_callback_method: :unset, voice_caller_id_lookup: :unset, sms_url: :unset, sms_method: :unset, sms_fallback_url: :unset, sms_fallback_method: :unset, sms_status_callback: :unset, message_status_callback: :unset, friendly_name: :unset, public_application_connect_enabled: :unset)
|
|
66
69
|
data = Twilio::Values.of({
|
|
67
70
|
'ApiVersion' => api_version,
|
|
68
71
|
'VoiceUrl' => voice_url,
|
|
@@ -79,6 +82,7 @@ module Twilio
|
|
|
79
82
|
'SmsStatusCallback' => sms_status_callback,
|
|
80
83
|
'MessageStatusCallback' => message_status_callback,
|
|
81
84
|
'FriendlyName' => friendly_name,
|
|
85
|
+
'PublicApplicationConnectEnabled' => public_application_connect_enabled,
|
|
82
86
|
})
|
|
83
87
|
|
|
84
88
|
payload = @version.create('POST', @uri, data: data)
|
|
@@ -283,8 +287,11 @@ module Twilio
|
|
|
283
287
|
# sent by the application. Deprecated, included for backwards compatibility.
|
|
284
288
|
# @param [String] message_status_callback The URL we should call using a POST
|
|
285
289
|
# method to send message status information to your application.
|
|
290
|
+
# @param [Boolean] public_application_connect_enabled Whether to allow other
|
|
291
|
+
# Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or
|
|
292
|
+
# `false`.
|
|
286
293
|
# @return [ApplicationInstance] Updated ApplicationInstance
|
|
287
|
-
def update(friendly_name: :unset, api_version: :unset, voice_url: :unset, voice_method: :unset, voice_fallback_url: :unset, voice_fallback_method: :unset, status_callback: :unset, status_callback_method: :unset, voice_caller_id_lookup: :unset, sms_url: :unset, sms_method: :unset, sms_fallback_url: :unset, sms_fallback_method: :unset, sms_status_callback: :unset, message_status_callback: :unset)
|
|
294
|
+
def update(friendly_name: :unset, api_version: :unset, voice_url: :unset, voice_method: :unset, voice_fallback_url: :unset, voice_fallback_method: :unset, status_callback: :unset, status_callback_method: :unset, voice_caller_id_lookup: :unset, sms_url: :unset, sms_method: :unset, sms_fallback_url: :unset, sms_fallback_method: :unset, sms_status_callback: :unset, message_status_callback: :unset, public_application_connect_enabled: :unset)
|
|
288
295
|
data = Twilio::Values.of({
|
|
289
296
|
'FriendlyName' => friendly_name,
|
|
290
297
|
'ApiVersion' => api_version,
|
|
@@ -301,6 +308,7 @@ module Twilio
|
|
|
301
308
|
'SmsFallbackMethod' => sms_fallback_method,
|
|
302
309
|
'SmsStatusCallback' => sms_status_callback,
|
|
303
310
|
'MessageStatusCallback' => message_status_callback,
|
|
311
|
+
'PublicApplicationConnectEnabled' => public_application_connect_enabled,
|
|
304
312
|
})
|
|
305
313
|
|
|
306
314
|
payload = @version.update('POST', @uri, data: data)
|
|
@@ -364,6 +372,7 @@ module Twilio
|
|
|
364
372
|
'voice_fallback_url' => payload['voice_fallback_url'],
|
|
365
373
|
'voice_method' => payload['voice_method'],
|
|
366
374
|
'voice_url' => payload['voice_url'],
|
|
375
|
+
'public_application_connect_enabled' => payload['public_application_connect_enabled'],
|
|
367
376
|
}
|
|
368
377
|
|
|
369
378
|
# Context
|
|
@@ -502,6 +511,12 @@ module Twilio
|
|
|
502
511
|
@properties['voice_url']
|
|
503
512
|
end
|
|
504
513
|
|
|
514
|
+
##
|
|
515
|
+
# @return [Boolean] Whether to allow other Twilio accounts to dial this application
|
|
516
|
+
def public_application_connect_enabled
|
|
517
|
+
@properties['public_application_connect_enabled']
|
|
518
|
+
end
|
|
519
|
+
|
|
505
520
|
##
|
|
506
521
|
# Delete the ApplicationInstance
|
|
507
522
|
# @return [Boolean] true if delete succeeds, false otherwise
|
|
@@ -551,8 +566,11 @@ module Twilio
|
|
|
551
566
|
# sent by the application. Deprecated, included for backwards compatibility.
|
|
552
567
|
# @param [String] message_status_callback The URL we should call using a POST
|
|
553
568
|
# method to send message status information to your application.
|
|
569
|
+
# @param [Boolean] public_application_connect_enabled Whether to allow other
|
|
570
|
+
# Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or
|
|
571
|
+
# `false`.
|
|
554
572
|
# @return [ApplicationInstance] Updated ApplicationInstance
|
|
555
|
-
def update(friendly_name: :unset, api_version: :unset, voice_url: :unset, voice_method: :unset, voice_fallback_url: :unset, voice_fallback_method: :unset, status_callback: :unset, status_callback_method: :unset, voice_caller_id_lookup: :unset, sms_url: :unset, sms_method: :unset, sms_fallback_url: :unset, sms_fallback_method: :unset, sms_status_callback: :unset, message_status_callback: :unset)
|
|
573
|
+
def update(friendly_name: :unset, api_version: :unset, voice_url: :unset, voice_method: :unset, voice_fallback_url: :unset, voice_fallback_method: :unset, status_callback: :unset, status_callback_method: :unset, voice_caller_id_lookup: :unset, sms_url: :unset, sms_method: :unset, sms_fallback_url: :unset, sms_fallback_method: :unset, sms_status_callback: :unset, message_status_callback: :unset, public_application_connect_enabled: :unset)
|
|
556
574
|
context.update(
|
|
557
575
|
friendly_name: friendly_name,
|
|
558
576
|
api_version: api_version,
|
|
@@ -569,6 +587,7 @@ module Twilio
|
|
|
569
587
|
sms_fallback_method: sms_fallback_method,
|
|
570
588
|
sms_status_callback: sms_status_callback,
|
|
571
589
|
message_status_callback: message_status_callback,
|
|
590
|
+
public_application_connect_enabled: public_application_connect_enabled,
|
|
572
591
|
)
|
|
573
592
|
end
|
|
574
593
|
|
|
@@ -391,8 +391,8 @@ module Twilio
|
|
|
391
391
|
'lata' => payload['lata'],
|
|
392
392
|
'locality' => payload['locality'],
|
|
393
393
|
'rate_center' => payload['rate_center'],
|
|
394
|
-
'latitude' => payload['latitude'].to_f,
|
|
395
|
-
'longitude' => payload['longitude'].to_f,
|
|
394
|
+
'latitude' => payload['latitude'] == nil ? payload['latitude'] : payload['latitude'].to_f,
|
|
395
|
+
'longitude' => payload['longitude'] == nil ? payload['longitude'] : payload['longitude'].to_f,
|
|
396
396
|
'region' => payload['region'],
|
|
397
397
|
'postal_code' => payload['postal_code'],
|
|
398
398
|
'iso_country' => payload['iso_country'],
|
|
@@ -391,8 +391,8 @@ module Twilio
|
|
|
391
391
|
'lata' => payload['lata'],
|
|
392
392
|
'locality' => payload['locality'],
|
|
393
393
|
'rate_center' => payload['rate_center'],
|
|
394
|
-
'latitude' => payload['latitude'].to_f,
|
|
395
|
-
'longitude' => payload['longitude'].to_f,
|
|
394
|
+
'latitude' => payload['latitude'] == nil ? payload['latitude'] : payload['latitude'].to_f,
|
|
395
|
+
'longitude' => payload['longitude'] == nil ? payload['longitude'] : payload['longitude'].to_f,
|
|
396
396
|
'region' => payload['region'],
|
|
397
397
|
'postal_code' => payload['postal_code'],
|
|
398
398
|
'iso_country' => payload['iso_country'],
|
|
@@ -391,8 +391,8 @@ module Twilio
|
|
|
391
391
|
'lata' => payload['lata'],
|
|
392
392
|
'locality' => payload['locality'],
|
|
393
393
|
'rate_center' => payload['rate_center'],
|
|
394
|
-
'latitude' => payload['latitude'].to_f,
|
|
395
|
-
'longitude' => payload['longitude'].to_f,
|
|
394
|
+
'latitude' => payload['latitude'] == nil ? payload['latitude'] : payload['latitude'].to_f,
|
|
395
|
+
'longitude' => payload['longitude'] == nil ? payload['longitude'] : payload['longitude'].to_f,
|
|
396
396
|
'region' => payload['region'],
|
|
397
397
|
'postal_code' => payload['postal_code'],
|
|
398
398
|
'iso_country' => payload['iso_country'],
|
|
@@ -391,8 +391,8 @@ module Twilio
|
|
|
391
391
|
'lata' => payload['lata'],
|
|
392
392
|
'locality' => payload['locality'],
|
|
393
393
|
'rate_center' => payload['rate_center'],
|
|
394
|
-
'latitude' => payload['latitude'].to_f,
|
|
395
|
-
'longitude' => payload['longitude'].to_f,
|
|
394
|
+
'latitude' => payload['latitude'] == nil ? payload['latitude'] : payload['latitude'].to_f,
|
|
395
|
+
'longitude' => payload['longitude'] == nil ? payload['longitude'] : payload['longitude'].to_f,
|
|
396
396
|
'region' => payload['region'],
|
|
397
397
|
'postal_code' => payload['postal_code'],
|
|
398
398
|
'iso_country' => payload['iso_country'],
|
|
@@ -391,8 +391,8 @@ module Twilio
|
|
|
391
391
|
'lata' => payload['lata'],
|
|
392
392
|
'locality' => payload['locality'],
|
|
393
393
|
'rate_center' => payload['rate_center'],
|
|
394
|
-
'latitude' => payload['latitude'].to_f,
|
|
395
|
-
'longitude' => payload['longitude'].to_f,
|
|
394
|
+
'latitude' => payload['latitude'] == nil ? payload['latitude'] : payload['latitude'].to_f,
|
|
395
|
+
'longitude' => payload['longitude'] == nil ? payload['longitude'] : payload['longitude'].to_f,
|
|
396
396
|
'region' => payload['region'],
|
|
397
397
|
'postal_code' => payload['postal_code'],
|
|
398
398
|
'iso_country' => payload['iso_country'],
|
|
@@ -391,8 +391,8 @@ module Twilio
|
|
|
391
391
|
'lata' => payload['lata'],
|
|
392
392
|
'locality' => payload['locality'],
|
|
393
393
|
'rate_center' => payload['rate_center'],
|
|
394
|
-
'latitude' => payload['latitude'].to_f,
|
|
395
|
-
'longitude' => payload['longitude'].to_f,
|
|
394
|
+
'latitude' => payload['latitude'] == nil ? payload['latitude'] : payload['latitude'].to_f,
|
|
395
|
+
'longitude' => payload['longitude'] == nil ? payload['longitude'] : payload['longitude'].to_f,
|
|
396
396
|
'region' => payload['region'],
|
|
397
397
|
'postal_code' => payload['postal_code'],
|
|
398
398
|
'iso_country' => payload['iso_country'],
|
|
@@ -391,8 +391,8 @@ module Twilio
|
|
|
391
391
|
'lata' => payload['lata'],
|
|
392
392
|
'locality' => payload['locality'],
|
|
393
393
|
'rate_center' => payload['rate_center'],
|
|
394
|
-
'latitude' => payload['latitude'].to_f,
|
|
395
|
-
'longitude' => payload['longitude'].to_f,
|
|
394
|
+
'latitude' => payload['latitude'] == nil ? payload['latitude'] : payload['latitude'].to_f,
|
|
395
|
+
'longitude' => payload['longitude'] == nil ? payload['longitude'] : payload['longitude'].to_f,
|
|
396
396
|
'region' => payload['region'],
|
|
397
397
|
'postal_code' => payload['postal_code'],
|
|
398
398
|
'iso_country' => payload['iso_country'],
|
|
@@ -188,7 +188,7 @@ module Twilio
|
|
|
188
188
|
'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
|
|
189
189
|
'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
|
|
190
190
|
'issues' => payload['issues'],
|
|
191
|
-
'quality_score' => payload['quality_score'].to_i,
|
|
191
|
+
'quality_score' => payload['quality_score'] == nil ? payload['quality_score'] : payload['quality_score'].to_i,
|
|
192
192
|
'sid' => payload['sid'],
|
|
193
193
|
}
|
|
194
194
|
|
|
@@ -163,16 +163,16 @@ module Twilio
|
|
|
163
163
|
# Marshaled Properties
|
|
164
164
|
@properties = {
|
|
165
165
|
'account_sid' => payload['account_sid'],
|
|
166
|
-
'call_count' => payload['call_count'].to_i,
|
|
167
|
-
'call_feedback_count' => payload['call_feedback_count'].to_i,
|
|
166
|
+
'call_count' => payload['call_count'] == nil ? payload['call_count'] : payload['call_count'].to_i,
|
|
167
|
+
'call_feedback_count' => payload['call_feedback_count'] == nil ? payload['call_feedback_count'] : payload['call_feedback_count'].to_i,
|
|
168
168
|
'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
|
|
169
169
|
'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
|
|
170
170
|
'end_date' => Twilio.deserialize_iso8601_date(payload['end_date']),
|
|
171
171
|
'include_subaccounts' => payload['include_subaccounts'],
|
|
172
172
|
'issues' => payload['issues'],
|
|
173
|
-
'quality_score_average' => payload['quality_score_average'].to_f,
|
|
174
|
-
'quality_score_median' => payload['quality_score_median'].to_f,
|
|
175
|
-
'quality_score_standard_deviation' => payload['quality_score_standard_deviation'].to_f,
|
|
173
|
+
'quality_score_average' => payload['quality_score_average'] == nil ? payload['quality_score_average'] : payload['quality_score_average'].to_f,
|
|
174
|
+
'quality_score_median' => payload['quality_score_median'] == nil ? payload['quality_score_median'] : payload['quality_score_median'].to_f,
|
|
175
|
+
'quality_score_standard_deviation' => payload['quality_score_standard_deviation'] == nil ? payload['quality_score_standard_deviation'] : payload['quality_score_standard_deviation'].to_f,
|
|
176
176
|
'sid' => payload['sid'],
|
|
177
177
|
'start_date' => Twilio.deserialize_iso8601_date(payload['start_date']),
|
|
178
178
|
'status' => payload['status'],
|
|
@@ -332,12 +332,12 @@ module Twilio
|
|
|
332
332
|
'start_time' => Twilio.deserialize_rfc2822(payload['start_time']),
|
|
333
333
|
'duration' => payload['duration'],
|
|
334
334
|
'sid' => payload['sid'],
|
|
335
|
-
'price' => payload['price'].to_f,
|
|
335
|
+
'price' => payload['price'] == nil ? payload['price'] : payload['price'].to_f,
|
|
336
336
|
'uri' => payload['uri'],
|
|
337
337
|
'encryption_details' => payload['encryption_details'],
|
|
338
338
|
'price_unit' => payload['price_unit'],
|
|
339
339
|
'status' => payload['status'],
|
|
340
|
-
'channels' => payload['channels'].to_i,
|
|
340
|
+
'channels' => payload['channels'] == nil ? payload['channels'] : payload['channels'].to_i,
|
|
341
341
|
'source' => payload['source'],
|
|
342
342
|
'error_code' => payload['error_code'] == nil ? payload['error_code'] : payload['error_code'].to_i,
|
|
343
343
|
'track' => payload['track'],
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
##
|
|
2
|
+
# This code was generated by
|
|
3
|
+
# \ / _ _ _| _ _
|
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
|
5
|
+
# / /
|
|
6
|
+
#
|
|
7
|
+
# frozen_string_literal: true
|
|
8
|
+
|
|
9
|
+
module Twilio
|
|
10
|
+
module REST
|
|
11
|
+
class Api < Domain
|
|
12
|
+
class V2010 < Version
|
|
13
|
+
class AccountContext < InstanceContext
|
|
14
|
+
class CallContext < InstanceContext
|
|
15
|
+
class UserDefinedMessageList < ListResource
|
|
16
|
+
##
|
|
17
|
+
# Initialize the UserDefinedMessageList
|
|
18
|
+
# @param [Version] version Version that contains the resource
|
|
19
|
+
# @param [String] account_sid The SID of the
|
|
20
|
+
# {Account}[https://www.twilio.com/docs/iam/api/account] that created User Defined
|
|
21
|
+
# Message.
|
|
22
|
+
# @param [String] call_sid The SID of the
|
|
23
|
+
# {Call}[https://www.twilio.com/docs/voice/api/call-resource] the User Defined
|
|
24
|
+
# Message is associated with.
|
|
25
|
+
# @return [UserDefinedMessageList] UserDefinedMessageList
|
|
26
|
+
def initialize(version, account_sid: nil, call_sid: nil)
|
|
27
|
+
super(version)
|
|
28
|
+
|
|
29
|
+
# Path Solution
|
|
30
|
+
@solution = {account_sid: account_sid, call_sid: call_sid}
|
|
31
|
+
@uri = "/Accounts/#{@solution[:account_sid]}/Calls/#{@solution[:call_sid]}/UserDefinedMessages.json"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# Create the UserDefinedMessageInstance
|
|
36
|
+
# @param [String] content The User Defined Message in the form of URL-encoded JSON
|
|
37
|
+
# string.
|
|
38
|
+
# @param [String] idempotency_key A unique string value to identify API call. This
|
|
39
|
+
# should be a unique string value per API call and can be a randomly generated.
|
|
40
|
+
# @return [UserDefinedMessageInstance] Created UserDefinedMessageInstance
|
|
41
|
+
def create(content: nil, idempotency_key: :unset)
|
|
42
|
+
data = Twilio::Values.of({'Content' => content, 'IdempotencyKey' => idempotency_key, })
|
|
43
|
+
|
|
44
|
+
payload = @version.create('POST', @uri, data: data)
|
|
45
|
+
|
|
46
|
+
UserDefinedMessageInstance.new(
|
|
47
|
+
@version,
|
|
48
|
+
payload,
|
|
49
|
+
account_sid: @solution[:account_sid],
|
|
50
|
+
call_sid: @solution[:call_sid],
|
|
51
|
+
)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
##
|
|
55
|
+
# Provide a user friendly representation
|
|
56
|
+
def to_s
|
|
57
|
+
'#<Twilio.Api.V2010.UserDefinedMessageList>'
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
class UserDefinedMessagePage < Page
|
|
62
|
+
##
|
|
63
|
+
# Initialize the UserDefinedMessagePage
|
|
64
|
+
# @param [Version] version Version that contains the resource
|
|
65
|
+
# @param [Response] response Response from the API
|
|
66
|
+
# @param [Hash] solution Path solution for the resource
|
|
67
|
+
# @return [UserDefinedMessagePage] UserDefinedMessagePage
|
|
68
|
+
def initialize(version, response, solution)
|
|
69
|
+
super(version, response)
|
|
70
|
+
|
|
71
|
+
# Path Solution
|
|
72
|
+
@solution = solution
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
##
|
|
76
|
+
# Build an instance of UserDefinedMessageInstance
|
|
77
|
+
# @param [Hash] payload Payload response from the API
|
|
78
|
+
# @return [UserDefinedMessageInstance] UserDefinedMessageInstance
|
|
79
|
+
def get_instance(payload)
|
|
80
|
+
UserDefinedMessageInstance.new(
|
|
81
|
+
@version,
|
|
82
|
+
payload,
|
|
83
|
+
account_sid: @solution[:account_sid],
|
|
84
|
+
call_sid: @solution[:call_sid],
|
|
85
|
+
)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
##
|
|
89
|
+
# Provide a user friendly representation
|
|
90
|
+
def to_s
|
|
91
|
+
'<Twilio.Api.V2010.UserDefinedMessagePage>'
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class UserDefinedMessageInstance < InstanceResource
|
|
96
|
+
##
|
|
97
|
+
# Initialize the UserDefinedMessageInstance
|
|
98
|
+
# @param [Version] version Version that contains the resource
|
|
99
|
+
# @param [Hash] payload payload that contains response from Twilio
|
|
100
|
+
# @param [String] account_sid The SID of the
|
|
101
|
+
# {Account}[https://www.twilio.com/docs/iam/api/account] that created User Defined
|
|
102
|
+
# Message.
|
|
103
|
+
# @param [String] call_sid The SID of the
|
|
104
|
+
# {Call}[https://www.twilio.com/docs/voice/api/call-resource] the User Defined
|
|
105
|
+
# Message is associated with.
|
|
106
|
+
# @return [UserDefinedMessageInstance] UserDefinedMessageInstance
|
|
107
|
+
def initialize(version, payload, account_sid: nil, call_sid: nil)
|
|
108
|
+
super(version)
|
|
109
|
+
|
|
110
|
+
# Marshaled Properties
|
|
111
|
+
@properties = {
|
|
112
|
+
'account_sid' => payload['account_sid'],
|
|
113
|
+
'call_sid' => payload['call_sid'],
|
|
114
|
+
'sid' => payload['sid'],
|
|
115
|
+
'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
|
|
116
|
+
}
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
##
|
|
120
|
+
# @return [String] Account SID.
|
|
121
|
+
def account_sid
|
|
122
|
+
@properties['account_sid']
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
##
|
|
126
|
+
# @return [String] Call SID.
|
|
127
|
+
def call_sid
|
|
128
|
+
@properties['call_sid']
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
##
|
|
132
|
+
# @return [String] User Defined Message SID.
|
|
133
|
+
def sid
|
|
134
|
+
@properties['sid']
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
##
|
|
138
|
+
# @return [Time] The date this User Defined Message was created.
|
|
139
|
+
def date_created
|
|
140
|
+
@properties['date_created']
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
##
|
|
144
|
+
# Provide a user friendly representation
|
|
145
|
+
def to_s
|
|
146
|
+
"<Twilio.Api.V2010.UserDefinedMessageInstance>"
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
##
|
|
150
|
+
# Provide a detailed, user friendly representation
|
|
151
|
+
def inspect
|
|
152
|
+
"<Twilio.Api.V2010.UserDefinedMessageInstance>"
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|