twilio-ruby 5.21.2 → 5.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +13 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +2 -6
  5. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +3 -1
  6. data/lib/twilio-ruby/rest/api/v2010/account/queue/member.rb +15 -9
  7. data/lib/twilio-ruby/rest/api/v2010/account/queue.rb +7 -0
  8. data/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list/credential.rb +5 -5
  9. data/lib/twilio-ruby/rest/lookups/v1/phone_number.rb +47 -43
  10. data/lib/twilio-ruby/rest/lookups/v1.rb +3 -1
  11. data/lib/twilio-ruby/rest/lookups.rb +3 -3
  12. data/lib/twilio-ruby/rest/messaging/v1/session/webhook.rb +448 -0
  13. data/lib/twilio-ruby/rest/messaging/v1/session.rb +26 -0
  14. data/lib/twilio-ruby/rest/messaging/v1/webhook.rb +15 -2
  15. data/lib/twilio-ruby/rest/pricing/v1/messaging/country.rb +11 -7
  16. data/lib/twilio-ruby/rest/pricing/v1/messaging.rb +3 -1
  17. data/lib/twilio-ruby/rest/pricing/v1/phone_number/country.rb +11 -7
  18. data/lib/twilio-ruby/rest/pricing/v1/phone_number.rb +3 -1
  19. data/lib/twilio-ruby/rest/pricing/v1/voice/country.rb +11 -7
  20. data/lib/twilio-ruby/rest/pricing/v1/voice/number.rb +8 -8
  21. data/lib/twilio-ruby/rest/pricing/v1/voice.rb +4 -2
  22. data/lib/twilio-ruby/rest/pricing/v2/voice/country.rb +11 -9
  23. data/lib/twilio-ruby/rest/pricing/v2/voice/number.rb +23 -13
  24. data/lib/twilio-ruby/rest/pricing/v2/voice.rb +10 -7
  25. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb +1 -1
  26. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +343 -0
  27. data/lib/twilio-ruby/rest/verify/v2/service/verification_check.rb +209 -0
  28. data/lib/twilio-ruby/rest/verify/v2/service.rb +507 -0
  29. data/lib/twilio-ruby/rest/verify/v2.rb +43 -0
  30. data/lib/twilio-ruby/rest/verify.rb +10 -3
  31. data/lib/twilio-ruby/rest/voice/v1/{voice_permission → dialing_permissions}/bulk_country_update.rb +1 -1
  32. data/lib/twilio-ruby/rest/voice/v1/{voice_permission → dialing_permissions}/country/highrisk_special_prefix.rb +1 -1
  33. data/lib/twilio-ruby/rest/voice/v1/{voice_permission → dialing_permissions}/country.rb +1 -1
  34. data/lib/twilio-ruby/rest/voice/v1/{voice_permission → dialing_permissions}/settings.rb +1 -1
  35. data/lib/twilio-ruby/rest/voice/v1/{voice_permission.rb → dialing_permissions.rb} +16 -16
  36. data/lib/twilio-ruby/rest/voice/v1.rb +4 -4
  37. data/lib/twilio-ruby/rest/voice.rb +3 -3
  38. data/lib/twilio-ruby/rest/wireless/v1/sim.rb +15 -2
  39. data/lib/twilio-ruby/version.rb +1 -1
  40. data/spec/integration/api/v2010/account/queue/member_spec.rb +50 -9
  41. data/spec/integration/api/v2010/account/queue_spec.rb +16 -10
  42. data/spec/integration/lookups/v1/phone_number_spec.rb +263 -2
  43. data/spec/integration/messaging/v1/session/webhook_spec.rb +300 -0
  44. data/spec/integration/messaging/v1/session_spec.rb +8 -4
  45. data/spec/integration/messaging/v1/webhook_spec.rb +2 -0
  46. data/spec/integration/verify/v2/service/verification_check_spec.rb +54 -0
  47. data/spec/integration/verify/v2/service/verification_spec.rb +169 -0
  48. data/spec/integration/verify/v2/service_spec.rb +231 -0
  49. data/spec/integration/voice/v1/{voice_permission → dialing_permissions}/bulk_country_update_spec.rb +2 -2
  50. data/spec/integration/voice/v1/{voice_permission → dialing_permissions}/country/highrisk_special_prefix_spec.rb +3 -3
  51. data/spec/integration/voice/v1/{voice_permission → dialing_permissions}/country_spec.rb +4 -4
  52. data/spec/integration/voice/v1/{voice_permission → dialing_permissions}/settings_spec.rb +4 -4
  53. data/spec/integration/voice/v1/{voice_permission_spec.rb → dialing_permissions_spec.rb} +1 -1
  54. data/spec/integration/wireless/v1/sim_spec.rb +3 -0
  55. metadata +31 -18
@@ -51,8 +51,8 @@ describe 'PhoneNumber' do
51
51
  "last_ported_date": "2018-05-01 04:05:11"
52
52
  },
53
53
  "country_code": "US",
54
- "national_format": "(510) 867-5309",
55
- "phone_number": "+15108675309",
54
+ "national_format": "(510) 867-5310",
55
+ "phone_number": "+15108675310",
56
56
  "add_ons": {
57
57
  "status": "successful",
58
58
  "message": null,
@@ -68,4 +68,265 @@ describe 'PhoneNumber' do
68
68
 
69
69
  expect(actual).to_not eq(nil)
70
70
  end
71
+
72
+ it "receives fetch_carrier responses" do
73
+ @holodeck.mock(Twilio::Response.new(
74
+ 200,
75
+ %q[
76
+ {
77
+ "caller_name": null,
78
+ "carrier": {
79
+ "error_code": null,
80
+ "mobile_country_code": "310",
81
+ "mobile_network_code": "456",
82
+ "name": "verizon",
83
+ "type": "mobile"
84
+ },
85
+ "country_code": "US",
86
+ "national_format": "(510) 867-5310",
87
+ "phone_number": "+15108675310",
88
+ "fraud": null,
89
+ "add_ons": null,
90
+ "url": "https://lookups.twilio.com/v1/PhoneNumbers/phone_number"
91
+ }
92
+ ]
93
+ ))
94
+
95
+ actual = @client.lookups.v1.phone_numbers('+15017122661').fetch()
96
+
97
+ expect(actual).to_not eq(nil)
98
+ end
99
+
100
+ it "receives fetch_caller_name responses" do
101
+ @holodeck.mock(Twilio::Response.new(
102
+ 200,
103
+ %q[
104
+ {
105
+ "caller_name": {
106
+ "caller_name": "Delicious Cheese Cake",
107
+ "caller_type": "CONSUMER",
108
+ "error_code": null
109
+ },
110
+ "carrier": null,
111
+ "fraud": null,
112
+ "country_code": "US",
113
+ "national_format": "(510) 867-5310",
114
+ "phone_number": "+15108675310",
115
+ "add_ons": null,
116
+ "url": "https://lookups.twilio.com/v1/PhoneNumbers/phone_number"
117
+ }
118
+ ]
119
+ ))
120
+
121
+ actual = @client.lookups.v1.phone_numbers('+15017122661').fetch()
122
+
123
+ expect(actual).to_not eq(nil)
124
+ end
125
+
126
+ it "receives fetch_carrier_and_caller_name responses" do
127
+ @holodeck.mock(Twilio::Response.new(
128
+ 200,
129
+ %q[
130
+ {
131
+ "caller_name": {
132
+ "caller_name": "Delicious Cheese Cake",
133
+ "caller_type": "CONSUMER",
134
+ "error_code": null
135
+ },
136
+ "carrier": {
137
+ "error_code": null,
138
+ "mobile_country_code": "310",
139
+ "mobile_network_code": "456",
140
+ "name": "verizon",
141
+ "type": "mobile"
142
+ },
143
+ "fraud": null,
144
+ "country_code": "US",
145
+ "national_format": "(510) 867-5310",
146
+ "phone_number": "+15108675310",
147
+ "add_ons": {
148
+ "status": "successful",
149
+ "message": null,
150
+ "code": null,
151
+ "results": {}
152
+ },
153
+ "url": "https://lookups.twilio.com/v1/PhoneNumbers/+15108675310"
154
+ }
155
+ ]
156
+ ))
157
+
158
+ actual = @client.lookups.v1.phone_numbers('+15017122661').fetch()
159
+
160
+ expect(actual).to_not eq(nil)
161
+ end
162
+
163
+ it "receives fetch_addons_whitepages_pro responses" do
164
+ @holodeck.mock(Twilio::Response.new(
165
+ 200,
166
+ %q[
167
+ {
168
+ "caller_name": {
169
+ "caller_name": "EMPIRE STATE BUILDING",
170
+ "caller_type": "BUSINESS",
171
+ "error_code": null
172
+ },
173
+ "country_code": "US",
174
+ "phone_number": "+12127363100",
175
+ "national_format": "(212) 736-3100",
176
+ "carrier": null,
177
+ "fraud": null,
178
+ "add_ons": {
179
+ "status": "successful",
180
+ "message": null,
181
+ "code": null,
182
+ "results": {
183
+ "whitepages_pro_caller_id": {
184
+ "status": "successful",
185
+ "request_sid": "XR28b8f152ae12345605b0b3cc34123456",
186
+ "message": null,
187
+ "code": null,
188
+ "result": {
189
+ "phone_number": "2127363100",
190
+ "warnings": [],
191
+ "historical_addresses": [],
192
+ "alternate_phones": [],
193
+ "error": null,
194
+ "is_commercial": true,
195
+ "associated_people": [],
196
+ "country_calling_code": "1",
197
+ "belongs_to": [],
198
+ "is_valid": true,
199
+ "line_type": "NonFixedVOIP",
200
+ "carrier": "Level 3 Communications",
201
+ "current_addresses": [
202
+ {
203
+ "city": "New York",
204
+ "lat_long": {
205
+ "latitude": 40.748731,
206
+ "longitude": -73.986413,
207
+ "accuracy": "RoofTop"
208
+ },
209
+ "is_active": null,
210
+ "location_type": "Address",
211
+ "street_line_2": null,
212
+ "link_to_person_start_date": "2018-08-28",
213
+ "street_line_1": "350 5th Ave",
214
+ "postal_code": "10118",
215
+ "delivery_point": "MultiUnit",
216
+ "country_code": "US",
217
+ "state_code": "NY",
218
+ "id": "Location.4e81b857-1234-5678-31d29a3301e1",
219
+ "zip4": "0110"
220
+ }
221
+ ],
222
+ "id": "Phone.f8396fef-1234-5678-bc7128b6fd99",
223
+ "is_prepaid": false
224
+ }
225
+ }
226
+ }
227
+ },
228
+ "url": "https://lookups.twilio.com/v1/PhoneNumbers/+12127363100?Type=carrier"
229
+ }
230
+ ]
231
+ ))
232
+
233
+ actual = @client.lookups.v1.phone_numbers('+15017122661').fetch()
234
+
235
+ expect(actual).to_not eq(nil)
236
+ end
237
+
238
+ it "receives fetch_addons_nomorobo responses" do
239
+ @holodeck.mock(Twilio::Response.new(
240
+ 200,
241
+ %q[
242
+ {
243
+ "caller_name": null,
244
+ "country_code": "US",
245
+ "phone_number": "+19892008374",
246
+ "national_format": "(989) 200-8374",
247
+ "carrier": {
248
+ "mobile_country_code": "310",
249
+ "mobile_network_code": null,
250
+ "name": "Ytel/Blitz",
251
+ "type": "mobile",
252
+ "error_code": null
253
+ },
254
+ "fraud": null,
255
+ "add_ons": {
256
+ "status": "successful",
257
+ "message": null,
258
+ "code": null,
259
+ "results": {
260
+ "nomorobo_spamscore": {
261
+ "status": "successful",
262
+ "request_sid": "XR763c8acc4c56d5e3e18d2f0f12345bc1",
263
+ "message": null,
264
+ "code": null,
265
+ "result": {
266
+ "status": "success",
267
+ "message": "success",
268
+ "score": 1
269
+ }
270
+ }
271
+ }
272
+ },
273
+ "url": "https://lookups.twilio.com/v1/PhoneNumbers/+19892008374?Type=carrier"
274
+ }
275
+ ]
276
+ ))
277
+
278
+ actual = @client.lookups.v1.phone_numbers('+15017122661').fetch()
279
+
280
+ expect(actual).to_not eq(nil)
281
+ end
282
+
283
+ it "receives fetch_addons_payfone responses" do
284
+ @holodeck.mock(Twilio::Response.new(
285
+ 200,
286
+ %q[
287
+ {
288
+ "caller_name": null,
289
+ "country_code": "US",
290
+ "phone_number": "+16502530000",
291
+ "national_format": "(650) 253-0000",
292
+ "carrier": {
293
+ "mobile_country_code": null,
294
+ "mobile_network_code": null,
295
+ "name": "Level 3 Communications, LLC",
296
+ "type": "landline",
297
+ "error_code": null
298
+ },
299
+ "fraud": null,
300
+ "add_ons": {
301
+ "status": "successful",
302
+ "message": null,
303
+ "code": null,
304
+ "results": {
305
+ "payfone_tcpa_compliance": {
306
+ "status": "successful",
307
+ "request_sid": "XRd3a2991c9108bde3ca9589ed84d31463",
308
+ "message": null,
309
+ "code": null,
310
+ "result": {
311
+ "Status": 0,
312
+ "Response": {
313
+ "MSISDNType": "NonFixedVoIP",
314
+ "NumberMatch": "I",
315
+ "VerifyNumberTransactionId": "2019459819"
316
+ },
317
+ "RequestId": "XRd3a2991c9108bde3ca9589ed84d31463",
318
+ "Description": "Success."
319
+ }
320
+ }
321
+ }
322
+ },
323
+ "url": "https://lookups.twilio.com/v1/PhoneNumbers/+16502530000?Type=carrier"
324
+ }
325
+ ]
326
+ ))
327
+
328
+ actual = @client.lookups.v1.phone_numbers('+15017122661').fetch()
329
+
330
+ expect(actual).to_not eq(nil)
331
+ end
71
332
  end
@@ -0,0 +1,300 @@
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 'Webhook' do
12
+ it "can read" do
13
+ @holodeck.mock(Twilio::Response.new(500, ''))
14
+
15
+ expect {
16
+ @client.messaging.v1.sessions('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
17
+ .webhooks.list()
18
+ }.to raise_exception(Twilio::REST::TwilioError)
19
+
20
+ values = {}
21
+ expect(
22
+ @holodeck.has_request?(Holodeck::Request.new(
23
+ method: 'get',
24
+ url: 'https://messaging.twilio.com/v1/Sessions/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Webhooks',
25
+ ))).to eq(true)
26
+ end
27
+
28
+ it "receives read_full responses" do
29
+ @holodeck.mock(Twilio::Response.new(
30
+ 200,
31
+ %q[
32
+ {
33
+ "meta": {
34
+ "page": 0,
35
+ "page_size": 5,
36
+ "first_page_url": "https://messaging.twilio.com/v1/Sessions/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks?PageSize=5&Page=0",
37
+ "previous_page_url": null,
38
+ "url": "https://messaging.twilio.com/v1/Sessions/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks?PageSize=5&Page=0",
39
+ "next_page_url": null,
40
+ "key": "webhooks"
41
+ },
42
+ "webhooks": [
43
+ {
44
+ "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
45
+ "session_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
46
+ "sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
47
+ "target": "webhook",
48
+ "configuration": {
49
+ "url": "dummy",
50
+ "method": "get",
51
+ "filters": [
52
+ "onMessageSent",
53
+ "onSessionDestroyed"
54
+ ],
55
+ "retry_count": 2,
56
+ "buffer_messages": false
57
+ },
58
+ "date_created": "2016-03-24T21:05:50Z",
59
+ "date_updated": "2016-03-24T21:05:50Z",
60
+ "url": "https://messaging.twilio.com/v1/Sessions/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
61
+ },
62
+ {
63
+ "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
64
+ "session_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
65
+ "sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
66
+ "target": "trigger",
67
+ "configuration": {
68
+ "url": "dummy",
69
+ "method": "post",
70
+ "filters": [
71
+ "keyword1",
72
+ "keyword2"
73
+ ],
74
+ "retry_count": 3,
75
+ "buffer_messages": true,
76
+ "buffer_window": 3000
77
+ },
78
+ "date_created": "2016-03-24T21:05:50Z",
79
+ "date_updated": "2016-03-24T21:05:50Z",
80
+ "url": "https://messaging.twilio.com/v1/Sessions/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
81
+ },
82
+ {
83
+ "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
84
+ "session_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
85
+ "sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
86
+ "target": "studio",
87
+ "configuration": {
88
+ "flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
89
+ "buffer_messages": false,
90
+ "buffer_window": 4000
91
+ },
92
+ "date_created": "2016-03-24T21:05:50Z",
93
+ "date_updated": "2016-03-24T21:05:50Z",
94
+ "url": "https://messaging.twilio.com/v1/Sessions/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
95
+ }
96
+ ]
97
+ }
98
+ ]
99
+ ))
100
+
101
+ actual = @client.messaging.v1.sessions('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
102
+ .webhooks.list()
103
+
104
+ expect(actual).to_not eq(nil)
105
+ end
106
+
107
+ it "receives read_empty responses" do
108
+ @holodeck.mock(Twilio::Response.new(
109
+ 200,
110
+ %q[
111
+ {
112
+ "meta": {
113
+ "page": 0,
114
+ "page_size": 5,
115
+ "first_page_url": "https://messaging.twilio.com/v1/Sessions/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks?PageSize=5&Page=0",
116
+ "url": "https://messaging.twilio.com/v1/Sessions/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks?PageSize=5&Page=0",
117
+ "previous_page_url": null,
118
+ "next_page_url": null,
119
+ "key": "webhooks"
120
+ },
121
+ "webhooks": []
122
+ }
123
+ ]
124
+ ))
125
+
126
+ actual = @client.messaging.v1.sessions('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
127
+ .webhooks.list()
128
+
129
+ expect(actual).to_not eq(nil)
130
+ end
131
+
132
+ it "can fetch" do
133
+ @holodeck.mock(Twilio::Response.new(500, ''))
134
+
135
+ expect {
136
+ @client.messaging.v1.sessions('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
137
+ .webhooks('WHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch()
138
+ }.to raise_exception(Twilio::REST::TwilioError)
139
+
140
+ values = {}
141
+ expect(
142
+ @holodeck.has_request?(Holodeck::Request.new(
143
+ method: 'get',
144
+ url: 'https://messaging.twilio.com/v1/Sessions/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Webhooks/WHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
145
+ ))).to eq(true)
146
+ end
147
+
148
+ it "receives fetch responses" do
149
+ @holodeck.mock(Twilio::Response.new(
150
+ 200,
151
+ %q[
152
+ {
153
+ "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
154
+ "session_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
155
+ "sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
156
+ "target": "studio",
157
+ "configuration": {
158
+ "flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
159
+ "buffer_messages": false
160
+ },
161
+ "date_created": "2016-03-24T21:05:50Z",
162
+ "date_updated": "2016-03-24T21:05:50Z",
163
+ "url": "https://messaging.twilio.com/v1/Sessions/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
164
+ }
165
+ ]
166
+ ))
167
+
168
+ actual = @client.messaging.v1.sessions('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
169
+ .webhooks('WHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch()
170
+
171
+ expect(actual).to_not eq(nil)
172
+ end
173
+
174
+ it "can create" do
175
+ @holodeck.mock(Twilio::Response.new(500, ''))
176
+
177
+ expect {
178
+ @client.messaging.v1.sessions('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
179
+ .webhooks.create(target: 'webhook')
180
+ }.to raise_exception(Twilio::REST::TwilioError)
181
+
182
+ values = {'Target' => 'webhook', }
183
+ expect(
184
+ @holodeck.has_request?(Holodeck::Request.new(
185
+ method: 'post',
186
+ url: 'https://messaging.twilio.com/v1/Sessions/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Webhooks',
187
+ data: values,
188
+ ))).to eq(true)
189
+ end
190
+
191
+ it "receives create responses" do
192
+ @holodeck.mock(Twilio::Response.new(
193
+ 201,
194
+ %q[
195
+ {
196
+ "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
197
+ "session_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
198
+ "sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
199
+ "target": "webhook",
200
+ "configuration": {
201
+ "url": "dummy",
202
+ "method": "get",
203
+ "filters": [
204
+ "onMessageSent",
205
+ "onSessionDestroyed"
206
+ ],
207
+ "retry_count": 2,
208
+ "buffer_messages": true,
209
+ "buffer_window": 3000
210
+ },
211
+ "date_created": "2016-03-24T21:05:50Z",
212
+ "date_updated": "2016-03-24T21:05:50Z",
213
+ "url": "https://messaging.twilio.com/v1/Sessions/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
214
+ }
215
+ ]
216
+ ))
217
+
218
+ actual = @client.messaging.v1.sessions('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
219
+ .webhooks.create(target: 'webhook')
220
+
221
+ expect(actual).to_not eq(nil)
222
+ end
223
+
224
+ it "can update" do
225
+ @holodeck.mock(Twilio::Response.new(500, ''))
226
+
227
+ expect {
228
+ @client.messaging.v1.sessions('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
229
+ .webhooks('WHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update()
230
+ }.to raise_exception(Twilio::REST::TwilioError)
231
+
232
+ values = {}
233
+ expect(
234
+ @holodeck.has_request?(Holodeck::Request.new(
235
+ method: 'post',
236
+ url: 'https://messaging.twilio.com/v1/Sessions/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Webhooks/WHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
237
+ ))).to eq(true)
238
+ end
239
+
240
+ it "receives update responses" do
241
+ @holodeck.mock(Twilio::Response.new(
242
+ 200,
243
+ %q[
244
+ {
245
+ "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
246
+ "session_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
247
+ "sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
248
+ "target": "trigger",
249
+ "configuration": {
250
+ "url": "dummy",
251
+ "method": "post",
252
+ "filters": [
253
+ "keyword1",
254
+ "keyword2"
255
+ ],
256
+ "retry_count": 3,
257
+ "buffer_messages": true,
258
+ "buffer_window": 5000
259
+ },
260
+ "date_created": "2016-03-24T21:05:50Z",
261
+ "date_updated": "2016-03-24T21:05:51Z",
262
+ "url": "https://messaging.twilio.com/v1/Sessions/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
263
+ }
264
+ ]
265
+ ))
266
+
267
+ actual = @client.messaging.v1.sessions('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
268
+ .webhooks('WHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update()
269
+
270
+ expect(actual).to_not eq(nil)
271
+ end
272
+
273
+ it "can delete" do
274
+ @holodeck.mock(Twilio::Response.new(500, ''))
275
+
276
+ expect {
277
+ @client.messaging.v1.sessions('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
278
+ .webhooks('WHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete()
279
+ }.to raise_exception(Twilio::REST::TwilioError)
280
+
281
+ values = {}
282
+ expect(
283
+ @holodeck.has_request?(Holodeck::Request.new(
284
+ method: 'delete',
285
+ url: 'https://messaging.twilio.com/v1/Sessions/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Webhooks/WHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
286
+ ))).to eq(true)
287
+ end
288
+
289
+ it "receives delete responses" do
290
+ @holodeck.mock(Twilio::Response.new(
291
+ 204,
292
+ nil,
293
+ ))
294
+
295
+ actual = @client.messaging.v1.sessions('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
296
+ .webhooks('WHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete()
297
+
298
+ expect(actual).to eq(true)
299
+ end
300
+ end