restcomm-ruby 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Restcomm::REST::Address do
|
4
|
+
it 'should set up a dependent phone numbers resources object' do
|
5
|
+
address = Restcomm::REST::Address.new('someUri', 'someClient')
|
6
|
+
expect(address).to respond_to(:dependent_phone_numbers)
|
7
|
+
expect(address.dependent_phone_numbers.instance_variable_get('@path')).to eq(
|
8
|
+
'someUri/DependentPhoneNumbers'
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Restcomm::REST::Feedback do
|
4
|
+
before do
|
5
|
+
@call = Restcomm::REST::Call.new('someUri', 'someClient')
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'sets up a feedback resources object' do
|
9
|
+
expect(@call).to respond_to(:feedback)
|
10
|
+
expect(@call.feedback.instance_variable_get('@path')).to eq('someUri/Feedback')
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Restcomm::REST::FeedbackSummary do
|
4
|
+
it 'creates a feedback summary object' do
|
5
|
+
calls = Restcomm::REST::Calls.new('someUri', 'someClient')
|
6
|
+
expect(calls).to respond_to(:feedback_summary)
|
7
|
+
expect(calls.feedback_summary.instance_variable_get('@path')).to eq('someUri/FeedbackSummary')
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Restcomm::REST::Call do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@call = Restcomm::REST::Call.new('someUri', 'someClient')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'sets up a recordings resources object' do
|
10
|
+
expect(@call).to respond_to(:recordings)
|
11
|
+
expect(@call.recordings.instance_variable_get('@path')).to eq(
|
12
|
+
'someUri/Recordings'
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'sets up a notifications resources object' do
|
17
|
+
expect(@call).to respond_to(:notifications)
|
18
|
+
expect(@call.notifications.instance_variable_get('@path')).to eq(
|
19
|
+
'someUri/Notifications'
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,258 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Restcomm::REST::Client do
|
4
|
+
describe 'config at class level' do
|
5
|
+
after(:each) do
|
6
|
+
Restcomm.instance_variable_set('@configuration', nil)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should set the account sid and auth token with a config block' do
|
10
|
+
Restcomm.configure do |config|
|
11
|
+
config.account_sid = 'someSid'
|
12
|
+
config.auth_token = 'someToken'
|
13
|
+
end
|
14
|
+
|
15
|
+
client = Restcomm::REST::Client.new
|
16
|
+
expect(client.account_sid).to eq('someSid')
|
17
|
+
expect(client.instance_variable_get('@auth_token')).to eq('someToken')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should overwrite account sid and auth token if passed to initializer' do
|
21
|
+
Restcomm.configure do |config|
|
22
|
+
config.account_sid = 'someSid'
|
23
|
+
config.auth_token = 'someToken'
|
24
|
+
end
|
25
|
+
|
26
|
+
client = Restcomm::REST::Client.new 'otherSid', 'otherToken'
|
27
|
+
expect(client.account_sid).to eq('otherSid')
|
28
|
+
expect(client.instance_variable_get('@auth_token')).to eq('otherToken')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should overwrite the account sid if only the sid is given' do
|
32
|
+
Restcomm.configure do |config|
|
33
|
+
config.account_sid = 'someSid'
|
34
|
+
config.auth_token = 'someToken'
|
35
|
+
end
|
36
|
+
|
37
|
+
client = Restcomm::REST::Client.new 'otherSid'
|
38
|
+
expect(client.account_sid).to eq('otherSid')
|
39
|
+
expect(client.instance_variable_get('@auth_token')).to eq('someToken')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should allow options after setting up auth with config' do
|
43
|
+
Restcomm.configure do |config|
|
44
|
+
config.account_sid = 'someSid'
|
45
|
+
config.auth_token = 'someToken'
|
46
|
+
end
|
47
|
+
|
48
|
+
client = Restcomm::REST::Client.new :host => 'api.fakerestcomm.com'
|
49
|
+
|
50
|
+
connection = client.instance_variable_get('@connection')
|
51
|
+
expect(connection.address).to eq('api.fakerestcomm.com')
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should throw an argument error if the sid and token isn\'t set' do
|
55
|
+
expect { Restcomm::REST::Client.new }.to raise_error(ArgumentError)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should throw an argument error if only the account_sid is set' do
|
59
|
+
expect { Restcomm::REST::Client.new 'someSid' }.to raise_error(ArgumentError)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should not raise an error if the response body is empty' do
|
64
|
+
FakeWeb.register_uri(:any, %r/api\.restcomm\.com/, body: '')
|
65
|
+
restcomm = Restcomm::REST::Client.new('someSid', 'someToken')
|
66
|
+
Restcomm::REST::IncomingPhoneNumber.new('/phone_number', restcomm).delete
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should not raise an error if the response body is nil' do
|
70
|
+
response = double(:response, body: nil)
|
71
|
+
connection = double(:connection, request: response)
|
72
|
+
restcomm = Restcomm::REST::Client.new('someSid', 'someToken')
|
73
|
+
restcomm.instance_variable_set(:@connection, connection)
|
74
|
+
Restcomm::REST::IncomingPhoneNumber.new('/phone_number', restcomm).delete
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should set up a new client instance with the given sid and token' do
|
78
|
+
restcomm = Restcomm::REST::Client.new('someSid', 'someToken')
|
79
|
+
expect(restcomm.account_sid).to eq('someSid')
|
80
|
+
expect(restcomm.instance_variable_get('@auth_token')).to eq('someToken')
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should set up the proper default http ssl connection' do
|
84
|
+
restcomm = Restcomm::REST::Client.new('someSid', 'someToken')
|
85
|
+
connection = restcomm.instance_variable_get('@connection')
|
86
|
+
expect(connection.address).to eq('api.restcomm.com')
|
87
|
+
expect(connection.port).to eq(443)
|
88
|
+
expect(connection.use_ssl?).to eq(true)
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should set up the requested ssl verification ca_file if provided' do
|
92
|
+
restcomm = Restcomm::REST::Client.new(
|
93
|
+
'someSid', 'someToken', ssl_ca_file: '/path/to/ca/file'
|
94
|
+
)
|
95
|
+
connection = restcomm.instance_variable_get('@connection')
|
96
|
+
expect(connection.ca_file).to eq('/path/to/ca/file')
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should set up the proper http ssl connection when a different ' \
|
100
|
+
'domain is given' do
|
101
|
+
restcomm = Restcomm::REST::Client.new(
|
102
|
+
'someSid', 'someToken', host: 'api.fakerestcomm.com'
|
103
|
+
)
|
104
|
+
connection = restcomm.instance_variable_get('@connection')
|
105
|
+
expect(connection.address).to eq('api.fakerestcomm.com')
|
106
|
+
expect(connection.port).to eq(443)
|
107
|
+
expect(connection.use_ssl?).to eq(true)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should adjust the open and read timeouts on the underlying Net::HTTP ' \
|
111
|
+
'object when asked' do
|
112
|
+
timeout = rand(30)
|
113
|
+
restcomm = Restcomm::REST::Client.new('someSid', 'someToken', timeout: timeout)
|
114
|
+
connection = restcomm.instance_variable_get('@connection')
|
115
|
+
expect(connection.port).to eq(443)
|
116
|
+
expect(connection.use_ssl?).to eq(true)
|
117
|
+
expect(connection.open_timeout).to eq(timeout)
|
118
|
+
expect(connection.read_timeout).to eq(timeout)
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'should set up the proper http ssl connection when a proxy_host is ' \
|
122
|
+
'given' do
|
123
|
+
restcomm = Restcomm::REST::Client.new(
|
124
|
+
'someSid',
|
125
|
+
'someToken',
|
126
|
+
host: 'api.fakerestcomm.com',
|
127
|
+
proxy_addr: 'localhost'
|
128
|
+
)
|
129
|
+
connection = restcomm.instance_variable_get('@connection')
|
130
|
+
expect(connection.proxy?).to eq(true)
|
131
|
+
expect(connection.proxy_address).to eq('localhost')
|
132
|
+
expect(connection.proxy_port).to eq(80)
|
133
|
+
expect(connection.address).to eq('api.fakerestcomm.com')
|
134
|
+
expect(connection.port).to eq(443)
|
135
|
+
expect(connection.use_ssl?).to eq(true)
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should set up the proper http ssl connection when a proxy_host and ' \
|
139
|
+
'proxy_port are given' do
|
140
|
+
restcomm = Restcomm::REST::Client.new(
|
141
|
+
'someSid',
|
142
|
+
'someToken',
|
143
|
+
host: 'api.fakerestcomm.com',
|
144
|
+
proxy_addr: 'localhost',
|
145
|
+
proxy_port: 13128
|
146
|
+
)
|
147
|
+
connection = restcomm.instance_variable_get('@connection')
|
148
|
+
expect(connection.proxy?).to eq(true)
|
149
|
+
expect(connection.proxy_address).to eq('localhost')
|
150
|
+
expect(connection.proxy_port).to eq(13128)
|
151
|
+
expect(connection.address).to eq('api.fakerestcomm.com')
|
152
|
+
expect(connection.port).to eq(443)
|
153
|
+
expect(connection.use_ssl?).to eq(true)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should set up an accounts resources object' do
|
157
|
+
restcomm = Restcomm::REST::Client.new('someSid', 'someToken')
|
158
|
+
expect(restcomm).to respond_to(:accounts)
|
159
|
+
expect(restcomm.accounts.instance_variable_get('@path')).to eq(
|
160
|
+
'/2010-04-01/Accounts'
|
161
|
+
)
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should set up an account object with the given sid' do
|
165
|
+
restcomm = Restcomm::REST::Client.new('someSid', 'someToken')
|
166
|
+
expect(restcomm).to respond_to(:account)
|
167
|
+
expect(restcomm.account.instance_variable_get('@path')).to eq(
|
168
|
+
'/2010-04-01/Accounts/someSid'
|
169
|
+
)
|
170
|
+
end
|
171
|
+
|
172
|
+
[
|
173
|
+
:sandbox, :available_phone_numbers, :incoming_phone_numbers,
|
174
|
+
:calls, :outgoing_caller_ids, :conferences, :sms, :recordings,
|
175
|
+
:transcriptions, :notifications, :applications, :connect_apps,
|
176
|
+
:authorized_connect_apps, :queues, :usage, :messages, :media, :sip
|
177
|
+
].each do |method|
|
178
|
+
it "should delegate the client method #{method} to the account object" do
|
179
|
+
client = Restcomm::REST::Client.new('someSid', 'someToken')
|
180
|
+
expect(client).to respond_to(method)
|
181
|
+
expect(client.send(method)).to eq(client.account.send(method))
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should throw an argument error if the workspace_sid is not set' do
|
186
|
+
expect { Restcomm::REST::TaskRouterClient.new 'someSid', 'someToken' }.to raise_error(ArgumentError)
|
187
|
+
end
|
188
|
+
|
189
|
+
it 'should have its host set to taskrouter.restcomm.com' do
|
190
|
+
client = Restcomm::REST::TaskRouterClient.new('someSid', 'someToken', 'someSid')
|
191
|
+
connection = client.instance_variable_get('@connection')
|
192
|
+
expect(connection.address).to eq('taskrouter.restcomm.com')
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'should have task queue statistics resource' do
|
196
|
+
FakeWeb.register_uri(:get, %r/taskrouter\.restcomm\.com/, body: '{}')
|
197
|
+
client = Restcomm::REST::TaskRouterClient.new('someSid', 'someToken', 'someSid')
|
198
|
+
expect(client).to respond_to(:task_queue_statistics)
|
199
|
+
expect(client.task_queue_statistics('someSid').instance_variable_get('@path')).to eq('/v1/Workspaces/someSid/TaskQueues/someSid/Statistics')
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'should have task queues statistics resource' do
|
203
|
+
FakeWeb.register_uri(:get, %r/taskrouter\.restcomm\.com/, body: '{"meta": {"key": "task_queues_statistics"}, "task_queues_statistics": [{"task_queue_sid": "WQ123"}]}')
|
204
|
+
client = Restcomm::REST::TaskRouterClient.new('someSid', 'someToken', 'someSid')
|
205
|
+
expect(client).to respond_to(:task_queues_statistics)
|
206
|
+
expect(client.task_queues_statistics[0].task_queue_sid).to eq('WQ123')
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'should have worker statistics resource' do
|
210
|
+
FakeWeb.register_uri(:get, %r/taskrouter\.restcomm\.com/, body: '{}')
|
211
|
+
client = Restcomm::REST::TaskRouterClient.new('someSid', 'someToken', 'someSid')
|
212
|
+
expect(client).to respond_to(:worker_statistics)
|
213
|
+
expect(client.worker_statistics('someSid').instance_variable_get('@path')).to eq('/v1/Workspaces/someSid/Workers/someSid/Statistics')
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'should have workers statistics resource' do
|
217
|
+
FakeWeb.register_uri(:get, %r/taskrouter\.restcomm\.com/, body: '{}')
|
218
|
+
client = Restcomm::REST::TaskRouterClient.new('someSid', 'someToken', 'someSid')
|
219
|
+
expect(client).to respond_to(:workers_statistics)
|
220
|
+
expect(client.workers_statistics.instance_variable_get('@path')).to eq('/v1/Workspaces/someSid/Workers/Statistics')
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'should have workflow statistics resource' do
|
224
|
+
FakeWeb.register_uri(:get, %r/taskrouter\.restcomm\.com/, body: '{}')
|
225
|
+
client = Restcomm::REST::TaskRouterClient.new('someSid', 'someToken', 'someSid')
|
226
|
+
expect(client).to respond_to(:workflow_statistics)
|
227
|
+
expect(client.workflow_statistics('someSid').instance_variable_get('@path')).to eq('/v1/Workspaces/someSid/Workflows/someSid/Statistics')
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'should have workspace statistics resource' do
|
231
|
+
FakeWeb.register_uri(:get, %r/taskrouter\.restcomm\.com/, body: '{}')
|
232
|
+
client = Restcomm::REST::TaskRouterClient.new('someSid', 'someToken', 'someSid')
|
233
|
+
expect(client).to respond_to(:workspace_statistics)
|
234
|
+
expect(client.workspace_statistics.instance_variable_get('@path')).to eq('/v1/Workspaces/someSid/Statistics')
|
235
|
+
end
|
236
|
+
|
237
|
+
it 'should set up a workspaces resource object' do
|
238
|
+
client = Restcomm::REST::TaskRouterClient.new('someSid', 'someToken', 'someSid')
|
239
|
+
expect(client).to respond_to(:workspaces)
|
240
|
+
expect(client.workspaces.instance_variable_get('@path')).to eq('/v1/Workspaces')
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'should set up a workspace resource object' do
|
244
|
+
client = Restcomm::REST::TaskRouterClient.new('someSid', 'someToken', 'someSid')
|
245
|
+
expect(client).to respond_to(:workspace)
|
246
|
+
expect(client.workspace.instance_variable_get('@path')).to eq('/v1/Workspaces/someSid')
|
247
|
+
end
|
248
|
+
|
249
|
+
[
|
250
|
+
:activities, :tasks, :task_queues, :workers, :workflows
|
251
|
+
].each do |method|
|
252
|
+
it "should delegate the client method #{method} to the workspace object" do
|
253
|
+
client = Restcomm::REST::TaskRouterClient.new('someSid', 'someToken', 'someSid')
|
254
|
+
expect(client).to respond_to(method)
|
255
|
+
expect(client.send(method)).to eq(client.workspace.send(method))
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Restcomm::REST::Conference do
|
4
|
+
it 'should set up a participants resources object' do
|
5
|
+
conference = Restcomm::REST::Conference.new('someUri', 'someClient')
|
6
|
+
expect(conference).to respond_to(:participants)
|
7
|
+
expect(conference.participants.instance_variable_get('@path')).to eq(
|
8
|
+
'someUri/Participants'
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Restcomm::REST::InstanceResource do
|
4
|
+
it 'should set up an internal reference to the uri and client' do
|
5
|
+
resource = Restcomm::REST::InstanceResource.new('some/uri', 'someClient')
|
6
|
+
expect(resource.instance_variable_get('@path')).to eq('some/uri')
|
7
|
+
expect(resource.instance_variable_get('@client')).to eq('someClient')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should set up object properties if passed' do
|
11
|
+
params = { 'SomeKey' => 'someValue' }
|
12
|
+
resource = Restcomm::REST::InstanceResource.new('uri', 'client', params)
|
13
|
+
expect(resource.some_key).to eq('someValue')
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Restcomm::REST::Message do
|
4
|
+
before do
|
5
|
+
@message = Restcomm::REST::Message.new('someUri', 'someClient')
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'sets up a media resources object' do
|
9
|
+
expect(@message).to respond_to(:media)
|
10
|
+
expect(@message.media.instance_variable_get('@path')).to eq('someUri/Media')
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Restcomm::REST::Country do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@country = Restcomm::REST::Country.new('someUri', 'someClient')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'sets up a local resources object' do
|
10
|
+
expect(@country).to respond_to(:local)
|
11
|
+
expect(@country.local.instance_variable_get('@path')).to eq('someUri/Local')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'sets up a toll_free resources object' do
|
15
|
+
expect(@country).to respond_to(:toll_free)
|
16
|
+
expect(@country.toll_free.instance_variable_get('@path')).to eq(
|
17
|
+
'someUri/TollFree'
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'sets up a mobile resources object' do
|
22
|
+
expect(@country).to respond_to(:mobile)
|
23
|
+
expect(@country.mobile.instance_variable_get('@path')).to eq(
|
24
|
+
'someUri/Mobile'
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
describe Restcomm::REST::NumberType do
|
31
|
+
|
32
|
+
before do
|
33
|
+
@incoming_phone_numbers = Restcomm::REST::IncomingPhoneNumbers.new(
|
34
|
+
'someUri', 'someClient'
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'sets up a local resources object' do
|
39
|
+
expect(@incoming_phone_numbers).to respond_to(:local)
|
40
|
+
expect(@incoming_phone_numbers.local.instance_variable_get('@path')).to eq(
|
41
|
+
'someUri/Local'
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'sets up a toll_free resources object' do
|
46
|
+
expect(@incoming_phone_numbers).to respond_to(:toll_free)
|
47
|
+
expect(@incoming_phone_numbers.toll_free.instance_variable_get('@path')).to(
|
48
|
+
eq('someUri/TollFree')
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'sets up a mobile resources object' do
|
53
|
+
expect(@incoming_phone_numbers).to respond_to(:mobile)
|
54
|
+
expect(@incoming_phone_numbers.mobile.instance_variable_get('@path')).to eq(
|
55
|
+
'someUri/Mobile'
|
56
|
+
)
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Restcomm::REST::Queue do
|
4
|
+
it 'should set up a members resources object' do
|
5
|
+
queue = Restcomm::REST::Queue.new('someUri', 'someClient')
|
6
|
+
expect(queue).to respond_to(:members)
|
7
|
+
expect(queue.members.instance_variable_get('@path')).to eq(
|
8
|
+
'someUri/Members'
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Restcomm::REST::Recording do
|
4
|
+
it 'should set up a transcriptions resources object' do
|
5
|
+
call = Restcomm::REST::Recording.new('someUri', 'someClient')
|
6
|
+
expect(call).to respond_to(:transcriptions)
|
7
|
+
expect(call.transcriptions.instance_variable_get('@path')).to eq(
|
8
|
+
'someUri/Transcriptions'
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end
|