twilio-ruby 3.11.1 → 3.11.3
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 +4 -4
- data/CHANGES +13 -0
- data/docs/index.rst +1 -0
- data/docs/usage/accounts.rst +2 -2
- data/docs/usage/basics.rst +21 -0
- data/docs/usage/errors.rst +29 -0
- data/examples/examples.rb +6 -2
- data/lib/twilio-ruby.rb +1 -0
- data/lib/twilio-ruby/rest/instance_resource.rb +2 -1
- data/lib/twilio-ruby/rest/list_resource.rb +7 -1
- data/lib/twilio-ruby/rest/sms.rb +1 -0
- data/lib/twilio-ruby/rest/sms/messages.rb +15 -0
- data/lib/twilio-ruby/rest/sms/short_codes.rb +4 -2
- data/lib/twilio-ruby/version.rb +1 -1
- data/pull.txt +21 -0
- data/spec/rest/message_spec.rb +0 -5
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06d9012436c3641dc254ae2f2a35f79438f6195f
|
4
|
+
data.tar.gz: 511697c9a9d9acfb74673705b51327fccc51399d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/docs/index.rst
CHANGED
data/docs/usage/accounts.rst
CHANGED
@@ -44,7 +44,7 @@ Subaccounts are easy to make.
|
|
44
44
|
account_sid = "ACXXXXXXXXXXXXXXXXX"
|
45
45
|
auth_token = "YYYYYYYYYYYYYYYYYY"
|
46
46
|
|
47
|
-
@client = Twilio::
|
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::
|
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')
|
data/docs/usage/basics.rst
CHANGED
@@ -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
|
data/examples/examples.rb
CHANGED
@@ -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
|
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
|
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'})
|
data/lib/twilio-ruby.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
|
data/lib/twilio-ruby/rest/sms.rb
CHANGED
data/lib/twilio-ruby/version.rb
CHANGED
data/pull.txt
ADDED
@@ -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
|
data/spec/rest/message_spec.rb
CHANGED
@@ -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.
|
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-
|
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
|