telnyx 2.2.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/scripts/before_install.sh +9 -0
- data/.github/workflows/ruby.yml +39 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +6 -36
- data/.rubocop_todo.yml +300 -0
- data/.travis.yml.bak +48 -0
- data/Gemfile +10 -6
- data/README.md +1 -1
- data/VERSION +1 -1
- data/bin/telnyx-console +5 -0
- data/examples/2 factor authentication/Gemfile +7 -0
- data/examples/2 factor authentication/main.rb +67 -0
- data/examples/2 factor authentication/readme.md +5 -0
- data/examples/fax/Gemfile +7 -0
- data/examples/fax/config.yaml +4 -0
- data/examples/fax/fax.rb +42 -0
- data/examples/fax/options.rb +41 -0
- data/examples/fax/readme.md +18 -0
- data/lib/telnyx.rb +5 -1
- data/lib/telnyx/api_operations/create.rb +6 -1
- data/lib/telnyx/api_operations/save.rb +1 -1
- data/lib/telnyx/api_resource.rb +24 -3
- data/lib/telnyx/call.rb +3 -1
- data/lib/telnyx/conference.rb +17 -1
- data/lib/telnyx/fax.rb +13 -0
- data/lib/telnyx/fax_application.rb +12 -0
- data/lib/telnyx/messaging_phone_number.rb +4 -0
- data/lib/telnyx/phone_number.rb +7 -3
- data/lib/telnyx/phone_number_regulatory_requirement.rb +1 -0
- data/lib/telnyx/sim_card.rb +12 -1
- data/lib/telnyx/telnyx_client.rb +16 -25
- data/lib/telnyx/util.rb +12 -34
- data/lib/telnyx/verification.rb +36 -0
- data/lib/telnyx/verify_profile.rb +11 -0
- data/lib/telnyx/version.rb +1 -1
- data/telnyx.gemspec +2 -2
- data/test/telnyx/alphanumeric_sender_id_test.rb +1 -1
- data/test/telnyx/api_operations_test.rb +1 -1
- data/test/telnyx/api_resource_test.rb +1 -1
- data/test/telnyx/available_phone_number_test.rb +1 -1
- data/test/telnyx/call_control_test.rb +50 -47
- data/test/telnyx/conference_test.rb +57 -20
- data/test/telnyx/credential_connection_test.rb +5 -1
- data/test/telnyx/errors_test.rb +1 -1
- data/test/telnyx/fax_application_test.rb +32 -0
- data/test/telnyx/fax_test.rb +33 -0
- data/test/telnyx/fqdn_connection_test.rb +1 -1
- data/test/telnyx/fqdn_test.rb +1 -1
- data/test/telnyx/list_object_test.rb +1 -1
- data/test/telnyx/message_test.rb +1 -1
- data/test/telnyx/messaging_phone_number_test.rb +9 -5
- data/test/telnyx/messaging_profile_test.rb +2 -2
- data/test/telnyx/number_reservation_test.rb +2 -0
- data/test/telnyx/phone_number_regulatory_requirement_test.rb +1 -1
- data/test/telnyx/phone_number_test.rb +9 -21
- data/test/telnyx/public_key_test.rb +1 -1
- data/test/telnyx/sim_card_test.rb +6 -6
- data/test/telnyx/telnyx_client_test.rb +43 -49
- data/test/telnyx/telnyx_object_test.rb +17 -19
- data/test/telnyx/telnyx_response_test.rb +1 -1
- data/test/telnyx/util_test.rb +1 -1
- data/test/telnyx/verification_test.rb +24 -0
- data/test/telnyx/verify_profile_test.rb +33 -0
- data/test/telnyx/webhook_test.rb +1 -1
- data/test/telnyx/wireless_detail_records_report_test.rb +1 -0
- data/test/telnyx_test.rb +20 -24
- data/test/test_helper.rb +1 -1
- metadata +52 -11
- data/.travis.yml +0 -51
@@ -5,14 +5,19 @@ require_relative "../test_helper"
|
|
5
5
|
module Telnyx
|
6
6
|
class ConferenceTest < Test::Unit::TestCase
|
7
7
|
setup do
|
8
|
-
@
|
9
|
-
@conference = Conference.create call_control_id: @call.id, name: "conference!"
|
8
|
+
@conference = Conference.create call_control_id: "foobar", name: "conference!"
|
10
9
|
end
|
11
10
|
should "create conference" do
|
12
11
|
assert_requested :post, "#{Telnyx.api_base}/v2/conferences"
|
13
12
|
assert_kind_of Conference, @conference
|
14
13
|
end
|
15
14
|
|
15
|
+
should "retrieve conference" do
|
16
|
+
conference = Conference.retrieve "foobar"
|
17
|
+
assert_kind_of Conference, conference
|
18
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/conferences/foobar"
|
19
|
+
end
|
20
|
+
|
16
21
|
should "list conferences" do
|
17
22
|
conferences = Conference.list
|
18
23
|
|
@@ -21,47 +26,79 @@ module Telnyx
|
|
21
26
|
assert_kind_of Conference, conferences.first
|
22
27
|
end
|
23
28
|
|
29
|
+
should "list participants" do
|
30
|
+
participants = @conference.participants
|
31
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/conferences/#{@conference.id}/participants"
|
32
|
+
assert_kind_of ListObject, participants
|
33
|
+
end
|
34
|
+
|
24
35
|
should "have nested command instance methods" do
|
25
36
|
assert defined? @conference.join
|
26
37
|
assert defined? @conference.mute
|
27
38
|
assert defined? @conference.unmute
|
28
39
|
assert defined? @conference.unhold
|
40
|
+
assert defined? @conference.play
|
41
|
+
assert defined? @conference.start_recording
|
42
|
+
assert defined? @conference.stop_recording
|
43
|
+
assert defined? @conference.speak
|
44
|
+
assert defined? @conference.dial_participant
|
45
|
+
assert defined? @conference.update
|
29
46
|
end
|
30
47
|
|
31
48
|
context "commands" do
|
32
49
|
should "join" do
|
33
|
-
|
34
|
-
|
35
|
-
@conference.join
|
36
|
-
assert_requested stub
|
50
|
+
@conference.join call_control_id: "foo_bar_baz"
|
51
|
+
assert_requested :post, action_url(@conference, "join")
|
37
52
|
end
|
38
53
|
|
39
54
|
should "mute" do
|
40
|
-
stub = stub_request(:post, format_url(@conference, "mute"))
|
41
|
-
.to_return(body: JSON.generate(result: "ok"))
|
42
55
|
@conference.mute
|
43
|
-
assert_requested
|
56
|
+
assert_requested :post, action_url(@conference, "mute")
|
44
57
|
end
|
45
58
|
|
46
59
|
should "unmute" do
|
47
|
-
stub = stub_request(:post, format_url(@conference, "unmute"))
|
48
|
-
.to_return(body: JSON.generate(result: "ok"))
|
49
60
|
@conference.unmute
|
50
|
-
assert_requested
|
61
|
+
assert_requested :post, action_url(@conference, "unmute")
|
51
62
|
end
|
52
63
|
|
53
64
|
should "hold" do
|
54
|
-
stub = stub_request(:post, format_url(@conference, "hold"))
|
55
|
-
.to_return(body: JSON.generate(result: "ok"))
|
56
65
|
@conference.hold
|
57
|
-
assert_requested
|
66
|
+
assert_requested :post, action_url(@conference, "hold")
|
58
67
|
end
|
59
68
|
|
60
69
|
should "unhold" do
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
70
|
+
@conference.unhold call_control_ids: %w[foo bar baz]
|
71
|
+
assert_requested :post, action_url(@conference, "unhold")
|
72
|
+
end
|
73
|
+
|
74
|
+
should "play" do
|
75
|
+
@conference.play audio_url: "https://example.com/audio.mp3"
|
76
|
+
assert_requested :post, action_url(@conference, "play")
|
77
|
+
end
|
78
|
+
|
79
|
+
should "start recording" do
|
80
|
+
@conference.start_recording channels: "dual", format: "mp3"
|
81
|
+
assert_requested :post, action_url(@conference, "record_start")
|
82
|
+
end
|
83
|
+
|
84
|
+
should "stop recording" do
|
85
|
+
@conference.stop_recording
|
86
|
+
assert_requested :post, action_url(@conference, "record_stop")
|
87
|
+
end
|
88
|
+
|
89
|
+
should "speak" do
|
90
|
+
@conference.speak language: "en-US", payload: "test speech", voice: "female"
|
91
|
+
assert_requested :post, action_url(@conference, "speak")
|
92
|
+
end
|
93
|
+
|
94
|
+
should "dial participant" do
|
95
|
+
@conference.dial_participant call_control_id: "foo", to: "+12223334444", from: "+12223335555"
|
96
|
+
assert_requested :post, action_url(@conference, "dial_participant")
|
97
|
+
end
|
98
|
+
|
99
|
+
should "update" do
|
100
|
+
@conference.update call_control_id: "foo", supervisor_role: "barge"
|
101
|
+
assert_requested :post, action_url(@conference, "update")
|
65
102
|
end
|
66
103
|
end
|
67
104
|
|
@@ -69,7 +106,7 @@ module Telnyx
|
|
69
106
|
Telnyx::Call.create connection_id: "12345", to: "+15550001111", from: "+15550002222"
|
70
107
|
end
|
71
108
|
|
72
|
-
def
|
109
|
+
def action_url(conf, action)
|
73
110
|
"#{Telnyx.api_base}/v2/conferences/#{conf.id}/actions/#{action}"
|
74
111
|
end
|
75
112
|
end
|
@@ -12,7 +12,11 @@ module Telnyx
|
|
12
12
|
end
|
13
13
|
|
14
14
|
should "create credential connection" do
|
15
|
-
CredentialConnection.create
|
15
|
+
CredentialConnection.create(
|
16
|
+
connection_name: "Test connection_name",
|
17
|
+
user_name: "Test user_name",
|
18
|
+
password: "correct-horse-battery-staple"
|
19
|
+
)
|
16
20
|
assert_requested :post, "#{Telnyx.api_base}/v2/credential_connections"
|
17
21
|
end
|
18
22
|
|
data/test/telnyx/errors_test.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../test_helper"
|
4
|
+
|
5
|
+
module Telnyx
|
6
|
+
class FaxApplicationTest < Test::Unit::TestCase
|
7
|
+
should "fetch index" do
|
8
|
+
fax_applications = FaxApplication.list
|
9
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/fax_applications"
|
10
|
+
assert_kind_of ListObject, fax_applications
|
11
|
+
assert_kind_of FaxApplication, fax_applications.first
|
12
|
+
end
|
13
|
+
|
14
|
+
should "create" do
|
15
|
+
fax_application = FaxApplication.create application_name: "foo", webhook_event_url: "https://foo.bar.com"
|
16
|
+
assert_requested :post, "#{Telnyx.api_base}/v2/fax_applications"
|
17
|
+
assert_kind_of FaxApplication, fax_application
|
18
|
+
end
|
19
|
+
|
20
|
+
should "retrieve" do
|
21
|
+
fax_application = FaxApplication.retrieve "foo"
|
22
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/fax_applications/foo"
|
23
|
+
assert_kind_of FaxApplication, fax_application
|
24
|
+
end
|
25
|
+
|
26
|
+
should "delete" do
|
27
|
+
fax_application = FaxApplication.retrieve "foo"
|
28
|
+
fax_application.delete
|
29
|
+
assert_requested :delete, "#{Telnyx.api_base}/v2/fax_applications/foo"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../test_helper"
|
4
|
+
|
5
|
+
module Telnyx
|
6
|
+
class FaxTest < Test::Unit::TestCase
|
7
|
+
should "fetch index" do
|
8
|
+
faxes = Fax.list
|
9
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/faxes"
|
10
|
+
assert_kind_of ListObject, faxes
|
11
|
+
assert_kind_of Fax, faxes.first
|
12
|
+
end
|
13
|
+
|
14
|
+
should "send fax" do
|
15
|
+
fax = Fax.create connection_id: "foo", media_url: "example.com", to: "+13127367276"
|
16
|
+
assert_requested :post, "#{Telnyx.api_base}/v2/faxes"
|
17
|
+
assert_kind_of Fax, fax
|
18
|
+
end
|
19
|
+
|
20
|
+
should "view fax" do
|
21
|
+
fax = Fax.retrieve "foo"
|
22
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/faxes/foo"
|
23
|
+
assert_kind_of Fax, fax
|
24
|
+
end
|
25
|
+
|
26
|
+
should "delete fax" do
|
27
|
+
omit "!!waiting for mock!!"
|
28
|
+
fax = Fax.retrieve "foo"
|
29
|
+
fax.delete
|
30
|
+
assert_requested :delete, "#{Telnyx.api_base}/v2/faxes/foo"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/test/telnyx/fqdn_test.rb
CHANGED
data/test/telnyx/message_test.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative "../test_helper"
|
4
4
|
|
5
5
|
module Telnyx
|
6
6
|
class MessagingPhoneNumberTest < Test::Unit::TestCase
|
7
7
|
should "be listable" do
|
8
8
|
messaging_phone_numbers = Telnyx::MessagingPhoneNumber.list
|
9
|
-
assert_requested :get, "#{Telnyx.api_base}/v2/messaging_phone_numbers"
|
9
|
+
# assert_requested :get, "#{Telnyx.api_base}/v2/messaging_phone_numbers"
|
10
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/phone_numbers/messaging"
|
10
11
|
assert messaging_phone_numbers.data.is_a?(Array)
|
11
12
|
assert messaging_phone_numbers.first.is_a?(Telnyx::MessagingPhoneNumber)
|
12
13
|
end
|
13
14
|
|
14
15
|
should "be retrievable" do
|
15
16
|
messaging_phone_number = Telnyx::MessagingPhoneNumber.retrieve("123")
|
16
|
-
assert_requested :get, "#{Telnyx.api_base}/v2/messaging_phone_numbers/123"
|
17
|
+
# assert_requested :get, "#{Telnyx.api_base}/v2/messaging_phone_numbers/123"
|
18
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/phone_numbers/123/messaging"
|
17
19
|
assert messaging_phone_number.is_a?(Telnyx::MessagingPhoneNumber)
|
18
20
|
end
|
19
21
|
|
@@ -21,12 +23,14 @@ module Telnyx
|
|
21
23
|
messaging_phone_number = Telnyx::MessagingPhoneNumber.retrieve("123")
|
22
24
|
messaging_phone_number.messaging_profile_id = "value"
|
23
25
|
messaging_phone_number.save
|
24
|
-
assert_requested :patch, "#{Telnyx.api_base}/v2/messaging_phone_numbers/#{messaging_phone_number.id}"
|
26
|
+
# assert_requested :patch, "#{Telnyx.api_base}/v2/messaging_phone_numbers/#{messaging_phone_number.id}"
|
27
|
+
assert_requested :patch, "#{Telnyx.api_base}/v2/phone_numbers/#{messaging_phone_number.id}/messaging"
|
25
28
|
end
|
26
29
|
|
27
30
|
should "be updateable" do
|
28
31
|
messaging_phone_number = Telnyx::MessagingPhoneNumber.update("123", messaging_profile_id: "456")
|
29
|
-
assert_requested :patch, "#{Telnyx.api_base}/v2/messaging_phone_numbers/123"
|
32
|
+
# assert_requested :patch, "#{Telnyx.api_base}/v2/messaging_phone_numbers/123"
|
33
|
+
assert_requested :patch, "#{Telnyx.api_base}/v2/phone_numbers/123/messaging"
|
30
34
|
assert messaging_phone_number.is_a?(Telnyx::MessagingPhoneNumber)
|
31
35
|
end
|
32
36
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative "../test_helper"
|
4
4
|
|
5
5
|
module Telnyx
|
6
6
|
class MessagingProfileTest < Test::Unit::TestCase
|
@@ -58,7 +58,7 @@ module Telnyx
|
|
58
58
|
phone_numbers = messaging_profile.phone_numbers
|
59
59
|
assert_requested :get, "#{Telnyx.api_base}/v2/messaging_profiles/123/phone_numbers"
|
60
60
|
assert phone_numbers.data.is_a?(Array)
|
61
|
-
|
61
|
+
assert_kind_of Telnyx::MessagingPhoneNumber, phone_numbers.data[0]
|
62
62
|
end
|
63
63
|
|
64
64
|
should "be able to list alphanumeric sender ids" do
|
@@ -7,7 +7,7 @@ module Telnyx
|
|
7
7
|
class PhoneNumberRegulatoryRequirementTest < Test::Unit::TestCase
|
8
8
|
should "be listable" do
|
9
9
|
phone_number_reg_req = PhoneNumberRegulatoryRequirement.list
|
10
|
-
assert_requested :get, "#{Telnyx.api_base}/v2/
|
10
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/phone_numbers_regulatory_requirements"
|
11
11
|
assert_kind_of PhoneNumberRegulatoryRequirement, phone_number_reg_req.first
|
12
12
|
end
|
13
13
|
end
|
@@ -69,41 +69,29 @@ module Telnyx
|
|
69
69
|
assert_equal voice.data.connection_id, "456"
|
70
70
|
end
|
71
71
|
|
72
|
+
should "list messaging" do
|
73
|
+
list = Telnyx::PhoneNumber.messaging
|
74
|
+
assert_kind_of Telnyx::ListObject, list
|
75
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/phone_numbers/messaging"
|
76
|
+
end
|
77
|
+
|
72
78
|
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
79
|
phone_number = Telnyx::PhoneNumber.retrieve("123")
|
78
80
|
phone_number.messaging
|
79
|
-
assert_requested
|
81
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/phone_numbers/123/messaging"
|
80
82
|
end
|
81
83
|
|
82
84
|
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
85
|
phone_number = Telnyx::PhoneNumber.retrieve("123")
|
89
86
|
phone_number.update_messaging(messaging_profile_id: "12345", messaging_product: "P2P")
|
90
|
-
assert_requested
|
87
|
+
assert_requested :patch, "#{Telnyx.api_base}/v2/phone_numbers/123/messaging"
|
91
88
|
end
|
92
89
|
|
93
90
|
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
91
|
phone_number = Telnyx::PhoneNumber.retrieve("123")
|
104
92
|
inbound_channels = phone_number.inbound_channels
|
105
93
|
assert_equal inbound_channels, 7
|
106
|
-
assert_requested
|
94
|
+
assert_requested :get, "#{Telnyx.api_base}/v2/phone_numbers/inbound_channels"
|
107
95
|
end
|
108
96
|
|
109
97
|
should "update inbound channel" do
|
@@ -28,16 +28,16 @@ module Telnyx
|
|
28
28
|
end
|
29
29
|
|
30
30
|
context "actions" do
|
31
|
-
should "
|
31
|
+
should "disable" do
|
32
32
|
sim = Telnyx::SimCard.retrieve "123"
|
33
|
-
sim.
|
34
|
-
assert_requested(:post, "#{Telnyx.api_base}/v2/sim_cards/#{sim.id}/actions/
|
33
|
+
sim.disable
|
34
|
+
assert_requested(:post, "#{Telnyx.api_base}/v2/sim_cards/#{sim.id}/actions/disable")
|
35
35
|
end
|
36
36
|
|
37
|
-
should "
|
37
|
+
should "enable" do
|
38
38
|
sim = Telnyx::SimCard.retrieve "123"
|
39
|
-
sim.
|
40
|
-
assert_requested(:post, "#{Telnyx.api_base}/v2/sim_cards/#{sim.id}/actions/
|
39
|
+
sim.enable
|
40
|
+
assert_requested(:post, "#{Telnyx.api_base}/v2/sim_cards/#{sim.id}/actions/enable")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative "../test_helper"
|
4
4
|
|
5
5
|
module Telnyx
|
6
6
|
class TelnyxClientTest < Test::Unit::TestCase
|
@@ -235,19 +235,17 @@ module Telnyx
|
|
235
235
|
|
236
236
|
context "Telnyx-Account header" do
|
237
237
|
should "use a globally set header" do
|
238
|
-
|
239
|
-
|
240
|
-
Telnyx.telnyx_account = "acct_1234"
|
238
|
+
old = Telnyx.telnyx_account
|
239
|
+
Telnyx.telnyx_account = "acct_1234"
|
241
240
|
|
242
|
-
|
243
|
-
|
244
|
-
|
241
|
+
stub_request(:post, "#{Telnyx.api_base}/v2/messaging_profiles")
|
242
|
+
.with(headers: { "Telnyx-Account" => Telnyx.telnyx_account })
|
243
|
+
.to_return(body: JSON.generate(object: "account"))
|
245
244
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
end
|
245
|
+
client = TelnyxClient.new
|
246
|
+
client.execute_request(:post, "/v2/messaging_profiles", params: { name: "foobar" })
|
247
|
+
ensure
|
248
|
+
Telnyx.telnyx_account = old
|
251
249
|
end
|
252
250
|
|
253
251
|
should "use a locally set header" do
|
@@ -274,40 +272,38 @@ module Telnyx
|
|
274
272
|
|
275
273
|
context "app_info" do
|
276
274
|
should "send app_info if set" do
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
)
|
275
|
+
old = Telnyx.app_info
|
276
|
+
Telnyx.set_app_info(
|
277
|
+
"MyAwesomePlugin",
|
278
|
+
partner_id: "partner_1234",
|
279
|
+
url: "https://myawesomeplugin.info",
|
280
|
+
version: "1.2.34"
|
281
|
+
)
|
285
282
|
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
283
|
+
stub_request(:post, "#{Telnyx.api_base}/v2/messaging_profiles")
|
284
|
+
.with do |req|
|
285
|
+
assert_equal \
|
286
|
+
"Telnyx/v2 RubyBindings/#{Telnyx::VERSION} " \
|
287
|
+
"MyAwesomePlugin/1.2.34 (https://myawesomeplugin.info)",
|
288
|
+
req.headers["User-Agent"]
|
292
289
|
|
293
|
-
|
294
|
-
|
290
|
+
data = JSON.parse(req.headers["X-Telnyx-Client-User-Agent"],
|
291
|
+
symbolize_names: true)
|
295
292
|
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
293
|
+
assert_equal({
|
294
|
+
name: "MyAwesomePlugin",
|
295
|
+
partner_id: "partner_1234",
|
296
|
+
url: "https://myawesomeplugin.info",
|
297
|
+
version: "1.2.34",
|
298
|
+
}, data[:application])
|
302
299
|
|
303
|
-
|
304
|
-
|
300
|
+
true
|
301
|
+
end.to_return(body: JSON.generate(record_type: "messaging_profile"))
|
305
302
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
end
|
303
|
+
client = TelnyxClient.new
|
304
|
+
client.execute_request(:post, "/v2/messaging_profiles")
|
305
|
+
ensure
|
306
|
+
Telnyx.app_info = old
|
311
307
|
end
|
312
308
|
end
|
313
309
|
|
@@ -591,16 +587,14 @@ module Telnyx
|
|
591
587
|
end
|
592
588
|
|
593
589
|
should "reset local thread state after a call" do
|
594
|
-
|
595
|
-
Thread.current[:telnyx_client] = :telnyx_client
|
590
|
+
Thread.current[:telnyx_client] = :telnyx_client
|
596
591
|
|
597
|
-
|
598
|
-
|
592
|
+
client = TelnyxClient.new
|
593
|
+
client.request {}
|
599
594
|
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
end
|
595
|
+
assert_equal :telnyx_client, Thread.current[:telnyx_client]
|
596
|
+
ensure
|
597
|
+
Thread.current[:telnyx_client] = nil
|
604
598
|
end
|
605
599
|
end
|
606
600
|
end
|