telnyx 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/Gemfile +1 -0
- data/README.md +41 -3
- data/VERSION +1 -1
- data/bin/telnyx-console +2 -1
- data/lib/telnyx.rb +17 -2
- data/lib/telnyx/address.rb +12 -0
- data/lib/telnyx/api_operations/list.rb +1 -1
- data/lib/telnyx/api_operations/nested_resource.rb +2 -2
- data/lib/telnyx/api_resource.rb +1 -1
- data/lib/telnyx/billing_group.rb +12 -0
- data/lib/telnyx/call_control_application.rb +12 -0
- data/lib/telnyx/{conferences.rb → conference.rb} +2 -1
- data/lib/telnyx/connection.rb +9 -0
- data/lib/telnyx/credential_connection.rb +12 -0
- data/lib/telnyx/fqdn.rb +12 -0
- data/lib/telnyx/fqdn_connection.rb +12 -0
- data/lib/telnyx/ip.rb +12 -0
- data/lib/telnyx/ip_connection.rb +12 -0
- data/lib/telnyx/list_object.rb +30 -44
- data/lib/telnyx/number_order_document.rb +11 -0
- data/lib/telnyx/outbound_voice_profile.rb +12 -0
- data/lib/telnyx/phone_number.rb +11 -0
- data/lib/telnyx/phone_number_regulatory_requirement.rb +9 -0
- data/lib/telnyx/portout.rb +12 -0
- data/lib/telnyx/regulatory_requirement.rb +9 -0
- data/lib/telnyx/telnyx_client.rb +1 -1
- data/lib/telnyx/util.rb +31 -13
- data/lib/telnyx/version.rb +1 -1
- data/lib/telnyx/wireless_detail_records_report.rb +12 -0
- data/test/telnyx/address_test.rb +67 -0
- data/test/telnyx/alphanumeric_sender_id_test.rb +4 -0
- data/test/telnyx/api_resource_test.rb +14 -5
- data/test/telnyx/billing_group_test.rb +40 -0
- data/test/telnyx/call_control_application_test.rb +42 -0
- data/test/telnyx/{conferences_test.rb → conference_test.rb} +5 -5
- data/test/telnyx/connection_test.rb +28 -0
- data/test/telnyx/credential_connection_test.rb +40 -0
- data/test/telnyx/errors_test.rb +4 -4
- data/test/telnyx/fqdn_connection_test.rb +40 -0
- data/test/telnyx/fqdn_test.rb +40 -0
- data/test/telnyx/ip_connection_test.rb +40 -0
- data/test/telnyx/ip_test.rb +40 -0
- data/test/telnyx/list_object_test.rb +48 -90
- data/test/telnyx/messaging_profile_test.rb +15 -4
- data/test/telnyx/number_order_document_test.rb +35 -0
- data/test/telnyx/outbound_voice_profile_test.rb +67 -0
- data/test/telnyx/phone_number_regulatory_requirement_test.rb +14 -0
- data/test/telnyx/phone_number_test.rb +38 -0
- data/test/telnyx/public_key_test.rb +1 -0
- data/test/telnyx/regulatory_requirement_test.rb +21 -0
- data/test/telnyx/sim_card_test.rb +2 -14
- data/test/telnyx/telnyx_client_test.rb +1 -1
- data/test/telnyx/wireless_detail_records_report_test.rb +57 -0
- data/test/test_helper.rb +1 -1
- metadata +50 -6
data/test/telnyx/errors_test.rb
CHANGED
@@ -7,16 +7,16 @@ module Telnyx
|
|
7
7
|
context "#to_s" do
|
8
8
|
should "convert to string" do
|
9
9
|
e = TelnyxError.new([{ "title" => "Missing required attributes" }])
|
10
|
-
assert_equal
|
10
|
+
assert_equal 'Missing required attributes Full details: [{"title"=>"Missing required attributes"}]', e.to_s
|
11
11
|
|
12
12
|
e = TelnyxError.new([{ "title" => "Missing required attributes" }], http_status: 422)
|
13
|
-
assert_equal
|
13
|
+
assert_equal '(Status 422) Missing required attributes Full details: [{"title"=>"Missing required attributes"}]', e.to_s
|
14
14
|
|
15
15
|
e = TelnyxError.new([{ "title" => "Missing required attributes" }], http_status: nil, http_body: nil, json_body: nil, http_headers: { request_id: "request-id" })
|
16
|
-
assert_equal
|
16
|
+
assert_equal '(Request request-id) Missing required attributes Full details: [{"title"=>"Missing required attributes"}]', e.to_s
|
17
17
|
|
18
18
|
e = TelnyxError.new([{ "title" => "Missing required attributes" }, { "title" => "Phone number must be in +E.164 format" }], http_status: nil, http_body: nil, json_body: nil, http_headers: { request_id: "request-id" })
|
19
|
-
assert_equal
|
19
|
+
assert_equal '(Request request-id) Missing required attributes plus 1 other error. Full details: [{"title"=>"Missing required attributes"}, {"title"=>"Phone number must be in +E.164 format"}]', e.to_s
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../test_helper"
|
4
|
+
|
5
|
+
module Telnyx
|
6
|
+
class FQDNConnectionTest < Test::Unit::TestCase
|
7
|
+
should "list fqdn connections" do
|
8
|
+
fqdn_connections = FQDNConnection.list
|
9
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/fqdn_connections"
|
10
|
+
assert_kind_of ListObject, fqdn_connections
|
11
|
+
assert_kind_of FQDNConnection, fqdn_connections.first
|
12
|
+
end
|
13
|
+
|
14
|
+
should "create fqdn connection" do
|
15
|
+
FQDNConnection.create
|
16
|
+
assert_requested :post, "#{Telnyx.api_base}/v2/fqdn_connections"
|
17
|
+
end
|
18
|
+
|
19
|
+
should "retrieve fqdn connection" do
|
20
|
+
fqdn_connection = FQDNConnection.retrieve("id")
|
21
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/fqdn_connections/id"
|
22
|
+
assert_kind_of FQDNConnection, fqdn_connection
|
23
|
+
end
|
24
|
+
|
25
|
+
should "delete fqdn connection" do
|
26
|
+
fqdn_connection = FQDNConnection.retrieve("id")
|
27
|
+
|
28
|
+
fqdn_connection.delete
|
29
|
+
assert_requested :delete, "#{Telnyx.api_base}/v2/fqdn_connections/id"
|
30
|
+
end
|
31
|
+
|
32
|
+
should "update fqdn connection" do
|
33
|
+
fqdn_connection = FQDNConnection.retrieve("id")
|
34
|
+
|
35
|
+
fqdn_connection.active = false
|
36
|
+
fqdn_connection.save
|
37
|
+
assert_requested :patch, "#{Telnyx.api_base}/v2/fqdn_connections/id"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../test_helper"
|
4
|
+
|
5
|
+
module Telnyx
|
6
|
+
class FQDNTest < Test::Unit::TestCase
|
7
|
+
should "list fqdns" do
|
8
|
+
fqdn = FQDN.list
|
9
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/fqdns"
|
10
|
+
assert_kind_of ListObject, fqdn
|
11
|
+
assert_kind_of FQDN, fqdn.first
|
12
|
+
end
|
13
|
+
|
14
|
+
should "create fqdn" do
|
15
|
+
FQDN.create fqdn: "example.com"
|
16
|
+
assert_requested :post, "#{Telnyx.api_base}/v2/fqdns"
|
17
|
+
end
|
18
|
+
|
19
|
+
should "retrieve fqdn" do
|
20
|
+
fqdn = FQDN.retrieve("id")
|
21
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/fqdns/id"
|
22
|
+
assert_kind_of FQDN, fqdn
|
23
|
+
end
|
24
|
+
|
25
|
+
should "delete fqdn" do
|
26
|
+
fqdn = FQDN.retrieve("id")
|
27
|
+
|
28
|
+
fqdn.delete
|
29
|
+
assert_requested :delete, "#{Telnyx.api_base}/v2/fqdns/id"
|
30
|
+
end
|
31
|
+
|
32
|
+
should "update fqdn" do
|
33
|
+
fqdn = FQDN.retrieve("id")
|
34
|
+
|
35
|
+
fqdn.fqdn = "example.com"
|
36
|
+
fqdn.save
|
37
|
+
assert_requested :patch, "#{Telnyx.api_base}/v2/fqdns/id"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../test_helper"
|
4
|
+
|
5
|
+
module Telnyx
|
6
|
+
class IPConnectionTest < Test::Unit::TestCase
|
7
|
+
should "list ip connections" do
|
8
|
+
ip_connections = IPConnection.list
|
9
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/ip_connections"
|
10
|
+
assert_kind_of ListObject, ip_connections
|
11
|
+
assert_kind_of IPConnection, ip_connections.first
|
12
|
+
end
|
13
|
+
|
14
|
+
should "create ip connection" do
|
15
|
+
IPConnection.create
|
16
|
+
assert_requested :post, "#{Telnyx.api_base}/v2/ip_connections"
|
17
|
+
end
|
18
|
+
|
19
|
+
should "retrieve ip connection" do
|
20
|
+
ip_connection = IPConnection.retrieve("id")
|
21
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/ip_connections/id"
|
22
|
+
assert_kind_of IPConnection, ip_connection
|
23
|
+
end
|
24
|
+
|
25
|
+
should "delete ip connection" do
|
26
|
+
ip_connection = IPConnection.retrieve("id")
|
27
|
+
|
28
|
+
ip_connection.delete
|
29
|
+
assert_requested :delete, "#{Telnyx.api_base}/v2/ip_connections/id"
|
30
|
+
end
|
31
|
+
|
32
|
+
should "update ip connection" do
|
33
|
+
ip_connection = IPConnection.retrieve("id")
|
34
|
+
|
35
|
+
ip_connection.active = false
|
36
|
+
ip_connection.save
|
37
|
+
assert_requested :patch, "#{Telnyx.api_base}/v2/ip_connections/id"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../test_helper"
|
4
|
+
|
5
|
+
module Telnyx
|
6
|
+
class IPTest < Test::Unit::TestCase
|
7
|
+
should "list ips" do
|
8
|
+
ip = IP.list
|
9
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/ips"
|
10
|
+
assert_kind_of ListObject, ip
|
11
|
+
assert_kind_of IP, ip.first
|
12
|
+
end
|
13
|
+
|
14
|
+
should "create ip" do
|
15
|
+
IP.create ip_address: "0.0.0.0"
|
16
|
+
assert_requested :post, "#{Telnyx.api_base}/v2/ips"
|
17
|
+
end
|
18
|
+
|
19
|
+
should "retrieve ip" do
|
20
|
+
ip = IP.retrieve("id")
|
21
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/ips/id"
|
22
|
+
assert_kind_of IP, ip
|
23
|
+
end
|
24
|
+
|
25
|
+
should "delete ip" do
|
26
|
+
ip = IP.retrieve("id")
|
27
|
+
|
28
|
+
ip.delete
|
29
|
+
assert_requested :delete, "#{Telnyx.api_base}/v2/ips/id"
|
30
|
+
end
|
31
|
+
|
32
|
+
should "update ip" do
|
33
|
+
ip = IP.retrieve("id")
|
34
|
+
|
35
|
+
ip.ip_address = "0.0.0.0"
|
36
|
+
ip.save
|
37
|
+
assert_requested :patch, "#{Telnyx.api_base}/v2/ips/id"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -78,59 +78,6 @@ module Telnyx
|
|
78
78
|
assert_equal expected, actual
|
79
79
|
end
|
80
80
|
|
81
|
-
should "provide #auto_paging_each_by_token" do
|
82
|
-
arr = [
|
83
|
-
{ id: 1 },
|
84
|
-
{ id: 2 },
|
85
|
-
{ id: 3 },
|
86
|
-
]
|
87
|
-
expected = Util.convert_to_telnyx_object(arr, {})
|
88
|
-
|
89
|
-
list = TestListObject.construct_from(data: [{ id: 1 }],
|
90
|
-
meta: { next_page_token: "123" },
|
91
|
-
url: "/things")
|
92
|
-
stub_request(:get, "#{Telnyx.api_base}/things")
|
93
|
-
.with(query: { page: { token: "123" } })
|
94
|
-
.to_return(body: JSON.generate(data: [{ id: 2 }], meta: { next_page_token: "456" }))
|
95
|
-
stub_request(:get, "#{Telnyx.api_base}/things")
|
96
|
-
.with(query: { page: { token: "456" } })
|
97
|
-
.to_return(body: JSON.generate(data: [{ id: 3 }], meta: { next_page_token: "789" }))
|
98
|
-
stub_request(:get, "#{Telnyx.api_base}/things")
|
99
|
-
.with(query: { page: { token: "789" } })
|
100
|
-
.to_return(body: JSON.generate(data: [], meta: { next_page_token: nil }))
|
101
|
-
|
102
|
-
assert_equal expected, list.auto_paging_each_by_token.to_a
|
103
|
-
end
|
104
|
-
|
105
|
-
should "provide #auto_paging_each_by_token that responds to a block" do
|
106
|
-
arr = [
|
107
|
-
{ id: 1 },
|
108
|
-
{ id: 2 },
|
109
|
-
{ id: 3 },
|
110
|
-
]
|
111
|
-
expected = Util.convert_to_telnyx_object(arr, {})
|
112
|
-
|
113
|
-
list = TestListObject.construct_from(data: [{ id: 1 }],
|
114
|
-
meta: { next_page_token: "123" },
|
115
|
-
url: "/things")
|
116
|
-
stub_request(:get, "#{Telnyx.api_base}/things")
|
117
|
-
.with(query: { page: { token: "123" } })
|
118
|
-
.to_return(body: JSON.generate(data: [{ id: 2 }], meta: { next_page_token: "456" }))
|
119
|
-
stub_request(:get, "#{Telnyx.api_base}/things")
|
120
|
-
.with(query: { page: { token: "456" } })
|
121
|
-
.to_return(body: JSON.generate(data: [{ id: 3 }], meta: { next_page_token: "789" }))
|
122
|
-
stub_request(:get, "#{Telnyx.api_base}/things")
|
123
|
-
.with(query: { page: { token: "789" } })
|
124
|
-
.to_return(body: JSON.generate(data: [], meta: { next_page_token: nil }))
|
125
|
-
|
126
|
-
actual = []
|
127
|
-
list.auto_paging_each_by_token do |obj|
|
128
|
-
actual << obj
|
129
|
-
end
|
130
|
-
|
131
|
-
assert_equal expected, actual
|
132
|
-
end
|
133
|
-
|
134
81
|
should "provide #empty?" do
|
135
82
|
list = Telnyx::ListObject.construct_from(data: [])
|
136
83
|
assert list.empty?
|
@@ -138,6 +85,52 @@ module Telnyx
|
|
138
85
|
refute list.empty?
|
139
86
|
end
|
140
87
|
|
88
|
+
#
|
89
|
+
# page_size
|
90
|
+
#
|
91
|
+
|
92
|
+
should "fetch the current page size via #page_size" do
|
93
|
+
list = TestListObject.construct_from(
|
94
|
+
data: [
|
95
|
+
{ id: 1 },
|
96
|
+
{ id: 2 },
|
97
|
+
{ id: 3 },
|
98
|
+
],
|
99
|
+
meta: {
|
100
|
+
page_size: 5,
|
101
|
+
total_results: 3,
|
102
|
+
total_pages: 1,
|
103
|
+
page_number: 1,
|
104
|
+
},
|
105
|
+
url: "/things"
|
106
|
+
)
|
107
|
+
|
108
|
+
assert_equal(list.page_size, 5)
|
109
|
+
end
|
110
|
+
|
111
|
+
#
|
112
|
+
# page_number
|
113
|
+
#
|
114
|
+
|
115
|
+
should "fetch the current page number via #page_number" do
|
116
|
+
list = TestListObject.construct_from(
|
117
|
+
data: [
|
118
|
+
{ id: 1 },
|
119
|
+
{ id: 2 },
|
120
|
+
{ id: 3 },
|
121
|
+
],
|
122
|
+
meta: {
|
123
|
+
page_size: 5,
|
124
|
+
total_results: 3,
|
125
|
+
total_pages: 1,
|
126
|
+
page_number: 1,
|
127
|
+
},
|
128
|
+
url: "/things"
|
129
|
+
)
|
130
|
+
|
131
|
+
assert_equal(list.page_number, 1)
|
132
|
+
end
|
133
|
+
|
141
134
|
#
|
142
135
|
# next_page
|
143
136
|
#
|
@@ -162,7 +155,7 @@ module Telnyx
|
|
162
155
|
.with(query: { page: { number: 2, size: 20 }, enabled: true })
|
163
156
|
.to_return(body: JSON.generate(data: [{ id: 2 }], meta: { page_number: 2, total_pages: 2 }))
|
164
157
|
next_list = list.next_page
|
165
|
-
assert_equal({ enabled: true }, next_list.filters)
|
158
|
+
assert_equal({ enabled: true, page: { number: 2, size: 20 } }, next_list.filters)
|
166
159
|
end
|
167
160
|
|
168
161
|
should "fetch an empty page through #next_page" do
|
@@ -173,41 +166,6 @@ module Telnyx
|
|
173
166
|
assert_equal Telnyx::ListObject.empty_list, next_list
|
174
167
|
end
|
175
168
|
|
176
|
-
#
|
177
|
-
# next page by token
|
178
|
-
#
|
179
|
-
|
180
|
-
should "fetch a next page through #next_page_by_token" do
|
181
|
-
list = TestListObject.construct_from(data: [{ id: 1 }],
|
182
|
-
meta: { next_page_token: "123" },
|
183
|
-
url: "/things")
|
184
|
-
stub_request(:get, "#{Telnyx.api_base}/things")
|
185
|
-
.with(query: { page: { token: "123" } })
|
186
|
-
.to_return(body: JSON.generate(data: [{ id: 2 }]))
|
187
|
-
next_list = list.next_page_by_token
|
188
|
-
refute next_list.empty?
|
189
|
-
end
|
190
|
-
|
191
|
-
should "fetch a next page through #next_page_by_token and respect filters" do
|
192
|
-
list = TestListObject.construct_from(data: [{ id: 1 }],
|
193
|
-
meta: { next_page_token: "123" },
|
194
|
-
url: "/things")
|
195
|
-
list.filters = { enabled: true }
|
196
|
-
stub_request(:get, "#{Telnyx.api_base}/things")
|
197
|
-
.with(query: { page: { token: "123" }, enabled: true })
|
198
|
-
.to_return(body: JSON.generate(data: [{ id: 2 }], meta: { next_page_token: "456" }))
|
199
|
-
next_list = list.next_page_by_token
|
200
|
-
assert_equal({ enabled: true }, next_list.filters)
|
201
|
-
end
|
202
|
-
|
203
|
-
should "fetch an empty page through #next_page_by_token" do
|
204
|
-
list = TestListObject.construct_from(data: [{ id: 1 }],
|
205
|
-
meta: {},
|
206
|
-
url: "/things")
|
207
|
-
next_list = list.next_page_by_token
|
208
|
-
assert_equal Telnyx::ListObject.empty_list, next_list
|
209
|
-
end
|
210
|
-
|
211
169
|
#
|
212
170
|
# previous_page
|
213
171
|
#
|
@@ -234,7 +192,7 @@ module Telnyx
|
|
234
192
|
|
235
193
|
next_list = list.previous_page
|
236
194
|
assert_requested(stub_get)
|
237
|
-
assert_equal({ enabled: true }, next_list.filters)
|
195
|
+
assert_equal({ enabled: true, page: { number: 1, size: 20 } }, next_list.filters)
|
238
196
|
end
|
239
197
|
end
|
240
198
|
end
|
@@ -24,15 +24,25 @@ module Telnyx
|
|
24
24
|
end
|
25
25
|
|
26
26
|
should "be saveable" do
|
27
|
+
# stub out save until number_pool_settings issue is worked out
|
27
28
|
messaging_profile = Telnyx::MessagingProfile.retrieve("123")
|
28
|
-
|
29
|
+
stub = stub_request(:patch, "#{Telnyx.api_base}/v2/messaging_profiles/123")
|
30
|
+
.with(body: hash_including(name: "foo"))
|
31
|
+
.to_return(body: JSON.generate(data: messaging_profile))
|
32
|
+
messaging_profile.name = "foo"
|
29
33
|
messaging_profile.save
|
30
|
-
assert_requested :patch, "#{Telnyx.api_base}/v2/messaging_profiles/#{messaging_profile.id}"
|
34
|
+
# assert_requested :patch, "#{Telnyx.api_base}/v2/messaging_profiles/#{messaging_profile.id}"
|
35
|
+
assert_requested stub
|
31
36
|
end
|
32
37
|
|
33
|
-
should "be
|
38
|
+
should "be updatable" do
|
39
|
+
# stub out save until number_pool_settings issue is worked out
|
40
|
+
stub = stub_request(:patch, "#{Telnyx.api_base}/v2/messaging_profiles/123")
|
41
|
+
.with(body: hash_including(name: "foo"))
|
42
|
+
.to_return(body: JSON.generate(data: MessagingProfile.retrieve("123")))
|
34
43
|
messaging_profile = Telnyx::MessagingProfile.update("123", name: "foo")
|
35
|
-
assert_requested :patch, "#{Telnyx.api_base}/v2/messaging_profiles/123"
|
44
|
+
# assert_requested :patch, "#{Telnyx.api_base}/v2/messaging_profiles/123"
|
45
|
+
assert_requested stub
|
36
46
|
assert messaging_profile.is_a?(Telnyx::MessagingProfile)
|
37
47
|
end
|
38
48
|
|
@@ -52,6 +62,7 @@ module Telnyx
|
|
52
62
|
end
|
53
63
|
|
54
64
|
should "be able to list alphanumeric sender ids" do
|
65
|
+
omit "alphanumeric ids mock spec removed"
|
55
66
|
messaging_profile = Telnyx::MessagingProfile.retrieve("123")
|
56
67
|
alphanumeric_sender_ids = messaging_profile.alphanumeric_sender_ids
|
57
68
|
assert_requested :get, "#{Telnyx.api_base}/v2/messaging_profiles/123/alphanumeric_sender_ids"
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "../test_helper"
|
5
|
+
|
6
|
+
module Telnyx
|
7
|
+
class NumberOrderDocumentTest < Test::Unit::TestCase
|
8
|
+
should "be retrievable" do
|
9
|
+
number_order_document = NumberOrderDocument.retrieve "12345"
|
10
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/number_order_documents/12345"
|
11
|
+
assert_kind_of NumberOrderDocument, number_order_document
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be creatable" do
|
15
|
+
number_order_document = NumberOrderDocument.create
|
16
|
+
assert_requested :post, "#{Telnyx.api_base}/v2/number_order_documents"
|
17
|
+
assert_kind_of NumberOrderDocument, number_order_document
|
18
|
+
end
|
19
|
+
|
20
|
+
should "be listable" do
|
21
|
+
number_order_documents = NumberOrderDocument.list
|
22
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/number_order_documents"
|
23
|
+
assert_kind_of Array, number_order_documents.data
|
24
|
+
assert_kind_of NumberOrderDocument, number_order_documents.first
|
25
|
+
end
|
26
|
+
|
27
|
+
should "be saveable" do
|
28
|
+
number_order_document = NumberOrderDocument.retrieve("12345")
|
29
|
+
number_order_document.file_id = "1234"
|
30
|
+
number_order_document.save
|
31
|
+
assert_requested :patch, "#{Telnyx.api_base}/v2/number_order_documents/#{number_order_document.id}"
|
32
|
+
assert_kind_of NumberOrderDocument, number_order_document
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../test_helper"
|
4
|
+
|
5
|
+
module Telnyx
|
6
|
+
class OutboundVoiceProfileTest < Test::Unit::TestCase
|
7
|
+
# Stubbed until the mock spec updates with this endpoint
|
8
|
+
setup do
|
9
|
+
stub_request(:get, "#{Telnyx.api_base}/v2/outbound_voice_profiles/1234")
|
10
|
+
.to_return(body: JSON.generate(data:
|
11
|
+
{ id: "1234", record_type: "outbound_voice_profile" }))
|
12
|
+
end
|
13
|
+
should "list outbound voice profiles" do
|
14
|
+
stub = stub_request(:get, "#{Telnyx.api_base}/v2/outbound_voice_profiles")
|
15
|
+
.to_return(body: JSON.generate(data: [
|
16
|
+
{ id: "1234567", record_type: "outbound_voice_profile" },
|
17
|
+
]))
|
18
|
+
outbound_voice_profiles = OutboundVoiceProfile.list
|
19
|
+
# assert_requested :get, "#{Telnyx.api_base}/v2/outbound_voice_profiles"
|
20
|
+
assert_requested stub
|
21
|
+
assert_kind_of ListObject, outbound_voice_profiles
|
22
|
+
assert_kind_of OutboundVoiceProfile, outbound_voice_profiles.first
|
23
|
+
end
|
24
|
+
|
25
|
+
should "create outbound voice profile" do
|
26
|
+
stub = stub_request(:post, "#{Telnyx.api_base}/v2/outbound_voice_profiles")
|
27
|
+
.to_return(body: JSON.generate(data:
|
28
|
+
{ id: "1234", record_type: "outbound_voice_profile" }))
|
29
|
+
OutboundVoiceProfile.create
|
30
|
+
# assert_requested :post, "#{Telnyx.api_base}/v2/outbound_voice_profiles"
|
31
|
+
assert_requested stub
|
32
|
+
end
|
33
|
+
|
34
|
+
should "retrieve outbound voice profile" do
|
35
|
+
stub = stub_request(:get, "#{Telnyx.api_base}/v2/outbound_voice_profiles/1234")
|
36
|
+
.to_return(body: JSON.generate(data:
|
37
|
+
{ id: "1234", record_type: "outbound_voice_profile" }))
|
38
|
+
outbound_voice_profile = OutboundVoiceProfile.retrieve("1234")
|
39
|
+
# assert_requested :get, "#{Telnyx.api_base}/v2/outbound_voice_profiles/1234"
|
40
|
+
assert_requested stub
|
41
|
+
assert_kind_of OutboundVoiceProfile, outbound_voice_profile
|
42
|
+
end
|
43
|
+
|
44
|
+
should "delete outbound voice profile" do
|
45
|
+
stub = stub_request(:delete, "#{Telnyx.api_base}/v2/outbound_voice_profiles/1234")
|
46
|
+
.to_return(body: JSON.generate(data:
|
47
|
+
{ id: "1234", record_type: "outbound_voice_profile" }))
|
48
|
+
outbound_voice_profile = OutboundVoiceProfile.retrieve("1234")
|
49
|
+
|
50
|
+
outbound_voice_profile.delete
|
51
|
+
# assert_requested :delete, "#{Telnyx.api_base}/v2/outbound_voice_profiles/id"
|
52
|
+
assert_requested stub
|
53
|
+
end
|
54
|
+
|
55
|
+
should "update outbound voice profile" do
|
56
|
+
stub = stub_request(:patch, "#{Telnyx.api_base}/v2/outbound_voice_profiles/1234")
|
57
|
+
.to_return(body: JSON.generate(data:
|
58
|
+
{ id: "1234", record_type: "outbound_voice_profile" }))
|
59
|
+
outbound_voice_profile = OutboundVoiceProfile.retrieve("1234")
|
60
|
+
|
61
|
+
outbound_voice_profile.active = false
|
62
|
+
outbound_voice_profile.save
|
63
|
+
# assert_requested :patch, "#{Telnyx.api_base}/v2/outbound_voice_profiles/id"
|
64
|
+
assert_requested stub
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|