twilio-ruby 5.3.1 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +17 -0
  3. data/README.md +2 -2
  4. data/lib/rack/twilio_webhook_authentication.rb +46 -0
  5. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb +10 -1
  6. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb +10 -1
  7. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb +10 -1
  8. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb +22 -3
  9. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +3 -1
  10. data/lib/twilio-ruby/rest/client.rb +7 -0
  11. data/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document.rb +417 -0
  12. data/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb +8 -7
  13. data/lib/twilio-ruby/rest/preview/hosted_numbers.rb +16 -0
  14. data/lib/twilio-ruby/rest/preview.rb +9 -0
  15. data/lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb +384 -0
  16. data/lib/twilio-ruby/rest/proxy/v1/service/session/interaction.rb +456 -0
  17. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant/message_interaction.rb +465 -0
  18. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +541 -0
  19. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +578 -0
  20. data/lib/twilio-ruby/rest/proxy/v1/service/short_code.rb +377 -0
  21. data/lib/twilio-ruby/rest/proxy/v1/service.rb +509 -0
  22. data/lib/twilio-ruby/rest/proxy/v1.rb +41 -0
  23. data/lib/twilio-ruby/rest/proxy.rb +44 -0
  24. data/lib/twilio-ruby/rest/wireless/v1/sim.rb +7 -0
  25. data/lib/twilio-ruby/security/request_validator.rb +1 -1
  26. data/lib/twilio-ruby/twiml/messaging_response.rb +5 -5
  27. data/lib/twilio-ruby/twiml/voice_response.rb +9 -7
  28. data/lib/twilio-ruby/util/configuration.rb +0 -3
  29. data/lib/twilio-ruby/version.rb +1 -1
  30. data/lib/twilio-ruby.rb +1 -0
  31. data/spec/integration/api/v2010/account/incoming_phone_number/local_spec.rb +2 -0
  32. data/spec/integration/api/v2010/account/incoming_phone_number/mobile_spec.rb +2 -0
  33. data/spec/integration/api/v2010/account/incoming_phone_number/toll_free_spec.rb +2 -0
  34. data/spec/integration/api/v2010/account/incoming_phone_number_spec.rb +4 -0
  35. data/spec/integration/preview/hosted_numbers/authorization_document_spec.rb +211 -0
  36. data/spec/integration/preview/hosted_numbers/hosted_number_order_spec.rb +35 -4
  37. data/spec/integration/proxy/v1/service/phone_number_spec.rb +176 -0
  38. data/spec/integration/proxy/v1/service/session/interaction_spec.rb +104 -0
  39. data/spec/integration/proxy/v1/service/session/participant/message_interaction_spec.rb +164 -0
  40. data/spec/integration/proxy/v1/service/session/participant_spec.rb +232 -0
  41. data/spec/integration/proxy/v1/service/session_spec.rb +225 -0
  42. data/spec/integration/proxy/v1/service/short_code_spec.rb +173 -0
  43. data/spec/integration/proxy/v1/service_spec.rb +200 -0
  44. data/spec/integration/wireless/v1/sim_spec.rb +6 -3
  45. data/spec/rack/twilio_webhook_authentication_spec.rb +106 -0
  46. data/spec/security/request_validator_spec.rb +28 -0
  47. data/spec/twiml/messaging_response_spec.rb +6 -6
  48. metadata +31 -2
@@ -0,0 +1,41 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Proxy
10
+ class V1 < Version
11
+ ##
12
+ # Initialize the V1 version of Proxy
13
+ def initialize(domain)
14
+ super
15
+ @version = 'v1'
16
+ @services = nil
17
+ end
18
+
19
+ ##
20
+ # @param [String] sid A 34 character string that uniquely identifies this Service.
21
+ # @return [Twilio::REST::Proxy::V1::ServiceInstance] if sid was passed.
22
+ # @return [Twilio::REST::Proxy::V1::ServiceList]
23
+ def services(sid=:unset)
24
+ if sid.nil?
25
+ raise ArgumentError, 'sid cannot be nil'
26
+ elsif sid == :unset
27
+ @services ||= ServiceList.new self
28
+ else
29
+ ServiceContext.new(self, sid)
30
+ end
31
+ end
32
+
33
+ ##
34
+ # Provide a user friendly representation
35
+ def to_s
36
+ '<Twilio::REST::Proxy::V1>'
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,44 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Proxy < Domain
10
+ ##
11
+ # Initialize the Proxy Domain
12
+ def initialize(twilio)
13
+ super
14
+
15
+ @base_url = 'https://proxy.twilio.com'
16
+ @host = 'proxy.twilio.com'
17
+ @port = 443
18
+
19
+ # Versions
20
+ @v1 = nil
21
+ end
22
+
23
+ ##
24
+ # Version v1 of proxy
25
+ def v1
26
+ @v1 ||= V1.new self
27
+ end
28
+
29
+ ##
30
+ # @param [String] sid A 34 character string that uniquely identifies this Service.
31
+ # @return [Twilio::REST::Proxy::V1::ServiceInstance] if sid was passed.
32
+ # @return [Twilio::REST::Proxy::V1::ServiceList]
33
+ def services(sid=:unset)
34
+ self.v1.services(sid)
35
+ end
36
+
37
+ ##
38
+ # Provide a user friendly representation
39
+ def to_s
40
+ '#<Twilio::REST::Proxy>'
41
+ end
42
+ end
43
+ end
44
+ end
@@ -350,6 +350,7 @@ module Twilio
350
350
  'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
351
351
  'url' => payload['url'],
352
352
  'links' => payload['links'],
353
+ 'ip_address' => payload['ip_address'],
353
354
  }
354
355
 
355
356
  # Context
@@ -505,6 +506,12 @@ module Twilio
505
506
  @properties['links']
506
507
  end
507
508
 
509
+ ##
510
+ # @return [String] The ip_address
511
+ def ip_address
512
+ @properties['ip_address']
513
+ end
514
+
508
515
  ##
509
516
  # Fetch a SimInstance
510
517
  # @return [SimInstance] Fetched SimInstance
@@ -2,7 +2,7 @@ module Twilio
2
2
  module Security
3
3
  class RequestValidator
4
4
  def initialize(auth_token = nil)
5
- @auth_token = auth_token
5
+ @auth_token = auth_token || Twilio.auth_token
6
6
  raise ArgumentError, 'Auth token is required' if @auth_token.nil?
7
7
  end
8
8
 
@@ -18,14 +18,14 @@ module Twilio
18
18
 
19
19
  ##
20
20
  # Create a new <Message> element
21
- # message:: Message Body
21
+ # body:: Message Body
22
22
  # to:: Phone Number to send Message to
23
23
  # from:: Phone Number to send Message from
24
24
  # action:: Action URL
25
25
  # method:: Action URL Method
26
26
  # keyword_args:: additional attributes
27
- def message(message: nil, to: nil, from: nil, action: nil, method: nil, **keyword_args)
28
- message = Message.new(message: message, to: to, from: from, action: action, method: method, **keyword_args)
27
+ def message(body: nil, to: nil, from: nil, action: nil, method: nil, **keyword_args)
28
+ message = Message.new(body: body, to: to, from: from, action: action, method: method, **keyword_args)
29
29
 
30
30
  yield(message) if block_given?
31
31
  append(message)
@@ -55,10 +55,10 @@ module Twilio
55
55
  ##
56
56
  # <Message> TwiML Verb
57
57
  class Message < TwiML
58
- def initialize(message: nil, **keyword_args)
58
+ def initialize(body: nil, **keyword_args)
59
59
  super(**keyword_args)
60
60
  @name = 'Message'
61
- @value = message unless message.nil?
61
+ @value = body unless body.nil?
62
62
  yield(self) if block_given?
63
63
  end
64
64
 
@@ -29,9 +29,11 @@ module Twilio
29
29
  # trim:: Trim the recording
30
30
  # recording_status_callback:: Recording status callback URL
31
31
  # recording_status_callback_method:: Recording status callback URL method
32
+ # answer_on_bridge:: Preserve the ringing behavior of the inbound call until the Dialed call picks up
33
+ # ring_tone:: Ringtone allows you to override the ringback tone that Twilio will play back to the caller while executing the Dial
32
34
  # keyword_args:: additional attributes
33
- def dial(number: nil, action: nil, method: nil, timeout: nil, hangup_on_star: nil, time_limit: nil, caller_id: nil, record: nil, trim: nil, recording_status_callback: nil, recording_status_callback_method: nil, **keyword_args)
34
- dial = Dial.new(number: number, action: action, method: method, timeout: timeout, hangup_on_star: hangup_on_star, time_limit: time_limit, caller_id: caller_id, record: record, trim: trim, recording_status_callback: recording_status_callback, recording_status_callback_method: recording_status_callback_method, **keyword_args)
35
+ def dial(number: nil, action: nil, method: nil, timeout: nil, hangup_on_star: nil, time_limit: nil, caller_id: nil, record: nil, trim: nil, recording_status_callback: nil, recording_status_callback_method: nil, answer_on_bridge: nil, ring_tone: nil, **keyword_args)
36
+ dial = Dial.new(number: number, action: action, method: method, timeout: timeout, hangup_on_star: hangup_on_star, time_limit: time_limit, caller_id: caller_id, record: record, trim: trim, recording_status_callback: recording_status_callback, recording_status_callback_method: recording_status_callback_method, answer_on_bridge: answer_on_bridge, ring_tone: ring_tone, **keyword_args)
35
37
 
36
38
  yield(dial) if block_given?
37
39
  append(dial)
@@ -429,7 +431,7 @@ module Twilio
429
431
 
430
432
  ##
431
433
  # Create a new <Number> element
432
- # number:: Phone Number to dial
434
+ # phone_number:: Phone Number to dial
433
435
  # send_digits:: DTMF tones to play when the call is answered
434
436
  # url:: TwiML URL
435
437
  # method:: TwiML URL method
@@ -437,8 +439,8 @@ module Twilio
437
439
  # status_callback:: Status callback URL
438
440
  # status_callback_method:: Status callback URL method
439
441
  # keyword_args:: additional attributes
440
- def number(number, send_digits: nil, url: nil, method: nil, status_callback_event: nil, status_callback: nil, status_callback_method: nil, **keyword_args)
441
- append(Number.new(number, send_digits: send_digits, url: url, method: method, status_callback_event: status_callback_event, status_callback: status_callback, status_callback_method: status_callback_method, **keyword_args))
442
+ def number(phone_number, send_digits: nil, url: nil, method: nil, status_callback_event: nil, status_callback: nil, status_callback_method: nil, **keyword_args)
443
+ append(Number.new(phone_number, send_digits: send_digits, url: url, method: method, status_callback_event: status_callback_event, status_callback: status_callback, status_callback_method: status_callback_method, **keyword_args))
442
444
  end
443
445
 
444
446
  ##
@@ -502,10 +504,10 @@ module Twilio
502
504
  ##
503
505
  # <Number> TwiML Noun
504
506
  class Number < TwiML
505
- def initialize(number, **keyword_args)
507
+ def initialize(phone_number, **keyword_args)
506
508
  super(**keyword_args)
507
509
  @name = 'Number'
508
- @value = number
510
+ @value = phone_number
509
511
  yield(self) if block_given?
510
512
  end
511
513
  end
@@ -2,14 +2,11 @@ module Twilio
2
2
  module Util
3
3
  class Configuration
4
4
  attr_accessor :account_sid, :auth_token
5
-
6
5
  def account_sid=value
7
- warn "'Twilio::Util::Configuration.account_sid' has been deprecated. Please do not use the configure block."
8
6
  @account_sid=value
9
7
  end
10
8
 
11
9
  def auth_token=value
12
- warn "'Twilio::Util::Configuration.auth_token' has been deprecated. Please do not use the configure block."
13
10
  @auth_token=value
14
11
  end
15
12
  end
@@ -1,3 +1,3 @@
1
1
  module Twilio
2
- VERSION = '5.3.1'
2
+ VERSION = '5.4.0'
3
3
  end
data/lib/twilio-ruby.rb CHANGED
@@ -10,6 +10,7 @@ require 'time'
10
10
  require 'json'
11
11
 
12
12
  require 'twilio-ruby/version' unless defined?(Twilio::VERSION)
13
+ require 'rack/twilio_webhook_authentication'
13
14
 
14
15
  require 'twilio-ruby/util'
15
16
  require 'twilio-ruby/jwt/jwt'
@@ -45,6 +45,7 @@ describe 'Local' do
45
45
  "date_created": "Thu, 30 Jul 2015 23:19:04 +0000",
46
46
  "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000",
47
47
  "friendly_name": "(808) 925-5327",
48
+ "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
48
49
  "phone_number": "+18089255327",
49
50
  "origin": "origin",
50
51
  "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
@@ -150,6 +151,7 @@ describe 'Local' do
150
151
  "date_created": "Thu, 30 Jul 2015 23:19:04 +0000",
151
152
  "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000",
152
153
  "friendly_name": "(808) 925-5327",
154
+ "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
153
155
  "phone_number": "+18089255327",
154
156
  "origin": "origin",
155
157
  "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
@@ -45,6 +45,7 @@ describe 'Mobile' do
45
45
  "date_created": "Tue, 08 Sep 2015 16:21:16 +0000",
46
46
  "date_updated": "Tue, 08 Sep 2015 16:21:16 +0000",
47
47
  "friendly_name": "61429099450",
48
+ "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
48
49
  "phone_number": "+61429099450",
49
50
  "origin": "origin",
50
51
  "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
@@ -149,6 +150,7 @@ describe 'Mobile' do
149
150
  },
150
151
  "date_created": "Thu, 30 Jul 2015 23:19:04 +0000",
151
152
  "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000",
153
+ "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
152
154
  "friendly_name": "(808) 925-5327",
153
155
  "phone_number": "+18089255327",
154
156
  "origin": "origin",
@@ -45,6 +45,7 @@ describe 'TollFree' do
45
45
  "date_created": "Thu, 30 Jul 2015 23:19:04 +0000",
46
46
  "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000",
47
47
  "friendly_name": "(808) 925-5327",
48
+ "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
48
49
  "phone_number": "+18089255327",
49
50
  "origin": "origin",
50
51
  "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
@@ -150,6 +151,7 @@ describe 'TollFree' do
150
151
  "date_created": "Thu, 30 Jul 2015 23:19:04 +0000",
151
152
  "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000",
152
153
  "friendly_name": "(808) 925-5327",
154
+ "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
153
155
  "phone_number": "+18089255327",
154
156
  "origin": "origin",
155
157
  "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
@@ -42,6 +42,7 @@ describe 'IncomingPhoneNumber' do
42
42
  "emergency_status": "Inactive",
43
43
  "emergency_address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
44
44
  "friendly_name": "(808) 925-5327",
45
+ "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
45
46
  "origin": "origin",
46
47
  "phone_number": "+18089255327",
47
48
  "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
@@ -105,6 +106,7 @@ describe 'IncomingPhoneNumber' do
105
106
  "emergency_status": "Active",
106
107
  "emergency_address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
107
108
  "friendly_name": "(808) 925-5327",
109
+ "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
108
110
  "origin": "origin",
109
111
  "phone_number": "+18089255327",
110
112
  "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
@@ -200,6 +202,7 @@ describe 'IncomingPhoneNumber' do
200
202
  "emergency_status": "Active",
201
203
  "emergency_address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
202
204
  "friendly_name": "(808) 925-5327",
205
+ "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
203
206
  "origin": "origin",
204
207
  "phone_number": "+18089255327",
205
208
  "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
@@ -301,6 +304,7 @@ describe 'IncomingPhoneNumber' do
301
304
  "emergency_status": "Active",
302
305
  "emergency_address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
303
306
  "friendly_name": "(808) 925-5327",
307
+ "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
304
308
  "origin": "origin",
305
309
  "phone_number": "+18089255327",
306
310
  "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
@@ -0,0 +1,211 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ require 'spec_helper.rb'
8
+
9
+ describe 'AuthorizationDocument' do
10
+ it "can fetch" do
11
+ @holodeck.mock(Twilio::Response.new(500, ''))
12
+
13
+ expect {
14
+ @client.preview.hosted_numbers.authorization_documents("PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch()
15
+ }.to raise_exception(Twilio::REST::TwilioError)
16
+
17
+ values = {}
18
+ expect(
19
+ @holodeck.has_request?(Holodeck::Request.new(
20
+ method: 'get',
21
+ url: 'https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
22
+ ))).to eq(true)
23
+ end
24
+
25
+ it "receives fetch responses" do
26
+ @holodeck.mock(Twilio::Response.new(
27
+ 200,
28
+ %q[
29
+ {
30
+ "address_sid": "AD11111111111111111111111111111111",
31
+ "cc_emails": [
32
+ "aaa@twilio.com",
33
+ "bbb@twilio.com"
34
+ ],
35
+ "date_created": "2017-03-28T20:06:39Z",
36
+ "date_updated": "2017-03-28T20:06:39Z",
37
+ "email": "test@twilio.com",
38
+ "sid": "PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
39
+ "status": "signing",
40
+ "url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
41
+ }
42
+ ]
43
+ ))
44
+
45
+ actual = @client.preview.hosted_numbers.authorization_documents("PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch()
46
+
47
+ expect(actual).to_not eq(nil)
48
+ end
49
+
50
+ it "can update" do
51
+ @holodeck.mock(Twilio::Response.new(500, ''))
52
+
53
+ expect {
54
+ @client.preview.hosted_numbers.authorization_documents("PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update()
55
+ }.to raise_exception(Twilio::REST::TwilioError)
56
+
57
+ values = {}
58
+ expect(
59
+ @holodeck.has_request?(Holodeck::Request.new(
60
+ method: 'post',
61
+ url: 'https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
62
+ ))).to eq(true)
63
+ end
64
+
65
+ it "receives update responses" do
66
+ @holodeck.mock(Twilio::Response.new(
67
+ 200,
68
+ %q[
69
+ {
70
+ "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
71
+ "cc_emails": [
72
+ "test1@twilio.com",
73
+ "test2@twilio.com"
74
+ ],
75
+ "date_created": "2017-03-28T20:06:39Z",
76
+ "date_updated": "2017-03-28T20:06:39Z",
77
+ "email": "test+hosted@twilio.com",
78
+ "sid": "PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
79
+ "status": "signing",
80
+ "url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
81
+ }
82
+ ]
83
+ ))
84
+
85
+ actual = @client.preview.hosted_numbers.authorization_documents("PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update()
86
+
87
+ expect(actual).to_not eq(nil)
88
+ end
89
+
90
+ it "can read" do
91
+ @holodeck.mock(Twilio::Response.new(500, ''))
92
+
93
+ expect {
94
+ @client.preview.hosted_numbers.authorization_documents.list()
95
+ }.to raise_exception(Twilio::REST::TwilioError)
96
+
97
+ values = {}
98
+ expect(
99
+ @holodeck.has_request?(Holodeck::Request.new(
100
+ method: 'get',
101
+ url: 'https://preview.twilio.com/HostedNumbers/AuthorizationDocuments',
102
+ ))).to eq(true)
103
+ end
104
+
105
+ it "receives read_empty responses" do
106
+ @holodeck.mock(Twilio::Response.new(
107
+ 200,
108
+ %q[
109
+ {
110
+ "meta": {
111
+ "first_page_url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments?PageSize=50&Page=0",
112
+ "key": "items",
113
+ "next_page_url": null,
114
+ "page": 0,
115
+ "page_size": 50,
116
+ "previous_page_url": null,
117
+ "url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments?PageSize=50&Page=0"
118
+ },
119
+ "items": []
120
+ }
121
+ ]
122
+ ))
123
+
124
+ actual = @client.preview.hosted_numbers.authorization_documents.list()
125
+
126
+ expect(actual).to_not eq(nil)
127
+ end
128
+
129
+ it "receives read_full responses" do
130
+ @holodeck.mock(Twilio::Response.new(
131
+ 200,
132
+ %q[
133
+ {
134
+ "meta": {
135
+ "first_page_url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments?PageSize=50&Page=0",
136
+ "key": "items",
137
+ "next_page_url": null,
138
+ "page": 0,
139
+ "page_size": 50,
140
+ "previous_page_url": null,
141
+ "url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments?PageSize=50&Page=0"
142
+ },
143
+ "items": [
144
+ {
145
+ "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
146
+ "cc_emails": [
147
+ "test1@twilio.com",
148
+ "test2@twilio.com"
149
+ ],
150
+ "date_created": "2017-03-28T20:06:39Z",
151
+ "date_updated": "2017-03-28T20:06:39Z",
152
+ "email": "test+hosted@twilio.com",
153
+ "sid": "PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
154
+ "status": "signing",
155
+ "url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
156
+ }
157
+ ]
158
+ }
159
+ ]
160
+ ))
161
+
162
+ actual = @client.preview.hosted_numbers.authorization_documents.list()
163
+
164
+ expect(actual).to_not eq(nil)
165
+ end
166
+
167
+ it "can create" do
168
+ @holodeck.mock(Twilio::Response.new(500, ''))
169
+
170
+ expect {
171
+ @client.preview.hosted_numbers.authorization_documents.create(hosted_number_order_sids: ['hosted_number_order_sids'], address_sid: "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", email: "email")
172
+ }.to raise_exception(Twilio::REST::TwilioError)
173
+
174
+ values = {
175
+ 'HostedNumberOrderSids' => ['hosted_number_order_sids'],
176
+ 'AddressSid' => "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
177
+ 'Email' => "email",
178
+ }
179
+ expect(
180
+ @holodeck.has_request?(Holodeck::Request.new(
181
+ method: 'post',
182
+ url: 'https://preview.twilio.com/HostedNumbers/AuthorizationDocuments',
183
+ data: values,
184
+ ))).to eq(true)
185
+ end
186
+
187
+ it "receives create responses" do
188
+ @holodeck.mock(Twilio::Response.new(
189
+ 201,
190
+ %q[
191
+ {
192
+ "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
193
+ "cc_emails": [
194
+ "test1@twilio.com",
195
+ "test2@twilio.com"
196
+ ],
197
+ "date_created": "2017-03-28T20:06:39Z",
198
+ "date_updated": "2017-03-28T20:06:39Z",
199
+ "email": "test+hosted@twilio.com",
200
+ "sid": "PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
201
+ "status": "signing",
202
+ "url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
203
+ }
204
+ ]
205
+ ))
206
+
207
+ actual = @client.preview.hosted_numbers.authorization_documents.create(hosted_number_order_sids: ['hosted_number_order_sids'], address_sid: "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", email: "email")
208
+
209
+ expect(actual).to_not eq(nil)
210
+ end
211
+ end