telnyx 0.0.5 → 2.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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/Gemfile +1 -0
- data/README.md +42 -3
- data/VERSION +1 -1
- data/bin/telnyx-console +2 -1
- data/lib/telnyx.rb +19 -1
- data/lib/telnyx/address.rb +12 -0
- data/lib/telnyx/api_operations/list.rb +1 -1
- data/lib/telnyx/api_operations/nested_resource.rb +17 -4
- 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_lookup.rb +7 -0
- data/lib/telnyx/number_order_document.rb +11 -0
- data/lib/telnyx/outbound_voice_profile.rb +12 -0
- data/lib/telnyx/phone_number.rb +44 -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/sim_card.rb +24 -0
- data/lib/telnyx/telnyx_client.rb +1 -1
- data/lib/telnyx/telnyx_response.rb +11 -2
- data/lib/telnyx/util.rb +31 -11
- data/lib/telnyx/version.rb +1 -1
- data/lib/telnyx/wireless_detail_records_report.rb +12 -0
- data/telnyx.gemspec +1 -1
- 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_lookup_test.rb +18 -0
- 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 +157 -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 +44 -0
- data/test/telnyx/telnyx_client_test.rb +11 -10
- data/test/telnyx/wireless_detail_records_report_test.rb +57 -0
- data/test/test_helper.rb +1 -1
- metadata +74 -10
@@ -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,18 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "../test_helper"
|
5
|
+
|
6
|
+
module Telnyx
|
7
|
+
class NumberLookupTest < Test::Unit::TestCase
|
8
|
+
test "retrieve number" do
|
9
|
+
number = "555-555-5555"
|
10
|
+
stub = stub_request(:get, "#{Telnyx.api_base}/v2/number_lookup/#{number}")
|
11
|
+
.to_return(body: { data: { record_type: "number_lookup" } }.to_json)
|
12
|
+
nl = NumberLookup.retrieve number
|
13
|
+
|
14
|
+
assert_requested stub
|
15
|
+
assert_kind_of NumberLookup, nl
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -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
|
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "../test_helper"
|
5
|
+
|
6
|
+
module Telnyx
|
7
|
+
class PhoneNumberRegulatoryRequirementTest < Test::Unit::TestCase
|
8
|
+
should "be listable" do
|
9
|
+
phone_number_reg_req = PhoneNumberRegulatoryRequirement.list
|
10
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/phone_number_regulatory_requirements"
|
11
|
+
assert_kind_of PhoneNumberRegulatoryRequirement, phone_number_reg_req.first
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../test_helper"
|
4
|
+
module Telnyx
|
5
|
+
class PhoneNumberTest < Test::Unit::TestCase
|
6
|
+
should "list resources" do
|
7
|
+
stub = stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers")
|
8
|
+
.to_return(body: JSON.generate(data: (1..5).map { |i| mock_response(i) }))
|
9
|
+
phone_numbers = Telnyx::PhoneNumber.list
|
10
|
+
assert_requested stub
|
11
|
+
assert_kind_of Telnyx::ListObject, phone_numbers
|
12
|
+
assert_kind_of Telnyx::PhoneNumber, phone_numbers.first
|
13
|
+
end
|
14
|
+
|
15
|
+
should "get resource" do
|
16
|
+
stub = stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123")
|
17
|
+
.to_return(body: JSON.generate(data: mock_response("123")))
|
18
|
+
phone_number = Telnyx::PhoneNumber.retrieve("123")
|
19
|
+
assert_kind_of Telnyx::PhoneNumber, phone_number
|
20
|
+
assert_requested stub
|
21
|
+
assert_equal phone_number.id, "123"
|
22
|
+
end
|
23
|
+
|
24
|
+
should "update resource" do
|
25
|
+
stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123")
|
26
|
+
.to_return(body: JSON.generate(data: mock_response("123")))
|
27
|
+
stub = stub_request(:patch, "#{Telnyx.api_base}/v2/phone_numbers/123")
|
28
|
+
.to_return(body: JSON.generate(data: mock_response("123")))
|
29
|
+
phone_number = Telnyx::PhoneNumber.retrieve("123")
|
30
|
+
phone_number.save
|
31
|
+
assert_requested stub
|
32
|
+
end
|
33
|
+
|
34
|
+
should "delete resource" do
|
35
|
+
stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123")
|
36
|
+
.to_return(body: JSON.generate(data: mock_response("123")))
|
37
|
+
stub = stub_request(:delete, "#{Telnyx.api_base}/v2/phone_numbers/123")
|
38
|
+
.to_return(body: JSON.generate(data: mock_response("123")))
|
39
|
+
phone_number = Telnyx::PhoneNumber.retrieve("123")
|
40
|
+
phone_number.delete
|
41
|
+
assert_requested stub
|
42
|
+
end
|
43
|
+
|
44
|
+
should "list all voice settings" do
|
45
|
+
Telnyx::PhoneNumber.list_voice
|
46
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/phone_numbers/voice"
|
47
|
+
end
|
48
|
+
|
49
|
+
context "nested commands" do
|
50
|
+
should "update voice" do
|
51
|
+
stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123")
|
52
|
+
.to_return(body: JSON.generate(data: mock_response("123")))
|
53
|
+
command_stub = stub_request(:patch, "#{Telnyx.api_base}/v2/phone_numbers/123/voice")
|
54
|
+
.with(body: { connection_id: 123 })
|
55
|
+
.to_return(body: JSON.generate(data: mock_voice_response))
|
56
|
+
phone_number = Telnyx::PhoneNumber.retrieve("123")
|
57
|
+
phone_number.update_voice(connection_id: 123)
|
58
|
+
assert_requested command_stub
|
59
|
+
end
|
60
|
+
|
61
|
+
should "get voice" do
|
62
|
+
stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123")
|
63
|
+
.to_return(body: JSON.generate(data: mock_response("123")))
|
64
|
+
command_stub = stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123/voice")
|
65
|
+
.to_return(body: JSON.generate(data: mock_voice_response("456")))
|
66
|
+
phone_number = Telnyx::PhoneNumber.retrieve("123")
|
67
|
+
voice = phone_number.voice
|
68
|
+
assert_requested command_stub
|
69
|
+
assert_equal voice.data.connection_id, "456"
|
70
|
+
end
|
71
|
+
|
72
|
+
should "get messaging" do
|
73
|
+
stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123")
|
74
|
+
.to_return(body: JSON.generate(data: mock_response("123")))
|
75
|
+
command_stub = stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123/messaging")
|
76
|
+
.to_return(body: JSON.generate(data: mock_messaging_response("456")))
|
77
|
+
phone_number = Telnyx::PhoneNumber.retrieve("123")
|
78
|
+
phone_number.messaging
|
79
|
+
assert_requested command_stub
|
80
|
+
end
|
81
|
+
|
82
|
+
should "update messaging" do
|
83
|
+
stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123")
|
84
|
+
.to_return(body: JSON.generate(data: mock_response("123")))
|
85
|
+
command_stub = stub_request(:patch, "#{Telnyx.api_base}/v2/phone_numbers/123/messaging")
|
86
|
+
.with(body: { messaging_profile_id: "12345", messaging_product: "P2P" })
|
87
|
+
.to_return(body: JSON.generate(data: mock_messaging_response))
|
88
|
+
phone_number = Telnyx::PhoneNumber.retrieve("123")
|
89
|
+
phone_number.update_messaging(messaging_profile_id: "12345", messaging_product: "P2P")
|
90
|
+
assert_requested command_stub
|
91
|
+
end
|
92
|
+
|
93
|
+
should "list inbound channels" do
|
94
|
+
stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123")
|
95
|
+
.to_return(body: JSON.generate(data: mock_response("123")))
|
96
|
+
command_stub = stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/inbound_channels")
|
97
|
+
.to_return(body: JSON.generate(
|
98
|
+
data: {
|
99
|
+
channels: 7,
|
100
|
+
record_type: "inbound_channels",
|
101
|
+
}
|
102
|
+
))
|
103
|
+
phone_number = Telnyx::PhoneNumber.retrieve("123")
|
104
|
+
inbound_channels = phone_number.inbound_channels
|
105
|
+
assert_equal inbound_channels, 7
|
106
|
+
assert_requested command_stub
|
107
|
+
end
|
108
|
+
|
109
|
+
should "update inbound channel" do
|
110
|
+
stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123")
|
111
|
+
.to_return(body: JSON.generate(data: mock_response("123")))
|
112
|
+
stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/inbound_channels")
|
113
|
+
.to_return(body: JSON.generate(
|
114
|
+
data: {
|
115
|
+
channels: 7,
|
116
|
+
record_type: "inbound_channels",
|
117
|
+
}
|
118
|
+
))
|
119
|
+
command_stub = stub_request(:patch, "#{Telnyx.api_base}/v2/phone_numbers/inbound_channels")
|
120
|
+
.to_return(body: JSON.generate(
|
121
|
+
data: {
|
122
|
+
channels: 7,
|
123
|
+
record_type: "inbound_channels",
|
124
|
+
}
|
125
|
+
))
|
126
|
+
phone_number = Telnyx::PhoneNumber.retrieve("123")
|
127
|
+
phone_number.update_inbound_channels = 3
|
128
|
+
assert_requested command_stub
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def mock_response(id = nil)
|
133
|
+
{
|
134
|
+
id: (id || rand(0...1_000_000_000_000)),
|
135
|
+
record_type: :phone_number,
|
136
|
+
status: rand(1..10),
|
137
|
+
phone_number: "+15555555555",
|
138
|
+
address_id: rand(0...1_000_000_000_000),
|
139
|
+
}
|
140
|
+
end
|
141
|
+
|
142
|
+
def mock_voice_response(id = nil)
|
143
|
+
{
|
144
|
+
connection_id: (id || rand(0...1_000_000_000_000)),
|
145
|
+
connection_name: "Telnyx connection",
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
149
|
+
def mock_messaging_response(_id = nil)
|
150
|
+
{
|
151
|
+
record_type: "messaging_phone_number",
|
152
|
+
phone_number: "+18005550001",
|
153
|
+
id: "+18665550001",
|
154
|
+
}
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -5,6 +5,7 @@ require ::File.expand_path("../../test_helper", __FILE__)
|
|
5
5
|
module Telnyx
|
6
6
|
class PublicKeyTest < Test::Unit::TestCase
|
7
7
|
should "be retrievable" do
|
8
|
+
omit "mock spec removed"
|
8
9
|
public_key = Telnyx::PublicKey.retrieve
|
9
10
|
assert_requested :get, "#{Telnyx.api_base}/v2/public_key"
|
10
11
|
assert public_key.is_a?(Telnyx::PublicKey)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "../test_helper"
|
5
|
+
|
6
|
+
module Telnyx
|
7
|
+
class RegulatoryRequirementTest < Test::Unit::TestCase
|
8
|
+
should "be retrievable" do
|
9
|
+
reg_req = RegulatoryRequirement.retrieve "12345"
|
10
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/regulatory_requirements/12345"
|
11
|
+
assert_kind_of RegulatoryRequirement, reg_req
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be listable" do
|
15
|
+
reg_reqs = RegulatoryRequirement.list
|
16
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/regulatory_requirements"
|
17
|
+
assert_kind_of Array, reg_reqs.data
|
18
|
+
assert_kind_of RegulatoryRequirement, reg_reqs.first
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../test_helper"
|
4
|
+
|
5
|
+
module Telnyx
|
6
|
+
class SimCardTest < Test::Unit::TestCase
|
7
|
+
should "retrieve sim card" do
|
8
|
+
sim = Telnyx::SimCard.retrieve "123"
|
9
|
+
assert_requested(:get, "#{Telnyx.api_base}/v2/sim_cards/123")
|
10
|
+
assert_kind_of Telnyx::SimCard, sim
|
11
|
+
end
|
12
|
+
|
13
|
+
should "list sim cards" do
|
14
|
+
simlist = Telnyx::SimCard.list
|
15
|
+
assert_requested(:get, "#{Telnyx.api_base}/v2/sim_cards")
|
16
|
+
assert_kind_of Telnyx::ListObject, simlist
|
17
|
+
end
|
18
|
+
|
19
|
+
should "save sim card" do
|
20
|
+
sim = Telnyx::SimCard.retrieve "123"
|
21
|
+
sim.save
|
22
|
+
assert_requested(:get, "#{Telnyx.api_base}/v2/sim_cards/123")
|
23
|
+
end
|
24
|
+
|
25
|
+
should "register sim card" do
|
26
|
+
Telnyx::SimCard.register(registration_codes: %w[1234567890 123456332601])
|
27
|
+
assert_requested(:post, "#{Telnyx.api_base}/v2/actions/register/sim_cards")
|
28
|
+
end
|
29
|
+
|
30
|
+
context "actions" do
|
31
|
+
should "deactivate" do
|
32
|
+
sim = Telnyx::SimCard.retrieve "123"
|
33
|
+
sim.deactivate
|
34
|
+
assert_requested(:post, "#{Telnyx.api_base}/v2/sim_cards/#{sim.id}/actions/deactivate")
|
35
|
+
end
|
36
|
+
|
37
|
+
should "activate" do
|
38
|
+
sim = Telnyx::SimCard.retrieve "123"
|
39
|
+
sim.activate
|
40
|
+
assert_requested(:post, "#{Telnyx.api_base}/v2/sim_cards/#{sim.id}/actions/activate")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -244,7 +244,7 @@ module Telnyx
|
|
244
244
|
.to_return(body: JSON.generate(object: "account"))
|
245
245
|
|
246
246
|
client = TelnyxClient.new
|
247
|
-
client.execute_request(:post, "/v2/messaging_profiles")
|
247
|
+
client.execute_request(:post, "/v2/messaging_profiles", params: { name: "foobar" })
|
248
248
|
ensure
|
249
249
|
Telnyx.telnyx_account = old
|
250
250
|
end
|
@@ -324,17 +324,18 @@ module Telnyx
|
|
324
324
|
assert_equal 'Invalid response object from API: "" (HTTP response code was 500)', e.message
|
325
325
|
end
|
326
326
|
|
327
|
-
|
328
|
-
|
329
|
-
|
327
|
+
# Disabled this due to incompatibility with sim endpont actions.
|
328
|
+
# should "handle success response with empty body" do
|
329
|
+
# stub_request(:post, "#{Telnyx.api_base}/v2/messaging_profiles")
|
330
|
+
# .to_return(body: "", status: 200)
|
330
331
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
332
|
+
# client = TelnyxClient.new
|
333
|
+
# e = assert_raises Telnyx::APIError do
|
334
|
+
# client.execute_request(:post, "/v2/messaging_profiles")
|
335
|
+
# end
|
335
336
|
|
336
|
-
|
337
|
-
end
|
337
|
+
# assert_equal 'Invalid response object from API: "" (HTTP response code was 200)', e.message
|
338
|
+
# end
|
338
339
|
|
339
340
|
should "handle error response with unknown value" do
|
340
341
|
stub_request(:post, "#{Telnyx.api_base}/v2/messaging_profiles")
|