twilio-ruby 3.11.1 → 3.11.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4463ad95b5c4cdd215f8c1ba739c94356598855
4
- data.tar.gz: f7b531fa9490928e9ee8631e660c74068be58366
3
+ metadata.gz: 06d9012436c3641dc254ae2f2a35f79438f6195f
4
+ data.tar.gz: 511697c9a9d9acfb74673705b51327fccc51399d
5
5
  SHA512:
6
- metadata.gz: 414d7a39fe93d2159a6890f057aa54ea741d75e4d6ac5f9b167ea7c17c787ae0d5cd34b8cf029c497816dc8141d1af134c0487322a0fd0edd75e8d813ce8de5f
7
- data.tar.gz: e914fd9c3a2c539c4360544338bb4f2808055f56c94dd4845ad0deed1a90ba5dcac850d6a7bcbeb221d864a677179f0f105b4b7637e3b555bb2df04a0545651b
6
+ metadata.gz: ac1f7697751c9f07664d61a56415189a9fecba1d363be816636f887a22428ed27831e3406f2d62203a0913dcff35e92d1fd08b9398741f71dd15c1c23faf0cd4
7
+ data.tar.gz: ff659fa106429147fe87947e09695090166e35593b820e6c65a64e7928a40ee6f4cc7be6a9c63ce89860c0ed48e8d7fa4c9f593f287e5c5d09036b6eea5d06c0
data/CHANGES CHANGED
@@ -1,6 +1,19 @@
1
1
  twilio-ruby changelog
2
2
  =====================
3
3
 
4
+ Version 3.11.3
5
+
6
+ Released October 15, 2013
7
+
8
+ - Restore ability of `sms.messages` to make requests to /SMS/Messages.
9
+
10
+ Version 3.11.1
11
+ --------------
12
+
13
+ Released September 24, 2013
14
+
15
+ - Fix a bug causing request the new messages class to fail.
16
+
4
17
  Version 3.11.0
5
18
  -------------
6
19
 
@@ -41,6 +41,7 @@ Query the Twilio REST API to create phone calls, send SMS/MMS messages and more!
41
41
  :maxdepth: 1
42
42
 
43
43
  usage/basics
44
+ usage/errors
44
45
  usage/messages
45
46
  usage/phone-calls
46
47
  usage/phone-numbers
@@ -44,7 +44,7 @@ Subaccounts are easy to make.
44
44
  account_sid = "ACXXXXXXXXXXXXXXXXX"
45
45
  auth_token = "YYYYYYYYYYYYYYYYYY"
46
46
 
47
- @client = Twilio::Rest::Client.new account_sid, auth_token
47
+ @client = Twilio::REST::Client.new account_sid, auth_token
48
48
  @subaccount = @client.accounts.create({:name => "My Awesome SubAccount"})
49
49
 
50
50
 
@@ -61,7 +61,7 @@ Say you have a subaccount for Client X with an account sid `AC123`
61
61
  account_sid = "ACXXXXXXXXXXXXXXXXX"
62
62
  auth_token = "YYYYYYYYYYYYYYYYYY"
63
63
 
64
- @client = Twilio::Rest::Client.new account_sid, auth_token
64
+ @client = Twilio::REST::Client.new account_sid, auth_token
65
65
 
66
66
  # Client X's subaccount
67
67
  @subaccount = @client.accounts.get('AC123')
@@ -79,3 +79,24 @@ Provide the :attr:`sid` of the resource you'd like to get.
79
79
  @call = @client.account.calls.get("CA123")
80
80
  puts @call.to
81
81
 
82
+
83
+ Deleting a Resource
84
+ -------------------------------
85
+
86
+ Resources can only be deleted via their instance object. This means
87
+ you must instantiate an instance object using :meth:`ListResource.get`
88
+ and then call :meth:`delete` on it.
89
+
90
+ .. code-block:: ruby
91
+
92
+ require 'twilio-ruby'
93
+
94
+ # To find these visit https://www.twilio.com/user/account
95
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
96
+ auth_token = "YYYYYYYYYYYYYYYYYY"
97
+
98
+ @client = Twilio::REST::Client.new account_sid, auth_token
99
+
100
+ @recording = @client.account.recordings.get("RC123")
101
+ @recording.delete()
102
+
@@ -0,0 +1,29 @@
1
+ Error Handling
2
+ ==============
3
+
4
+ Exceptions
5
+ ----------
6
+ If the Twilio API returns a 400 or a 500 level HTTP response,
7
+ the twilio-ruby library will throw a :class:`Twilio::REST::RequestError`.
8
+ 400-level errors are normal during API operation ("Invalid number",
9
+ "Cannot deliver SMS to that number", for example) and should be
10
+ handled appropriately.
11
+
12
+ .. code-block:: ruby
13
+
14
+ require 'twilio-ruby'
15
+
16
+ # To find these visit https://www.twilio.com/user/account
17
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
18
+ auth_token = "YYYYYYYYYYYYYYYYYY"
19
+
20
+ begin
21
+ @client = Twilio::REST::Client.new account_sid, auth_token
22
+ client.account.messages.create({
23
+ :from => '+1234567890',
24
+ :to => '+1234567890',
25
+ :body => 'Hello world'
26
+ })
27
+ rescue Twilio::REST::RequestError => e
28
+ puts e.message
29
+ end
@@ -29,7 +29,9 @@ puts @account.friendly_name
29
29
  end
30
30
 
31
31
  # get a particular call and list its recording urls
32
- @account.calls.get('CAXXXXXXX').recordings.list.each do {|r| puts r.wav}
32
+ @account.calls.get('CAXXXXXXX').recordings.list.each do |r|
33
+ puts r.wav
34
+ end
33
35
 
34
36
  # make a new outgoing call. returns a call object just like calls.get
35
37
  @call = @account.calls.create({:from => '+14159341234', :to => '+18004567890', :url => 'http://example.com/call-handler'})
@@ -85,7 +87,9 @@ puts @account.messages.get('SMXXXXXXXX').body
85
87
  @participants = @account.conferences.get('CFbbe46ff1274e283f7e3ac1df0072ab39').participants
86
88
 
87
89
  # list participants
88
- @participants.list.each do {|p| puts p.sid}
90
+ @participants.list.each do |p|
91
+ puts p.sid
92
+ end
89
93
 
90
94
  # update a conference participant
91
95
  @participants.get('CA386025c9bf5d6052a1d1ea42b4d16662').update({:muted => 'true'})
@@ -21,6 +21,7 @@ require 'twilio-ruby/rest/accounts'
21
21
  require 'twilio-ruby/rest/calls'
22
22
  require 'twilio-ruby/rest/sms'
23
23
  require 'twilio-ruby/rest/sms/short_codes'
24
+ require 'twilio-ruby/rest/sms/messages'
24
25
  require 'twilio-ruby/rest/sip'
25
26
  require 'twilio-ruby/rest/sip/domains'
26
27
  require 'twilio-ruby/rest/sip/domains/ip_access_control_list_mappings'
@@ -89,7 +89,8 @@ module Twilio
89
89
  resource = twilify r
90
90
  relative_path = custom_resource_names.fetch(r, resource)
91
91
  path = "#{@path}/#{relative_path}"
92
- resource_class = Twilio::REST.const_get resource
92
+ enclosing_module = @submodule == nil ? (Twilio::REST) : (Twilio::REST.const_get(@submodule))
93
+ resource_class = enclosing_module.const_get resource
93
94
  instance_variable_set("@#{r}", resource_class.new(path, @client))
94
95
  end
95
96
  self.class.instance_eval {attr_reader *resources}
@@ -9,7 +9,13 @@ module Twilio
9
9
  @path, @client = path, client
10
10
  resource_name = self.class.name.split('::')[-1]
11
11
  instance_name = custom_names.fetch(resource_name, resource_name.chop)
12
- @instance_class = Twilio::REST.const_get instance_name
12
+
13
+ # The next line grabs the enclosing module. Necessary for resources
14
+ # contained in their own submodule like /SMS/Messages
15
+ parent_module = self.class.to_s.split('::')[-2]
16
+ full_module_path = parent_module == "REST" ? (Twilio::REST) : (Twilio::REST.const_get parent_module)
17
+
18
+ @instance_class = full_module_path.const_get instance_name
13
19
  @list_key, @instance_id_key = detwilify(resource_name), 'sid'
14
20
  end
15
21
 
@@ -3,6 +3,7 @@ module Twilio
3
3
  class Sms < InstanceResource
4
4
  def initialize(path, client, params={})
5
5
  super
6
+ @submodule = :SMS
6
7
  resource :messages, :short_codes
7
8
  end
8
9
  end
@@ -0,0 +1,15 @@
1
+ module Twilio
2
+ module REST
3
+ module SMS
4
+ class Messages < ListResource
5
+ def initialize(path, client)
6
+ super
7
+ @list_key = 'sms_messages'
8
+ end
9
+ end
10
+
11
+ class Message < InstanceResource
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,6 +1,8 @@
1
1
  module Twilio
2
2
  module REST
3
- class ShortCodes < ListResource; end
4
- class ShortCode < InstanceResource; end
3
+ module SMS
4
+ class ShortCodes < ListResource; end
5
+ class ShortCode < InstanceResource; end
6
+ end
5
7
  end
6
8
  end
@@ -1,3 +1,3 @@
1
1
  module Twilio
2
- VERSION = '3.11.1'
2
+ VERSION = '3.11.3'
3
3
  end
@@ -0,0 +1,21 @@
1
+ This pull moves the /SMS endpoints into their own `SMS` module. This allows both of the `Message` classes to coexist, since one is in its own namespace, so I was able to bring back the class living at `sms.messages`. This means `@client.account.sms.messages` will once again make requests to the `/SMS/Messages` endpoint. This change re-enables Test Credentials for the `sms.messages` class.
2
+
3
+ This required a change to both `instance_resource.rb` and `list_resource.rb` because both were relying on the assumption that all classes live in the Twilio::REST module.
4
+
5
+ To use the new submodule functionality, just set the `@submodule` variable to the name of the new submodule on the class declaring the subresources. Here is how it was done for `/SMS/Messages`.
6
+
7
+ ```ruby
8
+ module Twilio
9
+ module REST
10
+ class Sms < InstanceResource
11
+ def initialize(path, client, params={})
12
+ super
13
+ @submodule = :SMS
14
+ resource :messages, :short_codes
15
+ end
16
+ end
17
+ end
18
+ end
19
+ ```
20
+
21
+ @labcoder @carlosdp @alexcchan
@@ -9,9 +9,4 @@ describe Twilio::REST::Message do
9
9
  @message.should respond_to(:media)
10
10
  @message.media.instance_variable_get('@path').should == 'someUri/Media'
11
11
  end
12
-
13
- it 'does not use the old endpoint' do
14
- client = Twilio::REST::Client.new('someId', 'sometoken')
15
- client.account.sms.messages.instance_variable_get('@path').include?('/SMS').should be_false
16
- end
17
12
  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: 3.11.1
4
+ version: 3.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Benton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-25 00:00:00.000000000 Z
11
+ date: 2013-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -151,6 +151,7 @@ files:
151
151
  - docs/usage/basics.rst
152
152
  - docs/usage/caller-ids.rst
153
153
  - docs/usage/conferences.rst
154
+ - docs/usage/errors.rst
154
155
  - docs/usage/messages.rst
155
156
  - docs/usage/notifications.rst
156
157
  - docs/usage/phone-calls.rst
@@ -198,6 +199,7 @@ files:
198
199
  - lib/twilio-ruby/rest/sip/ip_access_control_lists.rb
199
200
  - lib/twilio-ruby/rest/sip/ip_access_control_lists/ip_addresses.rb
200
201
  - lib/twilio-ruby/rest/sms.rb
202
+ - lib/twilio-ruby/rest/sms/messages.rb
201
203
  - lib/twilio-ruby/rest/sms/short_codes.rb
202
204
  - lib/twilio-ruby/rest/transcriptions.rb
203
205
  - lib/twilio-ruby/rest/usage.rb
@@ -209,6 +211,7 @@ files:
209
211
  - lib/twilio-ruby/util/capability.rb
210
212
  - lib/twilio-ruby/util/request_validator.rb
211
213
  - lib/twilio-ruby/version.rb
214
+ - pull.txt
212
215
  - spec/rest/account_spec.rb
213
216
  - spec/rest/call_spec.rb
214
217
  - spec/rest/client_spec.rb