restcomm-ruby 1.2.0
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.
- data/AUTHORS.md +38 -0
- data/CHANGES.md +171 -0
- data/Gemfile +11 -0
- data/LICENSE +662 -0
- data/LICENSE.md +19 -0
- data/Makefile +12 -0
- data/README.md +155 -0
- data/Rakefile +10 -0
- data/conf/cacert.pem +3376 -0
- data/docs/Makefile +130 -0
- data/docs/_themes/LICENSE +45 -0
- data/docs/_themes/README.rst +25 -0
- data/docs/_themes/flask_theme_support.py +86 -0
- data/docs/_themes/kr/layout.html +32 -0
- data/docs/_themes/kr/relations.html +19 -0
- data/docs/_themes/kr/static/flasky.css_t +469 -0
- data/docs/_themes/kr/static/small_flask.css +70 -0
- data/docs/_themes/kr/theme.conf +7 -0
- data/docs/_themes/kr_small/layout.html +22 -0
- data/docs/_themes/kr_small/static/flasky.css_t +287 -0
- data/docs/_themes/kr_small/theme.conf +10 -0
- data/docs/changelog.rst +1 -0
- data/docs/conf.py +266 -0
- data/docs/faq.rst +42 -0
- data/docs/getting-started.rst +100 -0
- data/docs/index.rst +109 -0
- data/docs/make.bat +170 -0
- data/docs/src/pip-delete-this-directory.txt +5 -0
- data/docs/usage/accounts.rst +96 -0
- data/docs/usage/addresses.rst +102 -0
- data/docs/usage/applications.rst +111 -0
- data/docs/usage/basics.rst +120 -0
- data/docs/usage/caller-ids.rst +47 -0
- data/docs/usage/conferences.rst +112 -0
- data/docs/usage/errors.rst +31 -0
- data/docs/usage/messages.rst +142 -0
- data/docs/usage/notifications.rst +72 -0
- data/docs/usage/phone-calls.rst +193 -0
- data/docs/usage/phone-numbers.rst +192 -0
- data/docs/usage/queues.rst +117 -0
- data/docs/usage/recordings.rst +102 -0
- data/docs/usage/sip.rst +108 -0
- data/docs/usage/token-generation.rst +96 -0
- data/docs/usage/transcriptions.rst +34 -0
- data/docs/usage/twiml.rst +69 -0
- data/docs/usage/validation.rst +107 -0
- data/examples/examples.rb +200 -0
- data/examples/print-call-log.rb +25 -0
- data/lib/rack/restcomm_webhook_authentication.rb +47 -0
- data/lib/restcomm-ruby.rb +103 -0
- data/lib/restcomm-ruby/rest/accounts.rb +17 -0
- data/lib/restcomm-ruby/rest/addresses.rb +12 -0
- data/lib/restcomm-ruby/rest/addresses/dependent_phone_numbers.rb +6 -0
- data/lib/restcomm-ruby/rest/applications.rb +6 -0
- data/lib/restcomm-ruby/rest/authorized_connect_apps.rb +6 -0
- data/lib/restcomm-ruby/rest/available_phone_numbers.rb +13 -0
- data/lib/restcomm-ruby/rest/available_phone_numbers/country.rb +10 -0
- data/lib/restcomm-ruby/rest/available_phone_numbers/local.rb +11 -0
- data/lib/restcomm-ruby/rest/available_phone_numbers/mobile.rb +11 -0
- data/lib/restcomm-ruby/rest/available_phone_numbers/toll_free.rb +11 -0
- data/lib/restcomm-ruby/rest/call_feedback.rb +28 -0
- data/lib/restcomm-ruby/rest/call_feedback_summary.rb +13 -0
- data/lib/restcomm-ruby/rest/calls.rb +37 -0
- data/lib/restcomm-ruby/rest/client.rb +555 -0
- data/lib/restcomm-ruby/rest/conferences.rb +12 -0
- data/lib/restcomm-ruby/rest/conferences/participants.rb +23 -0
- data/lib/restcomm-ruby/rest/connect_apps.rb +6 -0
- data/lib/restcomm-ruby/rest/errors.rb +14 -0
- data/lib/restcomm-ruby/rest/incoming_phone_numbers.rb +17 -0
- data/lib/restcomm-ruby/rest/incoming_phone_numbers/local.rb +13 -0
- data/lib/restcomm-ruby/rest/incoming_phone_numbers/mobile.rb +13 -0
- data/lib/restcomm-ruby/rest/incoming_phone_numbers/toll_free.rb +13 -0
- data/lib/restcomm-ruby/rest/instance_resource.rb +88 -0
- data/lib/restcomm-ruby/rest/list_resource.rb +132 -0
- data/lib/restcomm-ruby/rest/media.rb +14 -0
- data/lib/restcomm-ruby/rest/messages.rb +23 -0
- data/lib/restcomm-ruby/rest/next_gen_list_resource.rb +29 -0
- data/lib/restcomm-ruby/rest/notifications.rb +6 -0
- data/lib/restcomm-ruby/rest/outgoing_caller_ids.rb +25 -0
- data/lib/restcomm-ruby/rest/queues.rb +12 -0
- data/lib/restcomm-ruby/rest/queues/members.rb +29 -0
- data/lib/restcomm-ruby/rest/recordings.rb +35 -0
- data/lib/restcomm-ruby/rest/sandbox.rb +5 -0
- data/lib/restcomm-ruby/rest/sip.rb +10 -0
- data/lib/restcomm-ruby/rest/sip/credential_lists.rb +11 -0
- data/lib/restcomm-ruby/rest/sip/credential_lists/credentials.rb +6 -0
- data/lib/restcomm-ruby/rest/sip/domains.rb +12 -0
- data/lib/restcomm-ruby/rest/sip/domains/credential_list_mappings.rb +6 -0
- data/lib/restcomm-ruby/rest/sip/domains/ip_access_control_list_mappings.rb +6 -0
- data/lib/restcomm-ruby/rest/sip/ip_access_control_lists.rb +11 -0
- data/lib/restcomm-ruby/rest/sip/ip_access_control_lists/ip_addresses.rb +6 -0
- data/lib/restcomm-ruby/rest/sms.rb +11 -0
- data/lib/restcomm-ruby/rest/sms/messages.rb +39 -0
- data/lib/restcomm-ruby/rest/sms/short_codes.rb +8 -0
- data/lib/restcomm-ruby/rest/task_router/activities.rb +8 -0
- data/lib/restcomm-ruby/rest/task_router/events.rb +8 -0
- data/lib/restcomm-ruby/rest/task_router/reservations.rb +8 -0
- data/lib/restcomm-ruby/rest/task_router/task_queues.rb +8 -0
- data/lib/restcomm-ruby/rest/task_router/task_queues_statistics.rb +15 -0
- data/lib/restcomm-ruby/rest/task_router/tasks.rb +15 -0
- data/lib/restcomm-ruby/rest/task_router/workers.rb +8 -0
- data/lib/restcomm-ruby/rest/task_router/workers_statistics.rb +8 -0
- data/lib/restcomm-ruby/rest/task_router/workflow_statistics.rb +7 -0
- data/lib/restcomm-ruby/rest/task_router/workflows.rb +8 -0
- data/lib/restcomm-ruby/rest/task_router/workspace_statistics.rb +7 -0
- data/lib/restcomm-ruby/rest/task_router/workspaces.rb +15 -0
- data/lib/restcomm-ruby/rest/tokens.rb +7 -0
- data/lib/restcomm-ruby/rest/transcriptions.rb +6 -0
- data/lib/restcomm-ruby/rest/usage.rb +10 -0
- data/lib/restcomm-ruby/rest/usage/records.rb +21 -0
- data/lib/restcomm-ruby/rest/usage/triggers.rb +12 -0
- data/lib/restcomm-ruby/rest/utils.rb +49 -0
- data/lib/restcomm-ruby/task_router.rb +0 -0
- data/lib/restcomm-ruby/task_router/capability.rb +87 -0
- data/lib/restcomm-ruby/twiml/response.rb +16 -0
- data/lib/restcomm-ruby/util.rb +15 -0
- data/lib/restcomm-ruby/util/capability.rb +64 -0
- data/lib/restcomm-ruby/util/configuration.rb +7 -0
- data/lib/restcomm-ruby/util/request_validator.rb +37 -0
- data/lib/restcomm-ruby/version.rb +3 -0
- data/restcomm-ruby.gemspec +34 -0
- data/spec/rack/twilio_webhook_authentication_spec.rb +110 -0
- data/spec/rest/account_spec.rb +89 -0
- data/spec/rest/address_spec.rb +11 -0
- data/spec/rest/call_feedback_spec.rb +12 -0
- data/spec/rest/call_feedback_summary_spec.rb +9 -0
- data/spec/rest/call_spec.rb +22 -0
- data/spec/rest/client_spec.rb +258 -0
- data/spec/rest/conference_spec.rb +11 -0
- data/spec/rest/instance_resource_spec.rb +15 -0
- data/spec/rest/message_spec.rb +12 -0
- data/spec/rest/numbers_spec.rb +58 -0
- data/spec/rest/queue_spec.rb +11 -0
- data/spec/rest/recording_spec.rb +11 -0
- data/spec/rest/sms/message_spec.rb +37 -0
- data/spec/rest/sms/messages_spec.rb +36 -0
- data/spec/rest/task_router/reservation_spec.rb +9 -0
- data/spec/rest/task_router/task_queue_spec.rb +9 -0
- data/spec/rest/token_spec.rb +7 -0
- data/spec/rest/utils_spec.rb +45 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/fakeweb.rb +2 -0
- data/spec/task_router_spec.rb +114 -0
- data/spec/twilio_spec.rb +15 -0
- data/spec/util/capability_spec.rb +186 -0
- data/spec/util/configuration_spec.rb +13 -0
- data/spec/util/request_validator_spec.rb +93 -0
- data/spec/util/url_encode_spec.rb +12 -0
- metadata +298 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Restcomm
|
|
2
|
+
module REST
|
|
3
|
+
class Participants < ListResource
|
|
4
|
+
def initialize(path, client)
|
|
5
|
+
super
|
|
6
|
+
# hard-code the json key since participants don't have sids
|
|
7
|
+
@instance_id_key = 'call_sid'
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class Participant < InstanceResource
|
|
12
|
+
def mute
|
|
13
|
+
update muted: 'true'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def unmute
|
|
17
|
+
update muted: 'false'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
alias :kick :delete
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Restcomm
|
|
2
|
+
module REST
|
|
3
|
+
class IncomingPhoneNumbers < ListResource
|
|
4
|
+
def initialize(path, client)
|
|
5
|
+
super
|
|
6
|
+
@submodule = :NumberType
|
|
7
|
+
resource :mobile, :local, :toll_free
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def buy(phone_number)
|
|
11
|
+
create phone_number: phone_number
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class IncomingPhoneNumber < InstanceResource; end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Restcomm
|
|
2
|
+
module REST
|
|
3
|
+
module NumberType
|
|
4
|
+
class Local < ListResource
|
|
5
|
+
def initialize(path, client)
|
|
6
|
+
@path, @client = path, client
|
|
7
|
+
@instance_class = Restcomm::REST::IncomingPhoneNumber
|
|
8
|
+
@list_key, @instance_id_key = 'incoming_phone_numbers', 'sid'
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Restcomm
|
|
2
|
+
module REST
|
|
3
|
+
module NumberType
|
|
4
|
+
class Mobile < ListResource
|
|
5
|
+
def initialize(path, client)
|
|
6
|
+
@path, @client = path, client
|
|
7
|
+
@instance_class = Restcomm::REST::IncomingPhoneNumber
|
|
8
|
+
@list_key, @instance_id_key = 'incoming_phone_numbers', 'sid'
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Restcomm
|
|
2
|
+
module REST
|
|
3
|
+
module NumberType
|
|
4
|
+
class TollFree < ListResource
|
|
5
|
+
def initialize(path, client)
|
|
6
|
+
@path, @client = path, client
|
|
7
|
+
@instance_class = Restcomm::REST::IncomingPhoneNumber
|
|
8
|
+
@list_key, @instance_id_key = 'incoming_phone_numbers', 'sid'
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
module Restcomm
|
|
2
|
+
module REST
|
|
3
|
+
##
|
|
4
|
+
# A class to wrap an instance resource (like a call or application) within
|
|
5
|
+
# the Restcomm API. All other instance resource classes within this library
|
|
6
|
+
# inherit from this class. You shouldn't need to instantiate this class
|
|
7
|
+
# directly. But reviewing the available methods is informative since they
|
|
8
|
+
# are rarely overridden in the inheriting class.
|
|
9
|
+
class InstanceResource
|
|
10
|
+
include Utils
|
|
11
|
+
|
|
12
|
+
##
|
|
13
|
+
# Instantiate a new instance resource object. You must pass the +path+ of
|
|
14
|
+
# the instance (e.g. /2010-04-01/Accounts/AC123/Calls/CA456) as well as a
|
|
15
|
+
# +client+ object that responds to #get #post and #delete. This client
|
|
16
|
+
# is meant to be an instance of Restcomm::REST::Client but could just as
|
|
17
|
+
# well be a mock object if you want to test the interface. The optional
|
|
18
|
+
# +params+ hash will be converted into attributes on the instantiated
|
|
19
|
+
# object.
|
|
20
|
+
def initialize(path, client, params = {})
|
|
21
|
+
@path, @client = path, client
|
|
22
|
+
set_up_properties_from params
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def inspect # :nodoc:
|
|
26
|
+
"<#{self.class} @path=#{@path}>"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
##
|
|
30
|
+
# Update the properties of this instance resource using the key/value
|
|
31
|
+
# pairs in +params+. This makes an HTTP POST request to <tt>@path</tt>
|
|
32
|
+
# to handle the update. For example, to update the +VoiceUrl+ of a Restcomm
|
|
33
|
+
# Application you could write:
|
|
34
|
+
#
|
|
35
|
+
# @app.update voice_url: 'http://my.other.app.com/handle_voice'
|
|
36
|
+
#
|
|
37
|
+
# After returning, the object will contain the most recent state of the
|
|
38
|
+
# instance resource, including the newly updated properties.
|
|
39
|
+
def update(params = {})
|
|
40
|
+
raise "Can't update a resource without a REST Client" unless @client
|
|
41
|
+
set_up_properties_from(@client.post(@path, params))
|
|
42
|
+
#self
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# Refresh the attributes of this instance resource object by fetching it
|
|
47
|
+
# from Restcomm. Calling this makes an HTTP GET request to <tt>@path</tt>.
|
|
48
|
+
def refresh
|
|
49
|
+
raise "Can't refresh a resource without a REST Client" unless @client
|
|
50
|
+
@updated = false
|
|
51
|
+
set_up_properties_from(@client.get(@path))
|
|
52
|
+
self
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
##
|
|
56
|
+
# Delete an instance resource from Restcomm. This operation isn't always
|
|
57
|
+
# supported. For instance, you can't delete an SMS. Calling this method
|
|
58
|
+
# makes an HTTP DELETE request to <tt>@path</tt>.
|
|
59
|
+
def delete
|
|
60
|
+
raise "Can't delete a resource without a REST Client" unless @client
|
|
61
|
+
@client.delete @path
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
##
|
|
66
|
+
# Lazily load attributes of the instance resource by waiting to fetch it
|
|
67
|
+
# until an attempt is made to access an unknown attribute.
|
|
68
|
+
def method_missing(method, *args)
|
|
69
|
+
super if @updated
|
|
70
|
+
set_up_properties_from(@client.get(@path))
|
|
71
|
+
self.send method, *args
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
protected
|
|
75
|
+
|
|
76
|
+
def set_up_properties_from(hash)
|
|
77
|
+
eigenclass = class << self; self; end
|
|
78
|
+
hash.each do |p,v|
|
|
79
|
+
property = derestify p
|
|
80
|
+
unless ['client', 'updated'].include? property
|
|
81
|
+
eigenclass.send :define_method, property.to_sym, &lambda { v }
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
@updated = !hash.keys.empty?
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require 'rubygems'
|
|
3
|
+
module Restcomm
|
|
4
|
+
module REST
|
|
5
|
+
class ListResource
|
|
6
|
+
include Utils
|
|
7
|
+
|
|
8
|
+
def initialize(path, client)
|
|
9
|
+
custom_names = {
|
|
10
|
+
'Activities' => 'Activity',
|
|
11
|
+
'Media' => 'MediaInstance',
|
|
12
|
+
'IpAddresses' => 'IpAddress',
|
|
13
|
+
'Feedback' => 'FeedbackInstance',
|
|
14
|
+
'Addresses' => 'Address'
|
|
15
|
+
}
|
|
16
|
+
@path, @client = path, client
|
|
17
|
+
|
|
18
|
+
resource_name = self.class.name.split('::')[-1]
|
|
19
|
+
|
|
20
|
+
instance_name = custom_names.fetch(resource_name, resource_name.chop)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# The next line grabs the enclosing module. Necessary for resources
|
|
24
|
+
# contained in their own submodule like /SMS/Messages
|
|
25
|
+
parent_module = self.class.to_s.split('::')[-2]
|
|
26
|
+
full_module_path = if parent_module == "REST"
|
|
27
|
+
Restcomm::REST
|
|
28
|
+
else
|
|
29
|
+
Restcomm::REST.const_get(parent_module)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
@instance_class = full_module_path.const_get(instance_name)
|
|
33
|
+
|
|
34
|
+
@list_key, @instance_id_key = derestify(resource_name), 'sid'
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def inspect # :nodoc:
|
|
39
|
+
"<#{self.class} @path=#{@path}>"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
##
|
|
43
|
+
# Grab a list of this kind of resource and return it as an array. The
|
|
44
|
+
# array includes a special attribute named +total+ which will return the
|
|
45
|
+
# total number of items in the list on Restcomm's server. This may differ
|
|
46
|
+
# from the +size+ and +length+ attributes of the returned array since
|
|
47
|
+
# by default Restcomm will only return 50 resources, and the maximum number
|
|
48
|
+
# of resources you can request is 1000.
|
|
49
|
+
#
|
|
50
|
+
# The optional +params+ hash allows you to filter the list returned. The
|
|
51
|
+
# filters for each list resource type are defined by Restcomm.
|
|
52
|
+
def list(params={}, full_path=false)
|
|
53
|
+
raise "Can't get a resource list without a REST Client" unless @client
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
response = @client.get( @path, params, full_path)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if @list_key == "calls"
|
|
60
|
+
resources = response[@list_key]
|
|
61
|
+
elsif @list_key == "recordings"
|
|
62
|
+
resources = response
|
|
63
|
+
else
|
|
64
|
+
resources = response
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
path = full_path ? @path.split('.')[0] : @path
|
|
68
|
+
|
|
69
|
+
resource_list = resources.map do |resource|
|
|
70
|
+
@instance_class.new("#{path}/#{resource[@instance_id_key]}", @client, resource)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# set the +total+ and +next_page+ properties on the array
|
|
75
|
+
client, list_class = @client, self.class
|
|
76
|
+
resource_list.instance_eval do
|
|
77
|
+
eigenclass = class << self; self; end
|
|
78
|
+
eigenclass.send :define_method, :total, &lambda { response['total'] }
|
|
79
|
+
eigenclass.send :define_method, :next_page, &lambda {
|
|
80
|
+
if response['next_page_uri']
|
|
81
|
+
list_class.new(response['next_page_uri'], client).list({}, true)
|
|
82
|
+
else
|
|
83
|
+
[]
|
|
84
|
+
end
|
|
85
|
+
}
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
resource_list
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
##
|
|
96
|
+
# Ask Restcomm for the total number of items in the list.
|
|
97
|
+
# Calling this method makes an HTTP GET request to <tt>@path</tt> with a
|
|
98
|
+
# page size parameter of 1 to minimize data over the wire while still
|
|
99
|
+
# obtaining the total. Don't use this if you are planning to
|
|
100
|
+
# call #list anyway, since the array returned from #list will have a
|
|
101
|
+
# +total+ attribute as well.
|
|
102
|
+
def total
|
|
103
|
+
raise "Can't get a resource total without a REST Client" unless @client
|
|
104
|
+
@client.get(@path, page_size: 1)['total']
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
##
|
|
108
|
+
# Return an empty instance resource object with the proper path. Note that
|
|
109
|
+
# this will never raise a Restcomm::REST::RequestError on 404 since no HTTP
|
|
110
|
+
# request is made. The HTTP request is made when attempting to access an
|
|
111
|
+
# attribute of the returned instance resource object, such as
|
|
112
|
+
# its #date_created or #voice_url attributes.
|
|
113
|
+
def get(sid)
|
|
114
|
+
@instance_class.new "#{@path}/#{sid}", @client
|
|
115
|
+
end
|
|
116
|
+
alias :find :get # for the ActiveRecord lovers
|
|
117
|
+
|
|
118
|
+
##
|
|
119
|
+
# Return a newly created resource. Some +params+ may be required. Consult
|
|
120
|
+
# the Restcomm REST API documentation related to the kind of resource you
|
|
121
|
+
# are attempting to create for details. Calling this method makes an HTTP
|
|
122
|
+
# POST request to <tt>@path</tt> with the given params
|
|
123
|
+
def create(params={})
|
|
124
|
+
raise "Can't create a resource without a REST Client" unless @client
|
|
125
|
+
response = @client.post @path, params
|
|
126
|
+
@instance_class.new "#{@path}/#{response[@instance_id_key]}", @client,
|
|
127
|
+
|
|
128
|
+
response
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Restcomm
|
|
2
|
+
module REST
|
|
3
|
+
class Messages < ListResource
|
|
4
|
+
def initialize(path, client)
|
|
5
|
+
# path.gsub! '/SMS', ''
|
|
6
|
+
path.gsub! '/Messages', '/SMS/Messages'
|
|
7
|
+
super
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class Message < InstanceResource
|
|
12
|
+
def initialize(path, client, params={})
|
|
13
|
+
super
|
|
14
|
+
resource :media
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def redact()
|
|
18
|
+
update({body: ''})
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Restcomm
|
|
2
|
+
module REST
|
|
3
|
+
class NextGenListResource < Restcomm::REST::ListResource
|
|
4
|
+
def list(params={}, full_path=false)
|
|
5
|
+
raise "Can't get a resource list without a REST Client" unless @client
|
|
6
|
+
response = @client.get @path, params, full_path
|
|
7
|
+
list_key = response['meta']['key']
|
|
8
|
+
raise "Couldn't find a list key in response meta" unless list_key
|
|
9
|
+
resources = response[list_key]
|
|
10
|
+
resource_list = resources.map do |resource|
|
|
11
|
+
@instance_class.new "#{@path}/#{resource[@instance_id_key]}", @client,
|
|
12
|
+
resource
|
|
13
|
+
end
|
|
14
|
+
client, list_class = @client, self.class
|
|
15
|
+
resource_list.instance_eval do
|
|
16
|
+
eigenclass = class << self; self; end
|
|
17
|
+
eigenclass.send :define_method, :next_page, &lambda {
|
|
18
|
+
if response['meta']['next_page_url']
|
|
19
|
+
list_class.new(response['meta']['next_page_url'], client).list({})
|
|
20
|
+
else
|
|
21
|
+
[]
|
|
22
|
+
end
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
resource_list
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Restcomm
|
|
2
|
+
module REST
|
|
3
|
+
class OutgoingCallerIds < ListResource
|
|
4
|
+
def add(phone_number)
|
|
5
|
+
create phone_number: phone_number
|
|
6
|
+
end
|
|
7
|
+
alias :verify :add
|
|
8
|
+
|
|
9
|
+
##
|
|
10
|
+
# Override ListResource#create to instantiate the proper instance class.
|
|
11
|
+
# This doesn't actually matter since all properties are lazily loaded into
|
|
12
|
+
# whatever object is instantiated. But it might matter in the future.
|
|
13
|
+
def create(params={}) # :nodoc:
|
|
14
|
+
old_instance_class = @instance_class
|
|
15
|
+
@instance_class = Restcomm::REST::PhoneNumberVerificationRequest
|
|
16
|
+
verification_request = super
|
|
17
|
+
@instance_class = old_instance_class
|
|
18
|
+
verification_request
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class OutgoingCallerId < InstanceResource; end
|
|
23
|
+
class PhoneNumberVerificationRequest < InstanceResource; end
|
|
24
|
+
end
|
|
25
|
+
end
|