twilio-ruby 3.10.1 → 3.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/AUTHORS.md +24 -0
  2. data/CHANGES +11 -0
  3. data/Makefile +13 -0
  4. data/README.md +28 -13
  5. data/docs/Makefile +130 -0
  6. data/docs/_themes/LICENSE +45 -0
  7. data/docs/_themes/README.rst +25 -0
  8. data/docs/_themes/flask_theme_support.py +86 -0
  9. data/docs/_themes/kr/layout.html +32 -0
  10. data/docs/_themes/kr/relations.html +19 -0
  11. data/docs/_themes/kr/static/flasky.css_t +469 -0
  12. data/docs/_themes/kr/static/small_flask.css +70 -0
  13. data/docs/_themes/kr/theme.conf +7 -0
  14. data/docs/_themes/kr_small/layout.html +22 -0
  15. data/docs/_themes/kr_small/static/flasky.css_t +287 -0
  16. data/docs/_themes/kr_small/theme.conf +10 -0
  17. data/docs/changelog.rst +1 -0
  18. data/docs/conf.py +266 -0
  19. data/docs/faq.rst +42 -0
  20. data/docs/getting-started.rst +91 -0
  21. data/docs/index.rst +108 -0
  22. data/docs/make.bat +170 -0
  23. data/docs/src/pip-delete-this-directory.txt +5 -0
  24. data/docs/usage/accounts.rst +89 -0
  25. data/docs/usage/applications.rst +108 -0
  26. data/docs/usage/basics.rst +81 -0
  27. data/docs/usage/caller-ids.rst +45 -0
  28. data/docs/usage/conferences.rst +108 -0
  29. data/docs/usage/messages.rst +110 -0
  30. data/docs/usage/notifications.rst +70 -0
  31. data/docs/usage/phone-calls.rst +168 -0
  32. data/docs/usage/phone-numbers.rst +159 -0
  33. data/docs/usage/queues.rst +112 -0
  34. data/docs/usage/recordings.rst +96 -0
  35. data/docs/usage/sip.rst +103 -0
  36. data/docs/usage/token-generation.rst +81 -0
  37. data/docs/usage/transcriptions.rst +31 -0
  38. data/docs/usage/twiml.rst +70 -0
  39. data/docs/usage/validation.rst +71 -0
  40. data/examples/examples.rb +8 -5
  41. data/lib/twilio-ruby.rb +10 -0
  42. data/lib/twilio-ruby/rest/accounts.rb +1 -1
  43. data/lib/twilio-ruby/rest/instance_resource.rb +2 -1
  44. data/lib/twilio-ruby/rest/list_resource.rb +4 -1
  45. data/lib/twilio-ruby/rest/media.rb +14 -0
  46. data/lib/twilio-ruby/rest/messages.rb +12 -0
  47. data/lib/twilio-ruby/rest/sip.rb +12 -0
  48. data/lib/twilio-ruby/rest/sip/credential_lists.rb +11 -0
  49. data/lib/twilio-ruby/rest/sip/credential_lists/credentials.rb +6 -0
  50. data/lib/twilio-ruby/rest/sip/domains.rb +12 -0
  51. data/lib/twilio-ruby/rest/sip/domains/credential_list_mappings.rb +6 -0
  52. data/lib/twilio-ruby/rest/sip/domains/ip_access_control_list_mappings.rb +6 -0
  53. data/lib/twilio-ruby/rest/sip/ip_access_control_lists.rb +11 -0
  54. data/lib/twilio-ruby/rest/sip/ip_access_control_lists/ip_addresses.rb +6 -0
  55. data/lib/twilio-ruby/rest/sms.rb +1 -1
  56. data/lib/twilio-ruby/rest/usage/records.rb +1 -1
  57. data/lib/twilio-ruby/rest/utils.rb +1 -1
  58. data/lib/twilio-ruby/version.rb +1 -1
  59. data/spec/rest/message_spec.rb +12 -0
  60. metadata +52 -2
data/examples/examples.rb CHANGED
@@ -50,16 +50,19 @@ end
50
50
 
51
51
  ################ SMS MESSAGES ################
52
52
 
53
- # print a list of sms messages
54
- @account.sms.messages.list({:date_sent => '2010-09-01'}).each do |sms|
55
- puts sms.body
53
+ # print a list of messages
54
+ @account.messages.list({:date_sent => '2010-09-01'}).each do |message|
55
+ puts message.body
56
56
  end
57
57
 
58
58
  # print a particular sms message
59
- puts @account.sms.messages.get('SMXXXXXXXX').body
59
+ puts @account.messages.get('SMXXXXXXXX').body
60
60
 
61
61
  # send an sms
62
- @account.sms.messages.create(:from => '+14159341234', :to => '+16105557069', :body => 'Hey there!')
62
+ @account.messages.create(:from => '+14159341234', :to => '+16105557069', :body => 'Hey there!')
63
+
64
+ # send an mms
65
+ @account.messages.create(:from => '+14159341234', :to => '+16105557069', :media_urls => 'http://example.com/media.png')
63
66
 
64
67
  ################ PHONE NUMBERS ################
65
68
 
data/lib/twilio-ruby.rb CHANGED
@@ -22,6 +22,16 @@ require 'twilio-ruby/rest/calls'
22
22
  require 'twilio-ruby/rest/sms'
23
23
  require 'twilio-ruby/rest/sms/messages'
24
24
  require 'twilio-ruby/rest/sms/short_codes'
25
+ require 'twilio-ruby/rest/sip'
26
+ require 'twilio-ruby/rest/sip/domains'
27
+ require 'twilio-ruby/rest/sip/domains/ip_access_control_list_mappings'
28
+ require 'twilio-ruby/rest/sip/domains/credential_list_mappings'
29
+ require 'twilio-ruby/rest/sip/credential_lists'
30
+ require 'twilio-ruby/rest/sip/credential_lists/credentials'
31
+ require 'twilio-ruby/rest/sip/ip_access_control_lists'
32
+ require 'twilio-ruby/rest/sip/ip_access_control_lists/ip_addresses'
33
+ require 'twilio-ruby/rest/media'
34
+ require 'twilio-ruby/rest/messages'
25
35
  require 'twilio-ruby/rest/applications'
26
36
  require 'twilio-ruby/rest/connect_apps'
27
37
  require 'twilio-ruby/rest/authorized_connect_apps'
@@ -8,7 +8,7 @@ module Twilio
8
8
  resource :sandbox, :available_phone_numbers, :incoming_phone_numbers,
9
9
  :calls, :outgoing_caller_ids, :conferences, :sms, :recordings,
10
10
  :transcriptions, :notifications, :applications, :connect_apps,
11
- :authorized_connect_apps, :queues, :usage
11
+ :authorized_connect_apps, :queues, :usage, :messages, :media, :sip
12
12
  end
13
13
  end
14
14
  end
@@ -84,9 +84,10 @@ module Twilio
84
84
  end
85
85
 
86
86
  def resource(*resources)
87
+ custom_resource_names = {:sms => 'SMS', :sip => 'SIP'}
87
88
  resources.each do |r|
88
89
  resource = twilify r
89
- relative_path = r == :sms ? 'SMS' : resource
90
+ relative_path = custom_resource_names.fetch(r, resource)
90
91
  path = "#{@path}/#{relative_path}"
91
92
  resource_class = Twilio::REST.const_get resource
92
93
  instance_variable_set("@#{r}", resource_class.new(path, @client))
@@ -3,10 +3,13 @@ module Twilio
3
3
  class ListResource
4
4
  include Utils
5
5
 
6
+
6
7
  def initialize(path, client)
8
+ custom_names = {"Media" => "MediaInstance", "IpAddresses" => "IpAddress"}
7
9
  @path, @client = path, client
8
10
  resource_name = self.class.name.split('::')[-1]
9
- @instance_class = Twilio::REST.const_get resource_name.chop
11
+ instance_name = custom_names.fetch(resource_name, resource_name.chop)
12
+ @instance_class = Twilio::REST.const_get instance_name
10
13
  @list_key, @instance_id_key = detwilify(resource_name), 'sid'
11
14
  end
12
15
 
@@ -0,0 +1,14 @@
1
+ module Twilio
2
+ module REST
3
+ class Media < ListResource
4
+
5
+ def initialize(path, client)
6
+ super
7
+ @list_key = 'media_list'
8
+ end
9
+
10
+ end
11
+
12
+ class MediaInstance < InstanceResource; end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ module Twilio
2
+ module REST
3
+ class Messages < ListResource; end
4
+
5
+ class Message < InstanceResource
6
+ def initialize(path, client, params={})
7
+ super
8
+ resource :media
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Twilio
2
+ module REST
3
+ class Sip < InstanceResource
4
+ def initialize(path, client, params={})
5
+ super
6
+ resource :domains,
7
+ :ip_access_control_lists,
8
+ :credential_lists
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ module Twilio
2
+ module REST
3
+ class CredentialLists < ListResource; end
4
+ class CredentialList < InstanceResource
5
+ def initialize(path, client, params={})
6
+ super
7
+ resource :credentials
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ module Twilio
2
+ module REST
3
+ class Credentials < ListResource; end
4
+ class Credential < InstanceResource; end
5
+ end
6
+ end
@@ -0,0 +1,12 @@
1
+ module Twilio
2
+ module REST
3
+ class Domains < ListResource; end
4
+ class Domain < InstanceResource
5
+ def initialize(path, client, params={})
6
+ super
7
+ resource :ip_access_control_list_mappings,
8
+ :credential_list_mappings
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ module Twilio
2
+ module REST
3
+ class CredentialListMappings < ListResource; end
4
+ class CredentialListMapping < InstanceResource; end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Twilio
2
+ module REST
3
+ class IpAccessControlListMappings < ListResource; end
4
+ class IpAccessControlListMapping < InstanceResource; end
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ module Twilio
2
+ module REST
3
+ class IpAccessControlLists < ListResource; end
4
+ class IpAccessControlList < InstanceResource
5
+ def initialize(path, client, params={})
6
+ super
7
+ resource :ip_addresses
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ module Twilio
2
+ module REST
3
+ class IpAddresses < ListResource; end
4
+ class IpAddress < InstanceResource; end
5
+ end
6
+ end
@@ -2,7 +2,7 @@ module Twilio
2
2
  module REST
3
3
  class Sms < InstanceResource
4
4
  def initialize(path, client, params={})
5
- super path, client, params
5
+ super
6
6
  resource :messages, :short_codes
7
7
  end
8
8
  end
@@ -11,7 +11,7 @@ module Twilio
11
11
  end
12
12
 
13
13
  def method_missing(method, *args)
14
- super unless SUBRESOURCES.include? method
14
+ return super unless SUBRESOURCES.include? method
15
15
  self.class.new "#{@path}/#{twilify(method)}", @client
16
16
  end
17
17
  end
@@ -4,7 +4,7 @@ module Twilio
4
4
 
5
5
  def twilify(something)
6
6
  if something.is_a? Hash
7
- Hash[*something.to_a.map {|a| [twilify(a[0]).to_sym, a[1]]}.flatten]
7
+ Hash[*something.to_a.map {|a| [twilify(a[0]).to_sym, a[1]]}.flatten(1)]
8
8
  else
9
9
  something.to_s.split('_').map do |s|
10
10
  [s[0,1].capitalize, s[1..-1]].join
@@ -1,3 +1,3 @@
1
1
  module Twilio
2
- VERSION = '3.10.1'
2
+ VERSION = '3.11.0'
3
3
  end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Twilio::REST::Message do
4
+ before do
5
+ @message = Twilio::REST::Message.new('someUri', 'someClient')
6
+ end
7
+
8
+ it 'sets up a media resources object' do
9
+ @message.should respond_to(:media)
10
+ @message.media.instance_variable_get('@path').should == 'someUri/Media'
11
+ end
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.1
4
+ version: 3.11.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-25 00:00:00.000000000 Z
12
+ date: 2013-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -134,11 +134,49 @@ extra_rdoc_files:
134
134
  files:
135
135
  - .gitignore
136
136
  - .travis.yml
137
+ - AUTHORS.md
138
+ - CHANGES
137
139
  - Gemfile
138
140
  - LICENSE
141
+ - Makefile
139
142
  - README.md
140
143
  - Rakefile
141
144
  - conf/cacert.pem
145
+ - docs/Makefile
146
+ - docs/_themes/LICENSE
147
+ - docs/_themes/README.rst
148
+ - docs/_themes/flask_theme_support.py
149
+ - docs/_themes/kr/layout.html
150
+ - docs/_themes/kr/relations.html
151
+ - docs/_themes/kr/static/flasky.css_t
152
+ - docs/_themes/kr/static/small_flask.css
153
+ - docs/_themes/kr/theme.conf
154
+ - docs/_themes/kr_small/layout.html
155
+ - docs/_themes/kr_small/static/flasky.css_t
156
+ - docs/_themes/kr_small/theme.conf
157
+ - docs/changelog.rst
158
+ - docs/conf.py
159
+ - docs/faq.rst
160
+ - docs/getting-started.rst
161
+ - docs/index.rst
162
+ - docs/make.bat
163
+ - docs/src/pip-delete-this-directory.txt
164
+ - docs/usage/accounts.rst
165
+ - docs/usage/applications.rst
166
+ - docs/usage/basics.rst
167
+ - docs/usage/caller-ids.rst
168
+ - docs/usage/conferences.rst
169
+ - docs/usage/messages.rst
170
+ - docs/usage/notifications.rst
171
+ - docs/usage/phone-calls.rst
172
+ - docs/usage/phone-numbers.rst
173
+ - docs/usage/queues.rst
174
+ - docs/usage/recordings.rst
175
+ - docs/usage/sip.rst
176
+ - docs/usage/token-generation.rst
177
+ - docs/usage/transcriptions.rst
178
+ - docs/usage/twiml.rst
179
+ - docs/usage/validation.rst
142
180
  - examples/examples.rb
143
181
  - examples/print-call-log.rb
144
182
  - lib/twilio-ruby.rb
@@ -158,12 +196,22 @@ files:
158
196
  - lib/twilio-ruby/rest/incoming_phone_numbers.rb
159
197
  - lib/twilio-ruby/rest/instance_resource.rb
160
198
  - lib/twilio-ruby/rest/list_resource.rb
199
+ - lib/twilio-ruby/rest/media.rb
200
+ - lib/twilio-ruby/rest/messages.rb
161
201
  - lib/twilio-ruby/rest/notifications.rb
162
202
  - lib/twilio-ruby/rest/outgoing_caller_ids.rb
163
203
  - lib/twilio-ruby/rest/queues.rb
164
204
  - lib/twilio-ruby/rest/queues/members.rb
165
205
  - lib/twilio-ruby/rest/recordings.rb
166
206
  - lib/twilio-ruby/rest/sandbox.rb
207
+ - lib/twilio-ruby/rest/sip.rb
208
+ - lib/twilio-ruby/rest/sip/credential_lists.rb
209
+ - lib/twilio-ruby/rest/sip/credential_lists/credentials.rb
210
+ - lib/twilio-ruby/rest/sip/domains.rb
211
+ - lib/twilio-ruby/rest/sip/domains/credential_list_mappings.rb
212
+ - lib/twilio-ruby/rest/sip/domains/ip_access_control_list_mappings.rb
213
+ - lib/twilio-ruby/rest/sip/ip_access_control_lists.rb
214
+ - lib/twilio-ruby/rest/sip/ip_access_control_lists/ip_addresses.rb
167
215
  - lib/twilio-ruby/rest/sms.rb
168
216
  - lib/twilio-ruby/rest/sms/messages.rb
169
217
  - lib/twilio-ruby/rest/sms/short_codes.rb
@@ -182,6 +230,7 @@ files:
182
230
  - spec/rest/client_spec.rb
183
231
  - spec/rest/conference_spec.rb
184
232
  - spec/rest/instance_resource_spec.rb
233
+ - spec/rest/message_spec.rb
185
234
  - spec/rest/queue_spec.rb
186
235
  - spec/rest/recording_spec.rb
187
236
  - spec/spec_helper.rb
@@ -227,6 +276,7 @@ test_files:
227
276
  - spec/rest/instance_resource_spec.rb
228
277
  - spec/rest/recording_spec.rb
229
278
  - spec/rest/account_spec.rb
279
+ - spec/rest/message_spec.rb
230
280
  - spec/rest/client_spec.rb
231
281
  - spec/rest/queue_spec.rb
232
282
  - spec/util/capability_spec.rb