twilio-ruby 5.33.0 → 5.36.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -0
  3. data/.rubocop_todo.yml +5 -26
  4. data/.travis.yml +9 -1
  5. data/CHANGES.md +110 -0
  6. data/README.md +17 -2
  7. data/lib/twilio-ruby.rb +4 -12
  8. data/lib/twilio-ruby/framework/error.rb +3 -3
  9. data/lib/twilio-ruby/jwt/jwt.rb +6 -0
  10. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +90 -90
  11. data/lib/twilio-ruby/rest/api/v2010/account/conference.rb +14 -0
  12. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +75 -72
  13. data/lib/twilio-ruby/rest/api/v2010/account/queue.rb +29 -29
  14. data/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb +38 -3
  15. data/lib/twilio-ruby/rest/autopilot.rb +6 -0
  16. data/lib/twilio-ruby/rest/autopilot/v1.rb +7 -0
  17. data/lib/twilio-ruby/rest/autopilot/v1/restore_assistant.rb +198 -0
  18. data/lib/twilio-ruby/rest/client.rb +35 -8
  19. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +19 -3
  20. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +27 -4
  21. data/lib/twilio-ruby/rest/flex_api/v1/channel.rb +2 -1
  22. data/lib/twilio-ruby/rest/flex_api/v1/configuration.rb +7 -0
  23. data/lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb +20 -11
  24. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle.rb +26 -0
  25. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/evaluation.rb +324 -0
  26. data/lib/twilio-ruby/rest/preview/trusted_comms/business.rb +26 -0
  27. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand.rb +239 -0
  28. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand/branded_channel.rb +266 -0
  29. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand/branded_channel/channel.rb +197 -0
  30. data/lib/twilio-ruby/rest/serverless/v1/service/environment/log.rb +7 -0
  31. data/lib/twilio-ruby/rest/studio.rb +2 -2
  32. data/lib/twilio-ruby/rest/studio/v1/flow/execution.rb +26 -0
  33. data/lib/twilio-ruby/rest/studio/v2.rb +3 -3
  34. data/lib/twilio-ruby/rest/studio/v2/flow.rb +7 -0
  35. data/lib/twilio-ruby/rest/studio/v2/flow/execution.rb +71 -24
  36. data/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_context.rb +12 -11
  37. data/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step.rb +21 -20
  38. data/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step/execution_step_context.rb +18 -15
  39. data/lib/twilio-ruby/rest/supersim.rb +18 -0
  40. data/lib/twilio-ruby/rest/supersim/v1.rb +30 -0
  41. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +53 -10
  42. data/lib/twilio-ruby/rest/supersim/v1/network.rb +315 -0
  43. data/lib/twilio-ruby/rest/supersim/v1/network_access_profile.rb +378 -0
  44. data/lib/twilio-ruby/rest/supersim/v1/network_access_profile/network_access_profile_network.rb +352 -0
  45. data/lib/twilio-ruby/rest/verify.rb +9 -0
  46. data/lib/twilio-ruby/rest/verify/v2.rb +16 -0
  47. data/lib/twilio-ruby/rest/verify/v2/form.rb +197 -0
  48. data/lib/twilio-ruby/rest/verify/v2/service.rb +48 -3
  49. data/lib/twilio-ruby/rest/verify/v2/service/entity.rb +379 -0
  50. data/lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb +500 -0
  51. data/lib/twilio-ruby/rest/verify/v2/service/entity/factor/challenge.rb +494 -0
  52. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +3 -3
  53. data/lib/twilio-ruby/rest/video/v1/composition_settings.rb +8 -12
  54. data/lib/twilio-ruby/rest/video/v1/recording_settings.rb +8 -12
  55. data/lib/twilio-ruby/rest/voice.rb +36 -0
  56. data/lib/twilio-ruby/rest/voice/v1.rb +64 -0
  57. data/lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb +513 -0
  58. data/lib/twilio-ruby/rest/voice/v1/connection_policy.rb +379 -0
  59. data/lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb +458 -0
  60. data/lib/twilio-ruby/rest/voice/v1/ip_record.rb +366 -0
  61. data/lib/twilio-ruby/rest/voice/v1/source_ip_mapping.rb +346 -0
  62. data/lib/twilio-ruby/twiml/twiml.rb +4 -0
  63. data/lib/twilio-ruby/twiml/voice_response.rb +3 -2
  64. data/lib/twilio-ruby/util/configuration.rb +9 -1
  65. data/lib/twilio-ruby/version.rb +1 -1
  66. data/spec/integration/api/v2010/account/call_spec.rb +5 -5
  67. data/spec/integration/api/v2010/account/conference_spec.rb +42 -14
  68. data/spec/integration/api/v2010/account/sip/domain_spec.rb +12 -4
  69. data/spec/integration/api/v2010/account/token_spec.rb +23 -11
  70. data/spec/integration/autopilot/v1/restore_assistant_spec.rb +53 -0
  71. data/spec/integration/bulkexports/v1/export/day_spec.rb +1 -1
  72. data/spec/integration/conversations/v1/conversation/participant_spec.rb +7 -0
  73. data/spec/integration/conversations/v1/conversation_spec.rb +4 -0
  74. data/spec/integration/flex_api/v1/configuration_spec.rb +3 -0
  75. data/spec/integration/numbers/v2/regulatory_compliance/bundle/evaluation_spec.rb +623 -0
  76. data/spec/integration/numbers/v2/regulatory_compliance/bundle_spec.rb +4 -0
  77. data/spec/integration/preview/bulk_exports/export/day_spec.rb +1 -1
  78. data/spec/integration/preview/trusted_comms/business/brand/branded_channel/channel_spec.rb +54 -0
  79. data/spec/integration/preview/trusted_comms/business/brand/branded_channel_spec.rb +52 -0
  80. data/spec/integration/preview/trusted_comms/business/brand_spec.rb +49 -0
  81. data/spec/integration/preview/trusted_comms/business_spec.rb +1 -0
  82. data/spec/integration/serverless/v1/service/asset/asset_version_spec.rb +1 -1
  83. data/spec/integration/serverless/v1/service/build_spec.rb +4 -4
  84. data/spec/integration/serverless/v1/service/environment/log_spec.rb +1 -0
  85. data/spec/integration/serverless/v1/service/function/function_version_spec.rb +1 -1
  86. data/spec/integration/studio/v1/flow/execution_spec.rb +46 -0
  87. data/spec/integration/studio/v2/flow/execution_spec.rb +45 -0
  88. data/spec/integration/studio/v2/flow_spec.rb +4 -0
  89. data/spec/integration/studio/v2/flow_validate_spec.rb +2 -2
  90. data/spec/integration/supersim/v1/fleet_spec.rb +12 -4
  91. data/spec/integration/supersim/v1/network_access_profile/network_access_profile_network_spec.rb +179 -0
  92. data/spec/integration/supersim/v1/network_access_profile_spec.rb +223 -0
  93. data/spec/integration/supersim/v1/network_spec.rb +139 -0
  94. data/spec/integration/trunking/v1/trunk/credential_list_spec.rb +13 -13
  95. data/spec/integration/trunking/v1/trunk/ip_access_control_list_spec.rb +23 -23
  96. data/spec/integration/trunking/v1/trunk/origination_url_spec.rb +28 -28
  97. data/spec/integration/trunking/v1/trunk/phone_number_spec.rb +17 -17
  98. data/spec/integration/trunking/v1/trunk_spec.rb +33 -33
  99. data/spec/integration/verify/v2/form_spec.rb +48 -0
  100. data/spec/integration/verify/v2/service/entity/factor/challenge_spec.rb +353 -0
  101. data/spec/integration/verify/v2/service/entity/factor_spec.rb +298 -0
  102. data/spec/integration/verify/v2/service/entity_spec.rb +201 -0
  103. data/spec/integration/verify/v2/service_spec.rb +28 -4
  104. data/spec/integration/video/v1/composition_settings_spec.rb +2 -2
  105. data/spec/integration/video/v1/recording_settings_spec.rb +2 -2
  106. data/spec/integration/video/v1/recording_spec.rb +2 -2
  107. data/spec/integration/video/v1/room/recording_spec.rb +2 -2
  108. data/spec/integration/voice/v1/byoc_trunk_spec.rb +250 -0
  109. data/spec/integration/voice/v1/connection_policy/connection_policy_target_spec.rb +246 -0
  110. data/spec/integration/voice/v1/connection_policy_spec.rb +226 -0
  111. data/spec/integration/voice/v1/ip_record_spec.rb +223 -0
  112. data/spec/integration/voice/v1/source_ip_mapping_spec.rb +219 -0
  113. data/spec/rest/client_spec.rb +173 -23
  114. data/spec/util/configuration_spec.rb +12 -0
  115. data/twilio-ruby.gemspec +4 -4
  116. metadata +67 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19a14979c8e969be4023b30f2b4188e364adde650a68730592639ca6d7d8f473
4
- data.tar.gz: d4f4d2299734e8e1e7ea75c60b480dbad6783f0467991faa42cc84fb53bcd354
3
+ metadata.gz: e0442d91ae15369f07249085856a03505c1beb0a71d76c88862ad992e3fcb390
4
+ data.tar.gz: 01f4add7958ec84a106489a68aece150618496782c1902720ed61722c95b9eb1
5
5
  SHA512:
6
- metadata.gz: d9eb5a26adf7209ac7b6b83e15cc1284ea77713737845b61e121b25ce27f8b1c1d835ebd3fc04e31fe9e3815232762a021cdefe6d08831d3108deae5cde22b57
7
- data.tar.gz: 1bdb3e73fc6236b9642ce27ee0b2067edf36b9121f1302a0c2e2a9ead22013390d2c2417658385cc5a43fbf7563adcf5785d710fb5e08cb5361730df339014c6
6
+ metadata.gz: 5a38fb1c3693fa9ce9450d37447d75fb7000f7c547f46b2a1af638327f8ca3ecc639755caf2ddbf1145f366d4ecb9b78cfaab139adc0d45c97854a9a7fbdbcc8
7
+ data.tar.gz: 991079bc47595a00e3f2bc02063891af980dec39f2a814fd80d04d5a895d1c5d87839f3bc4c278ee66fa291bd7a3b14494326fc81d178f554891266f500d17aa
@@ -15,6 +15,14 @@ Layout/LineLength:
15
15
  Exclude:
16
16
  - 'spec/**/*'
17
17
 
18
+ Style/BlockDelimiters:
19
+ Exclude:
20
+ - 'spec/**/*'
21
+
22
+ Lint/AmbiguousBlockAssociation:
23
+ Exclude:
24
+ - 'spec/**/*'
25
+
18
26
  Metrics/BlockLength:
19
27
  Exclude:
20
28
  - 'spec/**/*'
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-01-06 13:56:04 -0300 using RuboCop version 0.79.0.
3
+ # on 2020-04-29 14:57:47 -0500 using RuboCop version 0.82.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -55,22 +55,14 @@ Layout/SpaceInsideHashLiteralBraces:
55
55
 
56
56
  # Offense count: 1
57
57
  # Cop supports --auto-correct.
58
- # Configuration parameters: IndentationWidth.
59
- Layout/Tab:
60
- Exclude:
61
- - 'twilio-ruby.gemspec'
62
-
63
- # Offense count: 2
64
- # Cop supports --auto-correct.
65
58
  # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
66
59
  Lint/UnusedBlockArgument:
67
60
  Exclude:
68
- - 'Rakefile'
69
61
  - 'spec/rack/twilio_webhook_authentication_spec.rb'
70
62
 
71
63
  # Offense count: 4
72
64
  # Cop supports --auto-correct.
73
- # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
65
+ # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
74
66
  Lint/UnusedMethodArgument:
75
67
  Exclude:
76
68
  - 'lib/twilio-ruby.rb'
@@ -88,12 +80,6 @@ Lint/UselessAssignment:
88
80
  Exclude:
89
81
  - 'spec/rack/twilio_webhook_authentication_spec.rb'
90
82
 
91
- # Offense count: 1
92
- # Configuration parameters: CountComments, ExcludedMethods.
93
- # ExcludedMethods: refine
94
- Metrics/BlockLength:
95
- Max: 28
96
-
97
83
  # Offense count: 1
98
84
  # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
99
85
  # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
@@ -103,7 +89,7 @@ Naming/FileName:
103
89
 
104
90
  # Offense count: 2
105
91
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
106
- # AllowedNames: io, id, to, by, on, in, at, ip, db, os
92
+ # AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp
107
93
  Naming/MethodParameterName:
108
94
  Exclude:
109
95
  - 'lib/twilio-ruby/security/request_validator.rb'
@@ -116,7 +102,7 @@ Naming/VariableName:
116
102
  - 'spec/jwt/client_capability_spec.rb'
117
103
  - 'spec/jwt/task_router_spec.rb'
118
104
 
119
- # Offense count: 38
105
+ # Offense count: 39
120
106
  Style/Documentation:
121
107
  Enabled: false
122
108
 
@@ -136,7 +122,7 @@ Style/ExpandPathArguments:
136
122
  # Offense count: 23
137
123
  # Cop supports --auto-correct.
138
124
  # Configuration parameters: EnforcedStyle.
139
- # SupportedStyles: always, never
125
+ # SupportedStyles: always, always_true, never
140
126
  Style/FrozenStringLiteralComment:
141
127
  Enabled: false
142
128
 
@@ -195,13 +181,6 @@ Style/StringLiterals:
195
181
  Exclude:
196
182
  - 'spec/framework/serialize_spec.rb'
197
183
 
198
- # Offense count: 1
199
- # Cop supports --auto-correct.
200
- # Configuration parameters: MinSize.
201
- # SupportedStyles: percent, brackets
202
- Style/SymbolArray:
203
- EnforcedStyle: brackets
204
-
205
184
  # Offense count: 14
206
185
  # Cop supports --auto-correct.
207
186
  # Configuration parameters: AllowNamedUnderscoreVariables.
@@ -1,4 +1,3 @@
1
- sudo: false
2
1
  language: ruby
3
2
  cache: bundler
4
3
  bundler_args: --without development
@@ -34,3 +33,12 @@ deploy:
34
33
  on:
35
34
  tags: true
36
35
  rvm: "2.4"
36
+
37
+ notifications:
38
+ slack:
39
+ if: branch = master
40
+ on_pull_requests: false
41
+ on_success: never
42
+ on_failure: change
43
+ rooms:
44
+ - secure: AxzkBxp8izIXqkOEDiUaGjjym60GvuJeV1sBAHnLXqujDDpvdCeM+G8r274Xp48l7YqFz72PR2prFrAl8qMY5IVVFBolH1BtXqa7MsgclFKXXhq87y7OqzrUHVwdB1TAhse7k/wkeVN+mFPZswzSYqDzR3WmAbBG0iT6d1szO6c=
data/CHANGES.md CHANGED
@@ -1,6 +1,116 @@
1
1
  twilio-ruby changelog
2
2
  =====================
3
3
 
4
+ [2020-05-27] Version 5.36.0
5
+ ---------------------------
6
+ **Api**
7
+ - Added `reason_conference_ended` and `call_sid_ending_conference` to Conference read/fetch/update
8
+ - Fixed some examples to use the correct "TK" SID prefix for Trunk resources.
9
+
10
+ **Authy**
11
+ - Renamed `twilio_authy_sandbox_mode` headers to `twilio_sandbox_mode` **(breaking change)**
12
+ - Renamed `Twilio-Authy-*` headers to `Twilio-Veriry-*` **(breaking change)**
13
+
14
+ **Flex**
15
+ - Adding `flex_service_instance_sid` to Flex Configuration
16
+
17
+ **Preview**
18
+ - Removed insights preview API from API Definitions **(breaking change)**
19
+ - Added `Channels` endpoint to brand a phone number for BrandedCalls
20
+
21
+ **Serverless**
22
+ - Add Build Sid to Log results
23
+
24
+ **Supersim**
25
+ - Add Network Access Profile resource Networks subresource
26
+ - Allow specifying a Data Limit on Fleets
27
+
28
+ **Trunking**
29
+ - Fixed some examples to use the correct "TK" SID prefix for Trunk resources.
30
+
31
+
32
+ [2020-05-20] Version 5.35.0
33
+ ---------------------------
34
+ **Library - Feature**
35
+ - [PR #512](https://github.com/twilio/twilio-ruby/pull/512): add regional and edge support. Thanks to [@eshanholtz](https://github.com/eshanholtz)!
36
+
37
+
38
+ [2020-05-13] Version 5.34.1
39
+ ---------------------------
40
+ **Api**
41
+ - Add optional `emergency_caller_sid` parameter to SIP Domain
42
+ - Updated `call_reason` optional property to be treated as PII
43
+ - Added optional BYOC Trunk Sid property to Sip Domain API resource
44
+
45
+ **Autopilot**
46
+ - Add Restore resource to Autopilot Assistant
47
+
48
+ **Contacts**
49
+ - Added contacts Create API definition
50
+
51
+ **Events**
52
+ - Subscriptions API initial release
53
+
54
+ **Numbers**
55
+ - Add Evaluations API
56
+
57
+ **Supersim**
58
+ - Allow filtering the Fleets resource by Network Access Profile
59
+ - Allow assigning a Network Access Profile when creating and updating a Fleet
60
+ - Add Network Access Profiles resource
61
+
62
+ **Verify**
63
+ - Add `CustomCode` optional parameter on Verification creation.
64
+ - Add delete action on Service resource.
65
+
66
+ **Voice**
67
+ - Added endpoints for BYOC trunks, SIP connection policies and source IP mappings
68
+
69
+
70
+ [2020-04-29] Version 5.34.0
71
+ ---------------------------
72
+ **Library - Feature**
73
+ - [PR #511](https://github.com/twilio/twilio-ruby/pull/511): add details to error object. Thanks to [@ashish-s](https://github.com/ashish-s)!
74
+
75
+ **Preview**
76
+ - Added `Dispatch` version to `preview`
77
+
78
+ **Studio**
79
+ - Reroute Create Execution for V2 to the V2 downstream
80
+
81
+ **Supersim**
82
+ - Add Networks resource
83
+
84
+
85
+ [2020-04-15] Version 5.33.1
86
+ ---------------------------
87
+ **Library - Fix**
88
+ - [PR #506](https://github.com/twilio/twilio-ruby/pull/506): loosen the faraday version requirement. Thanks to [@childish-sambino](https://github.com/childish-sambino)!
89
+
90
+ **Library - Chore**
91
+ - [PR #508](https://github.com/twilio/twilio-ruby/pull/508): Refer to https:// homepage in gemspec. Thanks to [@olleolleolle](https://github.com/olleolleolle)!
92
+ - [PR #507](https://github.com/twilio/twilio-ruby/pull/507): Travis: Drop unused "sudo: false" directive. Thanks to [@olleolleolle](https://github.com/olleolleolle)!
93
+ - [PR #498](https://github.com/twilio/twilio-ruby/pull/498): autoload TwiML to save memory on load. Thanks to [@philnash](https://github.com/philnash)!
94
+ - [PR #499](https://github.com/twilio/twilio-ruby/pull/499): autoload JWT classes. Thanks to [@philnash](https://github.com/philnash)!
95
+ - [PR #505](https://github.com/twilio/twilio-ruby/pull/505): remove S3 URLs from test data. Thanks to [@childish-sambino](https://github.com/childish-sambino)!
96
+
97
+ **Api**
98
+ - Updated description for property `call_reason` in the call create request
99
+
100
+ **Contacts**
101
+ - Added Read, Delete All, and Delete by SID docs
102
+ - Initial Release
103
+
104
+ **Studio**
105
+ - Rename `flow_valid` to `flow_validate`
106
+ - Removed `errors` and `warnings` from flows error response and added new property named `details`
107
+ - Add Update Execution endpoints to v1 and v2 to end execution via API
108
+ - Add new `warnings` attribute v2 flow POST api
109
+
110
+ **Twiml**
111
+ - Add enhanced attribute to use with `speech_model` for the `Gather` verb
112
+
113
+
4
114
  [2020-04-01] Version 5.33.0
5
115
  ---------------------------
6
116
  **Library - Chore**
data/README.md CHANGED
@@ -32,13 +32,13 @@ This library supports the following Ruby implementations:
32
32
  To install using [Bundler][bundler] grab the latest stable version:
33
33
 
34
34
  ```ruby
35
- gem 'twilio-ruby', '~> 5.33.0'
35
+ gem 'twilio-ruby', '~> 5.36.0'
36
36
  ```
37
37
 
38
38
  To manually install `twilio-ruby` via [Rubygems][rubygems] simply gem install:
39
39
 
40
40
  ```bash
41
- gem install twilio-ruby -v 5.33.0
41
+ gem install twilio-ruby -v 5.36.0
42
42
  ```
43
43
 
44
44
  To build and install the development branch yourself from the latest source:
@@ -64,6 +64,21 @@ auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
64
64
  @client = Twilio::REST::Client.new account_sid, auth_token
65
65
  ```
66
66
 
67
+ ### Specify a Region and/or Edge
68
+
69
+ ```ruby
70
+ # set up a client to talk to the Twilio REST API over a specific region and edge
71
+ @client = Twilio::REST::Client.new account_sid, auth_token, nil, 'au1'
72
+ @client.edge = 'sydney'
73
+
74
+ # you may also specify the region and/or edge after client creation
75
+ @client = Twilio::REST::Client.new account_sid, auth_token
76
+ @client.region = 'au1'
77
+ @client.edge = 'sydney'
78
+ ```
79
+
80
+ This will result in the `hostname` transforming from `api.twilio.com` to `api.sydney.au1.twilio.com`.
81
+
67
82
  ### Make a Call
68
83
 
69
84
  ```ruby
@@ -2,12 +2,10 @@
2
2
 
3
3
  require 'net/http'
4
4
  require 'net/https'
5
- require 'nokogiri'
6
5
  require 'cgi'
7
6
  require 'openssl'
8
7
  require 'base64'
9
8
  require 'forwardable'
10
- require 'jwt'
11
9
  require 'time'
12
10
  require 'json'
13
11
 
@@ -15,18 +13,9 @@ require 'twilio-ruby/version' unless defined?(Twilio::VERSION)
15
13
  require 'rack/twilio_webhook_authentication'
16
14
 
17
15
  require 'twilio-ruby/util'
18
- require 'twilio-ruby/jwt/jwt'
19
- require 'twilio-ruby/jwt/access_token'
20
- require 'twilio-ruby/jwt/client_capability'
21
- require 'twilio-ruby/jwt/task_router'
22
16
  require 'twilio-ruby/security/request_validator'
23
17
  require 'twilio-ruby/util/configuration'
24
18
 
25
- require 'twilio-ruby/twiml/twiml'
26
- require 'twilio-ruby/twiml/fax_response'
27
- require 'twilio-ruby/twiml/messaging_response'
28
- require 'twilio-ruby/twiml/voice_response'
29
-
30
19
  Dir[File.dirname(__FILE__) + '/twilio-ruby/http/**/*.rb'].sort.each do |file|
31
20
  require file
32
21
  end
@@ -46,7 +35,10 @@ end
46
35
  module Twilio
47
36
  extend SingleForwardable
48
37
 
49
- def_delegators :configuration, :account_sid, :auth_token, :http_client
38
+ autoload :JWT, File.join(File.dirname(__FILE__), 'twilio-ruby', 'jwt', 'jwt.rb')
39
+ autoload :TwiML, File.join(File.dirname(__FILE__), 'twilio-ruby', 'twiml', 'twiml.rb')
40
+
41
+ def_delegators :configuration, :account_sid, :auth_token, :http_client, :region, :edge
50
42
 
51
43
  ##
52
44
  # Pre-configure with account SID and auth token so that you don't need to
@@ -11,12 +11,12 @@ module Twilio
11
11
  end
12
12
 
13
13
  class RestError < TwilioError
14
- attr_reader :message, :response, :code, :status_code, :detail, :more_info, :error_message
14
+ attr_reader :message, :response, :code, :status_code, :details, :more_info, :error_message
15
15
 
16
16
  def initialize(message, response)
17
17
  @status_code = response.status_code
18
18
  @code = response.body.fetch('code', @status_code)
19
- @detail = response.body.fetch('detail', nil)
19
+ @details = response.body.fetch('details', nil)
20
20
  @error_message = response.body.fetch('message', nil)
21
21
  @more_info = response.body.fetch('more_info', nil)
22
22
  @message = format_message(message)
@@ -39,7 +39,7 @@ module Twilio
39
39
  def format_message(initial_message)
40
40
  message = "[HTTP #{status_code}] #{code} : #{initial_message}"
41
41
  message += "\n#{error_message}" if error_message
42
- message += "\n#{detail}" if detail
42
+ message += "\n#{details}" if details
43
43
  message += "\n#{more_info}" if more_info
44
44
  message + "\n\n"
45
45
  end
@@ -1,7 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'jwt'
4
+
3
5
  module Twilio
4
6
  module JWT
7
+ autoload :AccessToken, File.join(File.dirname(__FILE__), 'access_token.rb')
8
+ autoload :ClientCapability, File.join(File.dirname(__FILE__), 'client_capability.rb')
9
+ autoload :TaskRouterCapability, File.join(File.dirname(__FILE__), 'task_router.rb')
10
+
5
11
  class BaseJWT
6
12
  # valid_until overrides ttl if specified
7
13
  def initialize(secret_key: nil, issuer: nil, subject: nil, nbf: nil, ttl: 3600, valid_until: nil)
@@ -139,9 +139,9 @@ module Twilio
139
139
  # @param [String] byoc The SID of a BYOC (Bring Your Own Carrier) trunk to route
140
140
  # this call with. Note that `byoc` is only meaningful when `to` is a phone number;
141
141
  # it will otherwise be ignored. (Beta)
142
- # @param [String] call_reason The Reason for the outgoing call. Use call_reason to
143
- # specify the purpose of the call that is presented on the called party's phone.
144
- # (Beta).
142
+ # @param [String] call_reason The Reason for the outgoing call. Use it to specify
143
+ # the purpose of the call that is presented on the called party's phone. (Branded
144
+ # Calls Beta)
145
145
  # @param [String] url The absolute URL that returns the TwiML instructions for the
146
146
  # call. We will call this URL using the `method` when the call connects. For more
147
147
  # information, see the [Url
@@ -614,33 +614,33 @@ module Twilio
614
614
 
615
615
  # Marshaled Properties
616
616
  @properties = {
617
- 'account_sid' => payload['account_sid'],
618
- 'annotation' => payload['annotation'],
619
- 'answered_by' => payload['answered_by'],
620
- 'api_version' => payload['api_version'],
621
- 'caller_name' => payload['caller_name'],
617
+ 'sid' => payload['sid'],
622
618
  'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
623
619
  'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
624
- 'direction' => payload['direction'],
625
- 'duration' => payload['duration'],
626
- 'end_time' => Twilio.deserialize_rfc2822(payload['end_time']),
627
- 'forwarded_from' => payload['forwarded_from'],
620
+ 'parent_call_sid' => payload['parent_call_sid'],
621
+ 'account_sid' => payload['account_sid'],
622
+ 'to' => payload['to'],
623
+ 'to_formatted' => payload['to_formatted'],
628
624
  'from' => payload['from'],
629
625
  'from_formatted' => payload['from_formatted'],
630
- 'group_sid' => payload['group_sid'],
631
- 'parent_call_sid' => payload['parent_call_sid'],
632
626
  'phone_number_sid' => payload['phone_number_sid'],
627
+ 'status' => payload['status'],
628
+ 'start_time' => Twilio.deserialize_rfc2822(payload['start_time']),
629
+ 'end_time' => Twilio.deserialize_rfc2822(payload['end_time']),
630
+ 'duration' => payload['duration'],
633
631
  'price' => payload['price'],
634
632
  'price_unit' => payload['price_unit'],
635
- 'sid' => payload['sid'],
636
- 'start_time' => Twilio.deserialize_rfc2822(payload['start_time']),
637
- 'status' => payload['status'],
638
- 'subresource_uris' => payload['subresource_uris'],
639
- 'to' => payload['to'],
640
- 'to_formatted' => payload['to_formatted'],
633
+ 'direction' => payload['direction'],
634
+ 'answered_by' => payload['answered_by'],
635
+ 'annotation' => payload['annotation'],
636
+ 'api_version' => payload['api_version'],
637
+ 'forwarded_from' => payload['forwarded_from'],
638
+ 'group_sid' => payload['group_sid'],
639
+ 'caller_name' => payload['caller_name'],
640
+ 'queue_time' => payload['queue_time'],
641
641
  'trunk_sid' => payload['trunk_sid'],
642
642
  'uri' => payload['uri'],
643
- 'queue_time' => payload['queue_time'],
643
+ 'subresource_uris' => payload['subresource_uris'],
644
644
  }
645
645
 
646
646
  # Context
@@ -660,33 +660,9 @@ module Twilio
660
660
  end
661
661
 
662
662
  ##
663
- # @return [String] The SID of the Account that created this resource
664
- def account_sid
665
- @properties['account_sid']
666
- end
667
-
668
- ##
669
- # @return [String] The annotation provided for the call
670
- def annotation
671
- @properties['annotation']
672
- end
673
-
674
- ##
675
- # @return [String] Either `human` or `machine` if this call was initiated with answering machine detection. Empty otherwise.
676
- def answered_by
677
- @properties['answered_by']
678
- end
679
-
680
- ##
681
- # @return [String] The API Version used to create the call
682
- def api_version
683
- @properties['api_version']
684
- end
685
-
686
- ##
687
- # @return [String] The caller's name if this call was an incoming call to a phone number with caller ID Lookup enabled. Otherwise, empty.
688
- def caller_name
689
- @properties['caller_name']
663
+ # @return [String] The unique string that identifies this resource
664
+ def sid
665
+ @properties['sid']
690
666
  end
691
667
 
692
668
  ##
@@ -702,27 +678,27 @@ module Twilio
702
678
  end
703
679
 
704
680
  ##
705
- # @return [String] A string describing the direction of the call. `inbound` for inbound calls, `outbound-api` for calls initiated via the REST API or `outbound-dial` for calls initiated by a `Dial` verb.
706
- def direction
707
- @properties['direction']
681
+ # @return [String] The SID that identifies the call that created this leg.
682
+ def parent_call_sid
683
+ @properties['parent_call_sid']
708
684
  end
709
685
 
710
686
  ##
711
- # @return [String] The length of the call in seconds.
712
- def duration
713
- @properties['duration']
687
+ # @return [String] The SID of the Account that created this resource
688
+ def account_sid
689
+ @properties['account_sid']
714
690
  end
715
691
 
716
692
  ##
717
- # @return [Time] The end time of the call. Null if the call did not complete successfully.
718
- def end_time
719
- @properties['end_time']
693
+ # @return [String] The phone number, SIP address or Client identifier that received this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as `name@company.com`. Client identifiers are formatted `client:name`.
694
+ def to
695
+ @properties['to']
720
696
  end
721
697
 
722
698
  ##
723
- # @return [String] The forwarding phone number if this call was an incoming call forwarded from another number (depends on carrier supporting forwarding). Otherwise, empty.
724
- def forwarded_from
725
- @properties['forwarded_from']
699
+ # @return [String] The phone number, SIP address or Client identifier that received this call. Formatted for display.
700
+ def to_formatted
701
+ @properties['to_formatted']
726
702
  end
727
703
 
728
704
  ##
@@ -738,21 +714,33 @@ module Twilio
738
714
  end
739
715
 
740
716
  ##
741
- # @return [String] The Group SID associated with this call. If no Group is associated with the call, the field is empty.
742
- def group_sid
743
- @properties['group_sid']
717
+ # @return [String] If the call was inbound, this is the SID of the IncomingPhoneNumber resource that received the call. If the call was outbound, it is the SID of the OutgoingCallerId resource from which the call was placed.
718
+ def phone_number_sid
719
+ @properties['phone_number_sid']
744
720
  end
745
721
 
746
722
  ##
747
- # @return [String] The SID that identifies the call that created this leg.
748
- def parent_call_sid
749
- @properties['parent_call_sid']
723
+ # @return [call.Status] The status of this call.
724
+ def status
725
+ @properties['status']
750
726
  end
751
727
 
752
728
  ##
753
- # @return [String] If the call was inbound, this is the SID of the IncomingPhoneNumber resource that received the call. If the call was outbound, it is the SID of the OutgoingCallerId resource from which the call was placed.
754
- def phone_number_sid
755
- @properties['phone_number_sid']
729
+ # @return [Time] The start time of the call. Null if the call has not yet been dialed.
730
+ def start_time
731
+ @properties['start_time']
732
+ end
733
+
734
+ ##
735
+ # @return [Time] The end time of the call. Null if the call did not complete successfully.
736
+ def end_time
737
+ @properties['end_time']
738
+ end
739
+
740
+ ##
741
+ # @return [String] The length of the call in seconds.
742
+ def duration
743
+ @properties['duration']
756
744
  end
757
745
 
758
746
  ##
@@ -768,39 +756,51 @@ module Twilio
768
756
  end
769
757
 
770
758
  ##
771
- # @return [String] The unique string that identifies this resource
772
- def sid
773
- @properties['sid']
759
+ # @return [String] A string describing the direction of the call. `inbound` for inbound calls, `outbound-api` for calls initiated via the REST API or `outbound-dial` for calls initiated by a `Dial` verb.
760
+ def direction
761
+ @properties['direction']
774
762
  end
775
763
 
776
764
  ##
777
- # @return [Time] The start time of the call. Null if the call has not yet been dialed.
778
- def start_time
779
- @properties['start_time']
765
+ # @return [String] Either `human` or `machine` if this call was initiated with answering machine detection. Empty otherwise.
766
+ def answered_by
767
+ @properties['answered_by']
780
768
  end
781
769
 
782
770
  ##
783
- # @return [call.Status] The status of this call.
784
- def status
785
- @properties['status']
771
+ # @return [String] The annotation provided for the call
772
+ def annotation
773
+ @properties['annotation']
786
774
  end
787
775
 
788
776
  ##
789
- # @return [String] A list of related subresources identified by their relative URIs
790
- def subresource_uris
791
- @properties['subresource_uris']
777
+ # @return [String] The API Version used to create the call
778
+ def api_version
779
+ @properties['api_version']
792
780
  end
793
781
 
794
782
  ##
795
- # @return [String] The phone number, SIP address or Client identifier that received this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as `name@company.com`. Client identifiers are formatted `client:name`.
796
- def to
797
- @properties['to']
783
+ # @return [String] The forwarding phone number if this call was an incoming call forwarded from another number (depends on carrier supporting forwarding). Otherwise, empty.
784
+ def forwarded_from
785
+ @properties['forwarded_from']
798
786
  end
799
787
 
800
788
  ##
801
- # @return [String] The phone number, SIP address or Client identifier that received this call. Formatted for display.
802
- def to_formatted
803
- @properties['to_formatted']
789
+ # @return [String] The Group SID associated with this call. If no Group is associated with the call, the field is empty.
790
+ def group_sid
791
+ @properties['group_sid']
792
+ end
793
+
794
+ ##
795
+ # @return [String] The caller's name if this call was an incoming call to a phone number with caller ID Lookup enabled. Otherwise, empty.
796
+ def caller_name
797
+ @properties['caller_name']
798
+ end
799
+
800
+ ##
801
+ # @return [String] The wait time in milliseconds before the call is placed.
802
+ def queue_time
803
+ @properties['queue_time']
804
804
  end
805
805
 
806
806
  ##
@@ -816,9 +816,9 @@ module Twilio
816
816
  end
817
817
 
818
818
  ##
819
- # @return [String] The wait time in milliseconds before the call is placed.
820
- def queue_time
821
- @properties['queue_time']
819
+ # @return [String] A list of related subresources identified by their relative URIs
820
+ def subresource_uris
821
+ @properties['subresource_uris']
822
822
  end
823
823
 
824
824
  ##