twilio-ruby 5.0.0.rc5 → 5.0.0.rc7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b36c0c36564e2f8f9a28c2a0806ffb3e22ac45ce
4
- data.tar.gz: 3945773e1504b060c44995ab120ee6e931ce8b34
3
+ metadata.gz: bbbaa3e364a1624cd589adf645929771a6f904bb
4
+ data.tar.gz: 22a02d6228e6248cd8b729e7217dba222e644b73
5
5
  SHA512:
6
- metadata.gz: 34b7af3a9579a759eebeef7618441387c255591dccda3bdc563579d345e487ebad9a9dc1757716d1168c3c27f50c6b1e4db8e8db84b7ca89faf6ba4655e39f2e
7
- data.tar.gz: e7ab48283e6cc5e1a8c9f231c267781adb3d9462ac107149dee6a20b12d1126d6d6fc67dfac5352ba75538d221f4e63682094df50be8ba370801fad72426554c
6
+ metadata.gz: cbd27881a6f2986afba1250a5ea958353d7a650276bbec2b3e2922d5b64d34b0d805d0b109fe067ee8d7c64b81380f0dd63f285c6135d21e4dbd210bfcaf7cb9
7
+ data.tar.gz: 2c5cb2d27e44730eb2bdc85262049639e5183ba0da7583384726022e7cbcc65c5c186f767de5bdc622c8bc9391a7436d2c767836ce199cb0276a0d6122224eda
data/CHANGES.md CHANGED
@@ -1,6 +1,14 @@
1
1
  twilio-ruby changelog
2
2
  =====================
3
3
 
4
+ Version 5.0.0-rc7
5
+ -------------
6
+
7
+ Release June 9, 2016
8
+
9
+ - Add messaging feedback support
10
+
11
+
4
12
  Version 5.0.0-rc5
5
13
  -------------
6
14
 
@@ -16,4 +16,30 @@ module Twilio
16
16
  Time.parse(date)
17
17
  end
18
18
  end
19
+
20
+ def self.flatten(map, result={}, previous=[])
21
+ map.each do |key, value|
22
+ if value.is_a? Hash
23
+ self.flatten(value, result, previous + [key])
24
+ else
25
+ result[(previous + [key]).join('.')] = value
26
+ end
27
+ end
28
+
29
+ result
30
+ end
31
+
32
+ def self.prefixed_collapsible_map(map, prefix)
33
+ result = {}
34
+ if map.is_a? Hash
35
+ flattened = self.flatten(map)
36
+ result = {}
37
+ flattened.each do |key, value|
38
+ result[prefix + '.' + key] = value
39
+ end
40
+ end
41
+
42
+ result
43
+ end
44
+
19
45
  end
@@ -12,6 +12,9 @@ module Twilio
12
12
  @proxy_pass = proxy_pass
13
13
  @ssl_ca_file = ssl_ca_file
14
14
  @adapter = Faraday.default_adapter
15
+
16
+ # Set default params encoder
17
+ Faraday::Utils.default_params_encoder = Faraday::FlatParamsEncoder
15
18
  end
16
19
 
17
20
  def request(host, port, method, url, params={}, data={}, headers={}, auth=nil, timeout=nil)
@@ -248,6 +248,7 @@ module Twilio
248
248
 
249
249
  # Dependents
250
250
  @media = nil
251
+ @feedback = nil
251
252
  end
252
253
 
253
254
  ##
@@ -325,6 +326,21 @@ module Twilio
325
326
  @media
326
327
  end
327
328
 
329
+ ##
330
+ # Access the feedback
331
+ # @return [FeedbackList] FeedbackList
332
+ def feedback
333
+ unless @feedback
334
+ @feedback = FeedbackList.new(
335
+ @version,
336
+ account_sid: @solution[:account_sid],
337
+ message_sid: @solution[:sid],
338
+ )
339
+ end
340
+
341
+ @feedback
342
+ end
343
+
328
344
  ##
329
345
  # Provide a user friendly representation
330
346
  def to_s
@@ -499,6 +515,13 @@ module Twilio
499
515
  @context.media
500
516
  end
501
517
 
518
+ ##
519
+ # Access the feedback
520
+ # @return [feedback] feedback
521
+ def feedback
522
+ @context.feedback
523
+ end
524
+
502
525
  ##
503
526
  # Provide a user friendly representation
504
527
  def to_s
@@ -0,0 +1,160 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Api < Domain
10
+ class V2010 < Version
11
+ class AccountContext < InstanceContext
12
+ class MessageContext < InstanceContext
13
+ class FeedbackList < ListResource
14
+ ##
15
+ # Initialize the FeedbackList
16
+ # @param [Version] version Version that contains the resource
17
+ # @param [String] account_sid The account_sid
18
+ # @param [String] message_sid The message_sid
19
+
20
+ # @return [FeedbackList] FeedbackList
21
+ def initialize(version, account_sid: nil, message_sid: nil)
22
+ super(version)
23
+
24
+ # Path Solution
25
+ @solution = {
26
+ account_sid: account_sid,
27
+ message_sid: message_sid
28
+ }
29
+ @uri = "/Accounts/#{@solution[:account_sid]}/Messages/#{@solution[:message_sid]}/Feedback.json"
30
+ end
31
+
32
+ ##
33
+ # Retrieve a single page of FeedbackInstance records from the API.
34
+ # Request is executed immediately.
35
+ # @param [feedback.Outcome] outcome The outcome
36
+
37
+ # @return [FeedbackInstance] Newly created FeedbackInstance
38
+ def create(outcome: nil)
39
+ data = {
40
+ 'Outcome' => outcome,
41
+ }
42
+
43
+ payload = @version.create(
44
+ 'POST',
45
+ @uri,
46
+ data: data
47
+ )
48
+
49
+ return FeedbackInstance.new(
50
+ @version,
51
+ payload,
52
+ account_sid: @solution['account_sid'],
53
+ message_sid: @solution['message_sid'],
54
+ )
55
+ end
56
+
57
+ ##
58
+ # Provide a user friendly representation
59
+ def to_s
60
+ '#<Twilio.Api.V2010.FeedbackList>'
61
+ end
62
+ end
63
+
64
+ class FeedbackPage < Page
65
+ ##
66
+ # Initialize the FeedbackPage
67
+ # @param [Version] version Version that contains the resource
68
+ # @param [Response] response Response from the API
69
+ # @param [Hash] solution Path solution for the resource
70
+ # @param [String] account_sid The account_sid
71
+ # @param [String] message_sid The message_sid
72
+
73
+ # @return [FeedbackPage] FeedbackPage
74
+ def initialize(version, response, solution)
75
+ super(version, response)
76
+
77
+ # Path Solution
78
+ @solution = solution
79
+ end
80
+
81
+ ##
82
+ # Build an instance of FeedbackInstance
83
+ # @param [Hash] payload Payload response from the API
84
+
85
+ # @return [FeedbackInstance] FeedbackInstance
86
+ def get_instance(payload)
87
+ return FeedbackInstance.new(
88
+ @version,
89
+ payload,
90
+ account_sid: @solution['account_sid'],
91
+ message_sid: @solution['message_sid'],
92
+ )
93
+ end
94
+
95
+ ##
96
+ # Provide a user friendly representation
97
+ def to_s
98
+ '<Twilio.Api.V2010.FeedbackPage>'
99
+ end
100
+ end
101
+
102
+ class FeedbackInstance < InstanceResource
103
+ ##
104
+ # Initialize the FeedbackInstance
105
+ # @param [Version] version Version that contains the resource
106
+ # @param [Hash] payload payload that contains response from Twilio
107
+ # @param [String] account_sid The account_sid
108
+ # @param [String] message_sid The message_sid
109
+
110
+ # @return [FeedbackInstance] FeedbackInstance
111
+ def initialize(version, payload, account_sid: nil, message_sid: nil)
112
+ super(version)
113
+
114
+ # Marshaled Properties
115
+ @properties = {
116
+ 'account_sid' => payload['account_sid'],
117
+ 'message_sid' => payload['message_sid'],
118
+ 'outcome' => payload['outcome'],
119
+ 'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
120
+ 'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
121
+ 'uri' => payload['uri'],
122
+ }
123
+ end
124
+
125
+ def account_sid
126
+ @properties['account_sid']
127
+ end
128
+
129
+ def message_sid
130
+ @properties['message_sid']
131
+ end
132
+
133
+ def outcome
134
+ @properties['outcome']
135
+ end
136
+
137
+ def date_created
138
+ @properties['date_created']
139
+ end
140
+
141
+ def date_updated
142
+ @properties['date_updated']
143
+ end
144
+
145
+ def uri
146
+ @properties['uri']
147
+ end
148
+
149
+ ##
150
+ # Provide a user friendly representation
151
+ def to_s
152
+ "<Twilio.Api.V2010.FeedbackInstance>"
153
+ end
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
160
+ end
@@ -83,14 +83,18 @@ module Twilio
83
83
  # Fetch a PhoneNumberInstance
84
84
  # @param [String] country_code The country_code
85
85
  # @param [String] type The type
86
+ # @param [String] add_ons The add_ons
87
+ # @param [Hash] add_ons_data The add_ons_data
86
88
 
87
89
  # @return [PhoneNumberInstance] Fetched PhoneNumberInstance
88
- def fetch(country_code: nil, type: nil)
90
+ def fetch(country_code: nil, type: nil, add_ons: nil, add_ons_data: nil)
89
91
  params = {
90
92
  'CountryCode' => country_code,
91
93
  'Type' => type,
94
+ 'AddOns' => add_ons,
92
95
  }
93
96
 
97
+ params.merge!(Twilio.prefixed_collapsible_map(add_ons_data, 'AddOns'))
94
98
  payload = @version.fetch(
95
99
  'GET',
96
100
  @uri,
@@ -129,6 +133,7 @@ module Twilio
129
133
  'phone_number' => payload['phone_number'],
130
134
  'national_format' => payload['national_format'],
131
135
  'carrier' => payload['carrier'],
136
+ 'add_ons' => payload['add_ons'],
132
137
  }
133
138
 
134
139
  # Context
@@ -170,15 +175,23 @@ module Twilio
170
175
  @properties['carrier']
171
176
  end
172
177
 
178
+ def add_ons
179
+ @properties['add_ons']
180
+ end
181
+
173
182
  ##
174
183
  # Fetch a PhoneNumberInstance
175
184
  # @param [String] country_code The country_code
176
185
  # @param [String] type The type
186
+ # @param [String] add_ons The add_ons
187
+ # @param [Hash] add_ons_data The add_ons_data
177
188
 
178
189
  # @return [PhoneNumberInstance] Fetched PhoneNumberInstance
179
- def fetch(country_code: nil, type: nil)
190
+ def fetch(country_code: nil, type: nil, add_ons: nil, add_ons_data: nil)
180
191
  @context.fetch(
181
192
  type: type,
193
+ add_ons: add_ons,
194
+ add_ons_data: add_ons_data,
182
195
  )
183
196
  end
184
197
 
@@ -15,10 +15,11 @@ module Twilio
15
15
  @base_url = 'https://preview.twilio.com'
16
16
  @host = 'preview.twilio.com'
17
17
  @port = 443
18
-
18
+
19
+ # Versions
19
20
  @wireless = nil
20
21
  end
21
-
22
+
22
23
  ##
23
24
  # Version wireless of preview
24
25
  def wireless
@@ -1,3 +1,3 @@
1
1
  module Twilio
2
- VERSION = '5.0.0.rc5'
2
+ VERSION = '5.0.0.rc7'
3
3
  end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Twilio do
4
+ describe 'prefixed_collapsible_map' do
5
+
6
+ it 'should serialize nil' do
7
+ actual = Twilio.prefixed_collapsible_map(nil, 'Prefix')
8
+ expect(actual).to eq({})
9
+ end
10
+
11
+ it 'should serialize a single key' do
12
+ actual = Twilio.prefixed_collapsible_map({
13
+ 'foo' => 'bar'
14
+ }, 'Prefix')
15
+ expect(actual).to eq({
16
+ 'Prefix.foo' => 'bar'
17
+ })
18
+ end
19
+
20
+ it 'should serialize nested key' do
21
+ actual = Twilio.prefixed_collapsible_map({
22
+ 'foo' => {
23
+ 'bar' => 'baz'
24
+ }
25
+ }, 'Prefix')
26
+ expect(actual).to eq({
27
+ 'Prefix.foo.bar' => 'baz'
28
+ })
29
+ end
30
+
31
+ it 'should serialize multiple keys' do
32
+ actual = Twilio.prefixed_collapsible_map({
33
+ 'watson' => {
34
+ 'language' => 'en',
35
+ 'alice' => 'bob'
36
+ },
37
+ 'foo' => 'bar'
38
+ }, 'Prefix')
39
+ expect(actual).to eq({
40
+ 'Prefix.watson.language' => 'en',
41
+ 'Prefix.watson.alice' => 'bob',
42
+ 'Prefix.foo' => 'bar'
43
+ })
44
+ end
45
+
46
+ it 'should serialize list' do
47
+ actual = Twilio.prefixed_collapsible_map(['foo', 'bar'], 'Prefix')
48
+ expect(actual).to eq({})
49
+ end
50
+
51
+
52
+ end
53
+ end
@@ -0,0 +1,26 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ require 'spec_helper.rb'
8
+
9
+ describe 'Feedback' do
10
+ it "can create" do
11
+ @holodeck.mock(Twilio::TwilioResponse.new(500, ''))
12
+
13
+ expect {
14
+ @client.api.v2010.accounts("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
15
+ .messages("MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
16
+ .feedback.create()
17
+ }.to raise_exception(Twilio::REST::TwilioException)
18
+
19
+ values = {}
20
+ expect(
21
+ @holodeck.has_request?(Holodeck::Request.new(
22
+ method: 'post',
23
+ url: 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Feedback.json',
24
+ ))).to eq(true)
25
+ end
26
+ end
@@ -37,6 +37,12 @@ describe 'PhoneNumber' do
37
37
  "country_code": "US",
38
38
  "national_format": "(510) 867-5309",
39
39
  "phone_number": "+15108675309",
40
+ "add_ons": {
41
+ "status": "successful",
42
+ "message": null,
43
+ "code": null,
44
+ "results": {}
45
+ },
40
46
  "url": "https://lookups.twilio.com/v1/PhoneNumbers/phone_number"
41
47
  }
42
48
  ]
@@ -11,7 +11,7 @@ describe 'Usage' do
11
11
  @holodeck.mock(Twilio::TwilioResponse.new(500, ''))
12
12
 
13
13
  expect {
14
- @client.preview.wireless.devices("sid") \
14
+ @client.preview.wireless.devices("DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
15
15
  .usage().fetch()
16
16
  }.to raise_exception(Twilio::REST::TwilioException)
17
17
 
@@ -19,7 +19,7 @@ describe 'Usage' do
19
19
  expect(
20
20
  @holodeck.has_request?(Holodeck::Request.new(
21
21
  method: 'get',
22
- url: 'https://preview.twilio.com/wireless/Devices/sid/Usage',
22
+ url: 'https://preview.twilio.com/wireless/Devices/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage',
23
23
  ))).to eq(true)
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.rc5
4
+ version: 5.0.0.rc7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Benton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-31 00:00:00.000000000 Z
11
+ date: 2016-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -139,6 +139,7 @@ files:
139
139
  - lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb
140
140
  - lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb
141
141
  - lib/twilio-ruby/rest/api/v2010/account/message.rb
142
+ - lib/twilio-ruby/rest/api/v2010/account/message/feedback.rb
142
143
  - lib/twilio-ruby/rest/api/v2010/account/message/media.rb
143
144
  - lib/twilio-ruby/rest/api/v2010/account/notification.rb
144
145
  - lib/twilio-ruby/rest/api/v2010/account/outgoing_caller_id.rb
@@ -243,6 +244,7 @@ files:
243
244
  - lib/twilio-ruby/util/configuration.rb
244
245
  - lib/twilio-ruby/util/request_validator.rb
245
246
  - lib/twilio-ruby/version.rb
247
+ - spec/framework/serialize_spec.rb
246
248
  - spec/holodeck/holodeck.rb
247
249
  - spec/holodeck/hologram.rb
248
250
  - spec/integration/api/v2010/account/address/dependent_phone_number_spec.rb
@@ -265,6 +267,7 @@ files:
265
267
  - spec/integration/api/v2010/account/incoming_phone_number/mobile_spec.rb
266
268
  - spec/integration/api/v2010/account/incoming_phone_number/toll_free_spec.rb
267
269
  - spec/integration/api/v2010/account/incoming_phone_number_spec.rb
270
+ - spec/integration/api/v2010/account/message/feedback_spec.rb
268
271
  - spec/integration/api/v2010/account/message/media_spec.rb
269
272
  - spec/integration/api/v2010/account/message_spec.rb
270
273
  - spec/integration/api/v2010/account/notification_spec.rb
@@ -388,6 +391,7 @@ specification_version: 4
388
391
  summary: A simple library for communicating with the Twilio REST API, building TwiML,
389
392
  and generating Twilio Client Capability Tokens
390
393
  test_files:
394
+ - spec/framework/serialize_spec.rb
391
395
  - spec/holodeck/holodeck.rb
392
396
  - spec/holodeck/hologram.rb
393
397
  - spec/integration/api/v2010/account/address/dependent_phone_number_spec.rb
@@ -410,6 +414,7 @@ test_files:
410
414
  - spec/integration/api/v2010/account/incoming_phone_number/mobile_spec.rb
411
415
  - spec/integration/api/v2010/account/incoming_phone_number/toll_free_spec.rb
412
416
  - spec/integration/api/v2010/account/incoming_phone_number_spec.rb
417
+ - spec/integration/api/v2010/account/message/feedback_spec.rb
413
418
  - spec/integration/api/v2010/account/message/media_spec.rb
414
419
  - spec/integration/api/v2010/account/message_spec.rb
415
420
  - spec/integration/api/v2010/account/notification_spec.rb