twilio-ruby 5.34.0 → 5.38.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.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +126 -0
  3. data/README.md +24 -3
  4. data/lib/twilio-ruby.rb +1 -1
  5. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +87 -87
  6. data/lib/twilio-ruby/rest/api/v2010/account/conference.rb +14 -0
  7. data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +47 -9
  8. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +71 -71
  9. data/lib/twilio-ruby/rest/api/v2010/account/queue.rb +29 -29
  10. data/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb +38 -3
  11. data/lib/twilio-ruby/rest/api/v2010/account/validation_request.rb +12 -12
  12. data/lib/twilio-ruby/rest/autopilot.rb +6 -0
  13. data/lib/twilio-ruby/rest/autopilot/v1.rb +7 -0
  14. data/lib/twilio-ruby/rest/autopilot/v1/assistant.rb +0 -16
  15. data/lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb +12 -3
  16. data/lib/twilio-ruby/rest/autopilot/v1/restore_assistant.rb +198 -0
  17. data/lib/twilio-ruby/rest/client.rb +35 -15
  18. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +28 -3
  19. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +27 -4
  20. data/lib/twilio-ruby/rest/flex_api/v1/channel.rb +2 -1
  21. data/lib/twilio-ruby/rest/flex_api/v1/configuration.rb +7 -0
  22. data/lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb +6 -3
  23. data/lib/twilio-ruby/rest/monitor/v1/alert.rb +8 -8
  24. data/lib/twilio-ruby/rest/notify/v1/service.rb +20 -1
  25. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle.rb +26 -0
  26. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/evaluation.rb +324 -0
  27. data/lib/twilio-ruby/rest/preview.rb +6 -0
  28. data/lib/twilio-ruby/rest/preview/trusted_comms.rb +7 -0
  29. data/lib/twilio-ruby/rest/preview/trusted_comms/brands_information.rb +193 -0
  30. data/lib/twilio-ruby/rest/preview/trusted_comms/business.rb +26 -0
  31. data/lib/twilio-ruby/rest/{autopilot/v1/assistant/export_assistant.rb → preview/trusted_comms/business/brand.rb} +88 -71
  32. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand/branded_channel.rb +266 -0
  33. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand/branded_channel/channel.rb +194 -0
  34. data/lib/twilio-ruby/rest/serverless/v1/service/environment/log.rb +7 -0
  35. data/lib/twilio-ruby/rest/supersim.rb +18 -0
  36. data/lib/twilio-ruby/rest/supersim/v1.rb +30 -0
  37. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +63 -16
  38. data/lib/twilio-ruby/rest/supersim/v1/network.rb +315 -0
  39. data/lib/twilio-ruby/rest/{authy/v1/service.rb → supersim/v1/network_access_profile.rb} +95 -121
  40. data/lib/twilio-ruby/rest/supersim/v1/network_access_profile/network_access_profile_network.rb +352 -0
  41. data/lib/twilio-ruby/rest/verify.rb +9 -0
  42. data/lib/twilio-ruby/rest/verify/v2.rb +16 -0
  43. data/lib/twilio-ruby/rest/{authy/v1 → verify/v2}/form.rb +8 -8
  44. data/lib/twilio-ruby/rest/verify/v2/service.rb +74 -3
  45. data/lib/twilio-ruby/rest/{authy/v1 → verify/v2}/service/entity.rb +32 -8
  46. data/lib/twilio-ruby/rest/verify/v2/service/entity/access_token.rb +141 -0
  47. data/lib/twilio-ruby/rest/{authy/v1 → verify/v2}/service/entity/factor.rb +8 -8
  48. data/lib/twilio-ruby/rest/{authy/v1 → verify/v2}/service/entity/factor/challenge.rb +8 -8
  49. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +3 -3
  50. data/lib/twilio-ruby/rest/verify/v2/service/webhook.rb +425 -0
  51. data/lib/twilio-ruby/rest/video/v1/composition_settings.rb +8 -4
  52. data/lib/twilio-ruby/rest/video/v1/recording_settings.rb +8 -4
  53. data/lib/twilio-ruby/rest/voice.rb +36 -0
  54. data/lib/twilio-ruby/rest/voice/v1.rb +64 -0
  55. data/lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb +513 -0
  56. data/lib/twilio-ruby/rest/voice/v1/connection_policy.rb +379 -0
  57. data/lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb +458 -0
  58. data/lib/twilio-ruby/rest/voice/v1/ip_record.rb +366 -0
  59. data/lib/twilio-ruby/rest/voice/v1/source_ip_mapping.rb +346 -0
  60. data/lib/twilio-ruby/util/configuration.rb +9 -1
  61. data/lib/twilio-ruby/version.rb +1 -1
  62. data/spec/integration/api/v2010/account/call_spec.rb +5 -5
  63. data/spec/integration/api/v2010/account/conference/participant_spec.rb +177 -0
  64. data/spec/integration/api/v2010/account/conference_spec.rb +42 -14
  65. data/spec/integration/api/v2010/account/outgoing_caller_id_spec.rb +8 -14
  66. data/spec/integration/api/v2010/account/sip/domain_spec.rb +12 -4
  67. data/spec/integration/api/v2010/account/token_spec.rb +23 -11
  68. data/spec/integration/api/v2010/account/validation_request_spec.rb +1 -1
  69. data/spec/integration/autopilot/v1/assistant/query_spec.rb +4 -4
  70. data/spec/integration/autopilot/v1/assistant_spec.rb +4 -8
  71. data/spec/integration/autopilot/v1/restore_assistant_spec.rb +53 -0
  72. data/spec/integration/conversations/v1/conversation/participant_spec.rb +7 -0
  73. data/spec/integration/conversations/v1/conversation_spec.rb +16 -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/trusted_comms/brands_information_spec.rb +44 -0
  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/environment/log_spec.rb +1 -0
  83. data/spec/integration/supersim/v1/fleet_spec.rb +16 -7
  84. data/spec/integration/supersim/v1/network_access_profile/network_access_profile_network_spec.rb +179 -0
  85. data/spec/integration/supersim/v1/network_access_profile_spec.rb +223 -0
  86. data/spec/integration/supersim/v1/network_spec.rb +139 -0
  87. data/spec/integration/supersim/v1/sim_spec.rb +78 -6
  88. data/spec/integration/trunking/v1/trunk/credential_list_spec.rb +13 -13
  89. data/spec/integration/trunking/v1/trunk/ip_access_control_list_spec.rb +23 -23
  90. data/spec/integration/trunking/v1/trunk/origination_url_spec.rb +28 -28
  91. data/spec/integration/trunking/v1/trunk/phone_number_spec.rb +17 -17
  92. data/spec/integration/trunking/v1/trunk_spec.rb +33 -33
  93. data/spec/integration/{authy/v1 → verify/v2}/form_spec.rb +4 -4
  94. data/spec/integration/verify/v2/service/entity/access_token_spec.rb +46 -0
  95. data/spec/integration/{authy/v1 → verify/v2}/service/entity/factor/challenge_spec.rb +73 -73
  96. data/spec/integration/{authy/v1 → verify/v2}/service/entity/factor_spec.rb +54 -54
  97. data/spec/integration/verify/v2/service/entity_spec.rb +204 -0
  98. data/spec/integration/verify/v2/service/webhook_spec.rb +262 -0
  99. data/spec/integration/verify/v2/service_spec.rb +32 -4
  100. data/spec/integration/voice/v1/byoc_trunk_spec.rb +250 -0
  101. data/spec/integration/voice/v1/connection_policy/connection_policy_target_spec.rb +246 -0
  102. data/spec/integration/voice/v1/connection_policy_spec.rb +226 -0
  103. data/spec/integration/voice/v1/ip_record_spec.rb +223 -0
  104. data/spec/integration/voice/v1/source_ip_mapping_spec.rb +219 -0
  105. data/spec/rest/client_spec.rb +168 -58
  106. data/spec/util/configuration_spec.rb +12 -0
  107. data/twilio-ruby.gemspec +1 -1
  108. metadata +63 -23
  109. data/lib/twilio-ruby/rest/authy.rb +0 -55
  110. data/lib/twilio-ruby/rest/authy/v1.rb +0 -59
  111. data/spec/integration/authy/v1/service/entity_spec.rb +0 -201
  112. data/spec/integration/authy/v1/service_spec.rb +0 -231
  113. data/spec/integration/autopilot/v1/assistant/export_assistant_spec.rb +0 -49
@@ -0,0 +1,223 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ require 'spec_helper.rb'
10
+
11
+ describe 'IpRecord' do
12
+ it "can create" do
13
+ @holodeck.mock(Twilio::Response.new(500, ''))
14
+
15
+ expect {
16
+ @client.voice.v1.ip_records.create(ip_address: 'ip_address')
17
+ }.to raise_exception(Twilio::REST::TwilioError)
18
+
19
+ values = {'IpAddress' => 'ip_address', }
20
+ expect(
21
+ @holodeck.has_request?(Holodeck::Request.new(
22
+ method: 'post',
23
+ url: 'https://voice.twilio.com/v1/IpRecords',
24
+ data: values,
25
+ ))).to eq(true)
26
+ end
27
+
28
+ it "receives create responses" do
29
+ @holodeck.mock(Twilio::Response.new(
30
+ 201,
31
+ %q[
32
+ {
33
+ "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
34
+ "sid": "ILaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
35
+ "friendly_name": "friendly_name",
36
+ "ip_address": "10.2.3.4",
37
+ "cidr_prefix_length": 30,
38
+ "date_created": "2020-03-18T23:31:36Z",
39
+ "date_updated": "2020-03-18T23:31:36Z",
40
+ "url": "https://voice.twilio.com/v1/IpRecords/ILaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
41
+ }
42
+ ]
43
+ ))
44
+
45
+ actual = @client.voice.v1.ip_records.create(ip_address: 'ip_address')
46
+
47
+ expect(actual).to_not eq(nil)
48
+ end
49
+
50
+ it "can fetch" do
51
+ @holodeck.mock(Twilio::Response.new(500, ''))
52
+
53
+ expect {
54
+ @client.voice.v1.ip_records('ILXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch()
55
+ }.to raise_exception(Twilio::REST::TwilioError)
56
+
57
+ values = {}
58
+ expect(
59
+ @holodeck.has_request?(Holodeck::Request.new(
60
+ method: 'get',
61
+ url: 'https://voice.twilio.com/v1/IpRecords/ILXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
62
+ ))).to eq(true)
63
+ end
64
+
65
+ it "receives fetch responses" do
66
+ @holodeck.mock(Twilio::Response.new(
67
+ 200,
68
+ %q[
69
+ {
70
+ "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
71
+ "sid": "ILaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
72
+ "friendly_name": "friendly_name",
73
+ "ip_address": "10.2.3.4",
74
+ "cidr_prefix_length": 30,
75
+ "date_created": "2020-03-18T23:31:36Z",
76
+ "date_updated": "2020-03-18T23:31:37Z",
77
+ "url": "https://voice.twilio.com/v1/IpRecords/ILaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
78
+ }
79
+ ]
80
+ ))
81
+
82
+ actual = @client.voice.v1.ip_records('ILXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch()
83
+
84
+ expect(actual).to_not eq(nil)
85
+ end
86
+
87
+ it "can read" do
88
+ @holodeck.mock(Twilio::Response.new(500, ''))
89
+
90
+ expect {
91
+ @client.voice.v1.ip_records.list()
92
+ }.to raise_exception(Twilio::REST::TwilioError)
93
+
94
+ values = {}
95
+ expect(
96
+ @holodeck.has_request?(Holodeck::Request.new(
97
+ method: 'get',
98
+ url: 'https://voice.twilio.com/v1/IpRecords',
99
+ ))).to eq(true)
100
+ end
101
+
102
+ it "receives read_full responses" do
103
+ @holodeck.mock(Twilio::Response.new(
104
+ 200,
105
+ %q[
106
+ {
107
+ "meta": {
108
+ "page": 0,
109
+ "page_size": 50,
110
+ "first_page_url": "https://voice.twilio.com/v1/IpRecords?PageSize=50&Page=0",
111
+ "previous_page_url": null,
112
+ "url": "https://voice.twilio.com/v1/IpRecords?PageSize=50&Page=0",
113
+ "next_page_url": null,
114
+ "key": "ip_records"
115
+ },
116
+ "ip_records": [
117
+ {
118
+ "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
119
+ "sid": "ILaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
120
+ "friendly_name": "friendly_name",
121
+ "ip_address": "10.2.3.4",
122
+ "cidr_prefix_length": 30,
123
+ "date_created": "2020-03-18T23:31:36Z",
124
+ "date_updated": "2020-03-18T23:31:37Z",
125
+ "url": "https://voice.twilio.com/v1/IpRecords/ILaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
126
+ }
127
+ ]
128
+ }
129
+ ]
130
+ ))
131
+
132
+ actual = @client.voice.v1.ip_records.list()
133
+
134
+ expect(actual).to_not eq(nil)
135
+ end
136
+
137
+ it "receives read_empty responses" do
138
+ @holodeck.mock(Twilio::Response.new(
139
+ 200,
140
+ %q[
141
+ {
142
+ "meta": {
143
+ "page": 0,
144
+ "page_size": 50,
145
+ "first_page_url": "https://voice.twilio.com/v1/IpRecords?PageSize=50&Page=0",
146
+ "previous_page_url": null,
147
+ "url": "https://voice.twilio.com/v1/IpRecords?PageSize=50&Page=0",
148
+ "next_page_url": null,
149
+ "key": "ip_records"
150
+ },
151
+ "ip_records": []
152
+ }
153
+ ]
154
+ ))
155
+
156
+ actual = @client.voice.v1.ip_records.list()
157
+
158
+ expect(actual).to_not eq(nil)
159
+ end
160
+
161
+ it "can update" do
162
+ @holodeck.mock(Twilio::Response.new(500, ''))
163
+
164
+ expect {
165
+ @client.voice.v1.ip_records('ILXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update()
166
+ }.to raise_exception(Twilio::REST::TwilioError)
167
+
168
+ values = {}
169
+ expect(
170
+ @holodeck.has_request?(Holodeck::Request.new(
171
+ method: 'post',
172
+ url: 'https://voice.twilio.com/v1/IpRecords/ILXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
173
+ ))).to eq(true)
174
+ end
175
+
176
+ it "receives update responses" do
177
+ @holodeck.mock(Twilio::Response.new(
178
+ 200,
179
+ %q[
180
+ {
181
+ "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
182
+ "sid": "ILaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
183
+ "friendly_name": "update_name",
184
+ "ip_address": "10.2.3.4",
185
+ "cidr_prefix_length": 30,
186
+ "date_created": "2020-03-18T23:31:36Z",
187
+ "date_updated": "2020-03-18T23:31:37Z",
188
+ "url": "https://voice.twilio.com/v1/IpRecords/ILaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
189
+ }
190
+ ]
191
+ ))
192
+
193
+ actual = @client.voice.v1.ip_records('ILXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update()
194
+
195
+ expect(actual).to_not eq(nil)
196
+ end
197
+
198
+ it "can delete" do
199
+ @holodeck.mock(Twilio::Response.new(500, ''))
200
+
201
+ expect {
202
+ @client.voice.v1.ip_records('ILXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete()
203
+ }.to raise_exception(Twilio::REST::TwilioError)
204
+
205
+ values = {}
206
+ expect(
207
+ @holodeck.has_request?(Holodeck::Request.new(
208
+ method: 'delete',
209
+ url: 'https://voice.twilio.com/v1/IpRecords/ILXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
210
+ ))).to eq(true)
211
+ end
212
+
213
+ it "receives delete responses" do
214
+ @holodeck.mock(Twilio::Response.new(
215
+ 204,
216
+ nil,
217
+ ))
218
+
219
+ actual = @client.voice.v1.ip_records('ILXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete()
220
+
221
+ expect(actual).to eq(true)
222
+ end
223
+ end
@@ -0,0 +1,219 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ require 'spec_helper.rb'
10
+
11
+ describe 'SourceIpMapping' do
12
+ it "can create" do
13
+ @holodeck.mock(Twilio::Response.new(500, ''))
14
+
15
+ expect {
16
+ @client.voice.v1.source_ip_mappings.create(ip_record_sid: 'ILXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', sip_domain_sid: 'SDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
17
+ }.to raise_exception(Twilio::REST::TwilioError)
18
+
19
+ values = {
20
+ 'IpRecordSid' => 'ILXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
21
+ 'SipDomainSid' => 'SDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
22
+ }
23
+ expect(
24
+ @holodeck.has_request?(Holodeck::Request.new(
25
+ method: 'post',
26
+ url: 'https://voice.twilio.com/v1/SourceIpMappings',
27
+ data: values,
28
+ ))).to eq(true)
29
+ end
30
+
31
+ it "receives create responses" do
32
+ @holodeck.mock(Twilio::Response.new(
33
+ 201,
34
+ %q[
35
+ {
36
+ "sid": "IBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
37
+ "ip_record_sid": "ILaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
38
+ "sip_domain_sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
39
+ "date_created": "2020-03-18T23:31:36Z",
40
+ "date_updated": "2020-03-18T23:31:36Z",
41
+ "url": "https://voice.twilio.com/v1/SourceIpMappings/IBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
42
+ }
43
+ ]
44
+ ))
45
+
46
+ actual = @client.voice.v1.source_ip_mappings.create(ip_record_sid: 'ILXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', sip_domain_sid: 'SDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
47
+
48
+ expect(actual).to_not eq(nil)
49
+ end
50
+
51
+ it "can fetch" do
52
+ @holodeck.mock(Twilio::Response.new(500, ''))
53
+
54
+ expect {
55
+ @client.voice.v1.source_ip_mappings('IBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch()
56
+ }.to raise_exception(Twilio::REST::TwilioError)
57
+
58
+ values = {}
59
+ expect(
60
+ @holodeck.has_request?(Holodeck::Request.new(
61
+ method: 'get',
62
+ url: 'https://voice.twilio.com/v1/SourceIpMappings/IBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
63
+ ))).to eq(true)
64
+ end
65
+
66
+ it "receives fetch responses" do
67
+ @holodeck.mock(Twilio::Response.new(
68
+ 200,
69
+ %q[
70
+ {
71
+ "sid": "IBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
72
+ "ip_record_sid": "ILaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
73
+ "sip_domain_sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
74
+ "date_created": "2020-03-18T23:31:36Z",
75
+ "date_updated": "2020-03-18T23:31:37Z",
76
+ "url": "https://voice.twilio.com/v1/SourceIpMappings/IBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
77
+ }
78
+ ]
79
+ ))
80
+
81
+ actual = @client.voice.v1.source_ip_mappings('IBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch()
82
+
83
+ expect(actual).to_not eq(nil)
84
+ end
85
+
86
+ it "can read" do
87
+ @holodeck.mock(Twilio::Response.new(500, ''))
88
+
89
+ expect {
90
+ @client.voice.v1.source_ip_mappings.list()
91
+ }.to raise_exception(Twilio::REST::TwilioError)
92
+
93
+ values = {}
94
+ expect(
95
+ @holodeck.has_request?(Holodeck::Request.new(
96
+ method: 'get',
97
+ url: 'https://voice.twilio.com/v1/SourceIpMappings',
98
+ ))).to eq(true)
99
+ end
100
+
101
+ it "receives read_full responses" do
102
+ @holodeck.mock(Twilio::Response.new(
103
+ 200,
104
+ %q[
105
+ {
106
+ "meta": {
107
+ "page": 0,
108
+ "page_size": 50,
109
+ "first_page_url": "https://voice.twilio.com/v1/SourceIpMappings?PageSize=50&Page=0",
110
+ "previous_page_url": null,
111
+ "url": "https://voice.twilio.com/v1/SourceIpMappings?PageSize=50&Page=0",
112
+ "next_page_url": null,
113
+ "key": "source_ip_mappings"
114
+ },
115
+ "source_ip_mappings": [
116
+ {
117
+ "sid": "IBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
118
+ "ip_record_sid": "ILaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
119
+ "sip_domain_sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
120
+ "date_created": "2020-03-18T23:31:36Z",
121
+ "date_updated": "2020-03-18T23:31:37Z",
122
+ "url": "https://voice.twilio.com/v1/SourceIpMappings/IBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
123
+ }
124
+ ]
125
+ }
126
+ ]
127
+ ))
128
+
129
+ actual = @client.voice.v1.source_ip_mappings.list()
130
+
131
+ expect(actual).to_not eq(nil)
132
+ end
133
+
134
+ it "receives read_empty responses" do
135
+ @holodeck.mock(Twilio::Response.new(
136
+ 200,
137
+ %q[
138
+ {
139
+ "meta": {
140
+ "page": 0,
141
+ "page_size": 50,
142
+ "first_page_url": "https://voice.twilio.com/v1/SourceIpMappings?PageSize=50&Page=0",
143
+ "previous_page_url": null,
144
+ "url": "https://voice.twilio.com/v1/SourceIpMappings?PageSize=50&Page=0",
145
+ "next_page_url": null,
146
+ "key": "source_ip_mappings"
147
+ },
148
+ "source_ip_mappings": []
149
+ }
150
+ ]
151
+ ))
152
+
153
+ actual = @client.voice.v1.source_ip_mappings.list()
154
+
155
+ expect(actual).to_not eq(nil)
156
+ end
157
+
158
+ it "can update" do
159
+ @holodeck.mock(Twilio::Response.new(500, ''))
160
+
161
+ expect {
162
+ @client.voice.v1.source_ip_mappings('IBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(sip_domain_sid: 'SDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
163
+ }.to raise_exception(Twilio::REST::TwilioError)
164
+
165
+ values = {'SipDomainSid' => 'SDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', }
166
+ expect(
167
+ @holodeck.has_request?(Holodeck::Request.new(
168
+ method: 'post',
169
+ url: 'https://voice.twilio.com/v1/SourceIpMappings/IBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
170
+ data: values,
171
+ ))).to eq(true)
172
+ end
173
+
174
+ it "receives update responses" do
175
+ @holodeck.mock(Twilio::Response.new(
176
+ 200,
177
+ %q[
178
+ {
179
+ "sid": "IBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
180
+ "ip_record_sid": "ILaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
181
+ "sip_domain_sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
182
+ "date_created": "2020-03-18T23:31:36Z",
183
+ "date_updated": "2020-03-18T23:31:37Z",
184
+ "url": "https://voice.twilio.com/v1/SourceIpMappings/IBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
185
+ }
186
+ ]
187
+ ))
188
+
189
+ actual = @client.voice.v1.source_ip_mappings('IBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(sip_domain_sid: 'SDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
190
+
191
+ expect(actual).to_not eq(nil)
192
+ end
193
+
194
+ it "can delete" do
195
+ @holodeck.mock(Twilio::Response.new(500, ''))
196
+
197
+ expect {
198
+ @client.voice.v1.source_ip_mappings('IBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete()
199
+ }.to raise_exception(Twilio::REST::TwilioError)
200
+
201
+ values = {}
202
+ expect(
203
+ @holodeck.has_request?(Holodeck::Request.new(
204
+ method: 'delete',
205
+ url: 'https://voice.twilio.com/v1/SourceIpMappings/IBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
206
+ ))).to eq(true)
207
+ end
208
+
209
+ it "receives delete responses" do
210
+ @holodeck.mock(Twilio::Response.new(
211
+ 204,
212
+ nil,
213
+ ))
214
+
215
+ actual = @client.voice.v1.source_ip_mappings('IBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete()
216
+
217
+ expect(actual).to eq(true)
218
+ end
219
+ end
@@ -49,75 +49,185 @@ describe Twilio::REST::TrunkingClient do
49
49
  end
50
50
 
51
51
  describe Twilio::REST::Client do
52
- before do
53
- Twilio.configure do |config|
54
- config.account_sid = 'someSid'
55
- config.auth_token = 'someToken'
56
- config.http_client = 'someClient'
52
+ context 'configuration' do
53
+ before do
54
+ Twilio.configure do |config|
55
+ config.account_sid = 'someSid'
56
+ config.auth_token = 'someToken'
57
+ config.http_client = 'someClient'
58
+ config.region = 'someRegion'
59
+ config.edge = 'someEdge'
60
+ end
57
61
  end
58
- end
59
62
 
60
- it 'uses the global configuration by default' do
61
- @client = Twilio::REST::Client.new
62
- expect(@client.account_sid).to eq('someSid')
63
- expect(@client.auth_token).to eq('someToken')
64
- expect(@client.http_client).to eq('someClient')
65
- end
63
+ it 'uses the global configuration by default' do
64
+ @client = Twilio::REST::Client.new
65
+ expect(@client.account_sid).to eq('someSid')
66
+ expect(@client.auth_token).to eq('someToken')
67
+ expect(@client.http_client).to eq('someClient')
68
+ expect(@client.region).to eq('someRegion')
69
+ expect(@client.edge).to eq('someEdge')
70
+ end
66
71
 
67
- it 'uses the arguments over global configuration' do
68
- @client = Twilio::REST::Client.new('myUser', 'myPassword', nil, nil, 'myClient')
69
- expect(@client.account_sid).to eq('myUser')
70
- expect(@client.auth_token).to eq('myPassword')
71
- expect(@client.http_client).to eq('myClient')
72
- end
72
+ it 'uses the arguments over global configuration' do
73
+ @client = Twilio::REST::Client.new('myUser', 'myPassword', nil, 'myRegion', 'myClient')
74
+ @client.edge = 'myEdge'
75
+ expect(@client.account_sid).to eq('myUser')
76
+ expect(@client.auth_token).to eq('myPassword')
77
+ expect(@client.http_client).to eq('myClient')
78
+ expect(@client.region).to eq('myRegion')
79
+ expect(@client.edge).to eq('myEdge')
80
+ end
73
81
 
74
- it 'successfully validates the working SSL certificate' do
75
- @holodeck.mock Twilio::Response.new(200, '')
76
- expect { @client.validate_ssl_certificate }.not_to raise_error
77
- end
82
+ class MyVersion < Twilio::REST::Version
83
+ def initialize(domain)
84
+ super
85
+ @version = 'v1'
86
+ end
87
+ end
78
88
 
79
- it 'fails to validate broken SSL certificates' do
80
- @holodeck.mock Twilio::Response.new(504, '')
81
- expect { @client.validate_ssl_certificate }.to raise_error(Twilio::REST::RestError)
89
+ class MyDomain < Twilio::REST::Domain
90
+ def initialize(client)
91
+ super
92
+ @host = 'twilio.com'
93
+ @base_url = 'https://twilio.com'
94
+ @port = 443
95
+ end
96
+ end
82
97
  end
83
98
 
84
- it 'translates bad request error params' do
85
- @domain = MyDomain.new(@client)
86
- @version = MyVersion.new(@domain)
87
- @error_message = '{
88
- "code": 20001,
89
- "message": "Bad request",
90
- "more_info": "https://www.twilio.com/docs/errors/20001",
91
- "status": 400,
92
- "details": {
93
- "foo":"bar"
94
- }}'
95
- @holodeck.mock Twilio::Response.new(400, @error_message)
96
- expect {
97
- @version.fetch('GET', 'http://foobar.com')
98
- }.to raise_error { |error|
99
- expect(error).to be_a(Twilio::REST::RestError)
100
- expect(error.status_code).to eq(400)
101
- expect(error.code).to eq(20_001)
102
- expect(error.details).to eq({ 'foo' => 'bar' })
103
- expect(error.error_message).to eq('Bad request')
104
- expect(error.more_info).to eq('https://www.twilio.com/docs/errors/20001')
105
- }
106
- end
99
+ context 'validation' do
100
+ before do
101
+ Twilio.configure do |config|
102
+ config.account_sid = 'someSid'
103
+ config.auth_token = 'someToken'
104
+ config.http_client = 'someClient'
105
+ config.region = nil
106
+ config.edge = nil
107
+ end
108
+ end
107
109
 
108
- class MyVersion < Twilio::REST::Version
109
- def initialize(domain)
110
- super
111
- @version = 'v1'
110
+ it 'successfully validates the working SSL certificate' do
111
+ @holodeck.mock Twilio::Response.new(200, '')
112
+ expect { @client.validate_ssl_certificate }.not_to raise_error
113
+ end
114
+
115
+ it 'fails to validate broken SSL certificates' do
116
+ @holodeck.mock Twilio::Response.new(504, '')
117
+ expect { @client.validate_ssl_certificate }.to raise_error(Twilio::REST::RestError)
118
+ end
119
+
120
+ it 'translates bad request error params' do
121
+ @domain = MyDomain.new(@client)
122
+ @version = MyVersion.new(@domain)
123
+ @error_message = '{
124
+ "code": 20001,
125
+ "message": "Bad request",
126
+ "more_info": "https://www.twilio.com/docs/errors/20001",
127
+ "status": 400,
128
+ "details": {
129
+ "foo":"bar"
130
+ }}'
131
+ @holodeck.mock Twilio::Response.new(400, @error_message)
132
+ expect {
133
+ @version.fetch('GET', 'http://foobar.com')
134
+ }.to raise_error { |error|
135
+ expect(error).to be_a(Twilio::REST::RestError)
136
+ expect(error.status_code).to eq(400)
137
+ expect(error.code).to eq(20_001)
138
+ expect(error.details).to eq({ 'foo' => 'bar' })
139
+ expect(error.error_message).to eq('Bad request')
140
+ expect(error.more_info).to eq('https://www.twilio.com/docs/errors/20001')
141
+ }
112
142
  end
113
143
  end
114
144
 
115
- class MyDomain < Twilio::REST::Domain
116
- def initialize(client)
117
- super
118
- @host = 'twilio.com'
119
- @base_url = 'https://twilio.com'
120
- @port = 443
145
+ describe '#build_uri' do
146
+ before(:all) do
147
+ Twilio.configure do |config|
148
+ config.account_sid = 'username'
149
+ config.auth_token = 'password'
150
+ config.region = nil
151
+ config.edge = nil
152
+ end
153
+ end
154
+
155
+ context 'no region or edge in url' do
156
+ it "doesn't set region or edge" do
157
+ @client = Twilio::REST::Client.new
158
+ expect(@client.build_uri('https://api.twilio.com')).to eq('https://api.twilio.com')
159
+ end
160
+
161
+ it 'uses the default region if edge set' do
162
+ @client = Twilio::REST::Client.new
163
+ @client.edge = 'edge'
164
+ expect(@client.build_uri('https://api.twilio.com')).to eq('https://api.edge.us1.twilio.com')
165
+ end
166
+
167
+ it 'sets region' do
168
+ @client = Twilio::REST::Client.new
169
+ @client.region = 'region'
170
+ expect(@client.build_uri('https://api.twilio.com')).to eq('https://api.region.twilio.com')
171
+ end
172
+
173
+ it 'sets region and edge' do
174
+ @client = Twilio::REST::Client.new
175
+ @client.region = 'region'
176
+ @client.edge = 'edge'
177
+ expect(@client.build_uri('https://api.twilio.com')).to eq('https://api.edge.region.twilio.com')
178
+ end
179
+ end
180
+
181
+ context 'region in url' do
182
+ it 'uses url region' do
183
+ @client = Twilio::REST::Client.new
184
+ expect(@client.build_uri('https://api.urlRegion.twilio.com')).to eq('https://api.urlRegion.twilio.com')
185
+ end
186
+
187
+ it 'uses client edge and url region' do
188
+ @client = Twilio::REST::Client.new
189
+ @client.edge = 'edge'
190
+ expect(@client.build_uri('https://api.urlRegion.twilio.com')).to eq('https://api.edge.urlRegion.twilio.com')
191
+ end
192
+
193
+ it 'prefers client region' do
194
+ @client = Twilio::REST::Client.new
195
+ @client.region = 'region'
196
+ expect(@client.build_uri('https://api.urlRegion.twilio.com')).to eq('https://api.region.twilio.com')
197
+ end
198
+
199
+ it 'uses client edge and prefers client region' do
200
+ @client = Twilio::REST::Client.new
201
+ @client.region = 'region'
202
+ @client.edge = 'edge'
203
+ expect(@client.build_uri('https://api.urlRegion.twilio.com')).to eq('https://api.edge.region.twilio.com')
204
+ end
205
+ end
206
+
207
+ context 'region and edge in url' do
208
+ it 'uses url region and edge' do
209
+ @client = Twilio::REST::Client.new
210
+ expect(@client.build_uri('https://api.urlEdge.urlRegion.twilio.com')).to eq('https://api.urlEdge.urlRegion.twilio.com')
211
+ end
212
+
213
+ it 'prefers client edge' do
214
+ @client = Twilio::REST::Client.new
215
+ @client.edge = 'edge'
216
+ expect(@client.build_uri('https://api.urlEdge.urlRegion.twilio.com')).to eq('https://api.edge.urlRegion.twilio.com')
217
+ end
218
+
219
+ it 'prefers client region' do
220
+ @client = Twilio::REST::Client.new
221
+ @client.region = 'region'
222
+ expect(@client.build_uri('https://api.urlEdge.urlRegion.twilio.com')).to eq('https://api.urlEdge.region.twilio.com')
223
+ end
224
+
225
+ it 'prefers client region and edge' do
226
+ @client = Twilio::REST::Client.new
227
+ @client.region = 'region'
228
+ @client.edge = 'edge'
229
+ expect(@client.build_uri('https://api.urlEdge.urlRegion.twilio.com')).to eq('https://api.edge.region.twilio.com')
230
+ end
121
231
  end
122
232
  end
123
233
  end