telnyx 2.4.0 → 2.8.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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +2 -2
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +1 -1
  5. data/Gemfile +5 -1
  6. data/VERSION +1 -1
  7. data/lib/telnyx.rb +1 -0
  8. data/lib/telnyx/api_operations/create.rb +6 -1
  9. data/lib/telnyx/api_resource.rb +10 -0
  10. data/lib/telnyx/call.rb +3 -1
  11. data/lib/telnyx/messaging_phone_number.rb +0 -5
  12. data/lib/telnyx/phone_number.rb +2 -2
  13. data/lib/telnyx/phone_number_regulatory_requirement.rb +1 -0
  14. data/lib/telnyx/telephony_credential.rb +12 -0
  15. data/lib/telnyx/telnyx_client.rb +1 -1
  16. data/lib/telnyx/util.rb +12 -39
  17. data/lib/telnyx/verification.rb +29 -0
  18. data/lib/telnyx/version.rb +1 -1
  19. data/telnyx.gemspec +2 -2
  20. data/test/telnyx/alphanumeric_sender_id_test.rb +1 -1
  21. data/test/telnyx/api_operations_test.rb +1 -1
  22. data/test/telnyx/api_resource_test.rb +1 -1
  23. data/test/telnyx/available_phone_number_test.rb +1 -1
  24. data/test/telnyx/call_control_test.rb +48 -45
  25. data/test/telnyx/conference_test.rb +1 -1
  26. data/test/telnyx/errors_test.rb +1 -1
  27. data/test/telnyx/fax_test.rb +1 -0
  28. data/test/telnyx/list_object_test.rb +1 -1
  29. data/test/telnyx/message_test.rb +1 -1
  30. data/test/telnyx/messaging_phone_number_test.rb +1 -1
  31. data/test/telnyx/messaging_profile_test.rb +1 -1
  32. data/test/telnyx/number_reservation_test.rb +2 -0
  33. data/test/telnyx/phone_number_regulatory_requirement_test.rb +1 -1
  34. data/test/telnyx/public_key_test.rb +1 -1
  35. data/test/telnyx/telephony_credential_test.rb +43 -0
  36. data/test/telnyx/telnyx_client_test.rb +43 -49
  37. data/test/telnyx/telnyx_object_test.rb +12 -14
  38. data/test/telnyx/telnyx_response_test.rb +1 -1
  39. data/test/telnyx/util_test.rb +1 -1
  40. data/test/telnyx/verification_test.rb +41 -3
  41. data/test/telnyx/verify_profile_test.rb +2 -0
  42. data/test/telnyx/webhook_test.rb +1 -1
  43. data/test/telnyx/wireless_detail_records_report_test.rb +1 -0
  44. data/test/telnyx_test.rb +20 -24
  45. metadata +22 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbfad03f6f54106bf7c6a1257febe38d392921e17352d3d6acbd3ecb1e7a30dd
4
- data.tar.gz: a51edd8d431e5b45b4fb178eb59a51d3350bca6e21790c82d86b3fa3c435af37
3
+ metadata.gz: f1f463fe082759c9cb99808df9016e908788912ac9a6d1f5c7de4b29c27ca891
4
+ data.tar.gz: cf8bb9e8030e6fac0063cd876339ea73b6db99e911c865af06c49bf7baa7ae7c
5
5
  SHA512:
6
- metadata.gz: ce3781a4464b221f9b0386ab6a2bf5330b2f3b87d9ab8e916c6e8b54b15c8e8a010487714ffb6a8f1bddaad59ac52eeea6a60ac63ca0da94d674282cd836b238
7
- data.tar.gz: 18204899a08b75d02346eb1612223c5f79ddf2d0b1bafee880c27b8a2bd4daecbd827b3caf1a9585aa560fe3a15e0a3446ce44c67e5c2ca911efcc46ff9a5589
6
+ metadata.gz: 4cc528c37b37e18abb166a4e10bd97631ded62a951ce8ce221ddf7c867488046db85ff96bbb4c0b97c23350113d978286e5c5c6251b5879b3f8b47f09d29e797
7
+ data.tar.gz: 6e35320931291772a01de09fd2bd2e7301fb1f92d158bb4e71fa00c7b4eb4774ce13714ef30eb59a2e76d81a69704b21ff52a50735045c4ba786cd0d063c64d5
@@ -16,11 +16,11 @@ on:
16
16
  jobs:
17
17
  test:
18
18
  env:
19
- TELNYX_MOCK_VERSION: 0.8.10
19
+ TELNYX_MOCK_VERSION: 0.8.13
20
20
  runs-on: ubuntu-latest
21
21
  strategy:
22
22
  matrix:
23
- ruby: [ '2.5', '2.6', '2.7' ]
23
+ ruby: [ '2.5', '2.6', '2.7', '3.0' ]
24
24
  steps:
25
25
  - uses: actions/checkout@v2
26
26
  - name: Set up Ruby
data/.gitignore CHANGED
@@ -6,3 +6,6 @@ tags
6
6
  /.bundle/
7
7
  coverage/
8
8
  .idea/
9
+ vendor/*
10
+ TAGS
11
+ .ruby-version
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ inherit_from: .rubocop_todo.yml
3
3
 
4
4
  AllCops:
5
5
  DisplayCopNames: true
6
- TargetRubyVersion: 2.4
6
+ TargetRubyVersion: 2.7
7
7
  NewCops: disable
8
8
 
9
9
  Layout/CaseIndentation:
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ gemspec
6
6
 
7
7
  group :development do
8
8
  gem "coveralls", require: false
9
- gem "faraday", "0.17.3"
9
+ gem "faraday", "~> 1.0"
10
10
  gem "mocha", "~> 0.13.2"
11
11
  gem "rake"
12
12
  gem "shoulda-context"
@@ -24,6 +24,10 @@ group :development do
24
24
  gem "guard-rubocop"
25
25
  gem "rubocop", "~> 1.6"
26
26
 
27
+ # debugging
28
+ # gem 'httplog' # when included logs all http requests
29
+ # gem 'awesome_print'
30
+
27
31
  # Rack 2.0+ requires Ruby >= 2.2.2 which is problematic for the test suite on
28
32
  # older Ruby versions. Check Ruby the version here and put a maximum
29
33
  # constraint on Rack if necessary.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.4.0
1
+ 2.8.0
data/lib/telnyx.rb CHANGED
@@ -66,6 +66,7 @@ require "telnyx/portout"
66
66
  require "telnyx/public_key"
67
67
  require "telnyx/regulatory_requirement"
68
68
  require "telnyx/sim_card"
69
+ require "telnyx/telephony_credential"
69
70
  require "telnyx/verification"
70
71
  require "telnyx/verify_profile"
71
72
  require "telnyx/wireless_detail_records_report"
@@ -4,7 +4,12 @@ module Telnyx
4
4
  module APIOperations
5
5
  module Create
6
6
  def create(params = {}, opts = {})
7
- resp, opts = request(:post, resource_url, params, opts)
7
+ if opts.respond_to? :fetch
8
+ url = opts.fetch(:resource_url, nil)
9
+ opts.delete :resource_url
10
+ end
11
+ url ||= resource_url
12
+ resp, opts = request(:post, url, params, opts)
8
13
  Util.convert_to_telnyx_object(resp.data, opts)
9
14
  end
10
15
  end
@@ -10,6 +10,16 @@ module Telnyx
10
10
  # own endpoints, but there are certain cases where this is allowed.
11
11
  attr_accessor :save_with_parent
12
12
 
13
+ class << self
14
+ def inherited(subclass)
15
+ super
16
+ @descendants ||= []
17
+ @descendants << subclass
18
+ end
19
+
20
+ attr_reader :descendants
21
+ end
22
+
13
23
  def self.class_name
14
24
  name.split("::")[-1]
15
25
  end
data/lib/telnyx/call.rb CHANGED
@@ -33,7 +33,9 @@ module Telnyx
33
33
 
34
34
  ACTIONS = %w[reject answer hangup bridge speak fork_start fork_stop
35
35
  gather_using_audio gather_using_speak playback_start
36
- playback_stop record_start record_stop send_dtmf transfer].freeze
36
+ playback_stop record_start record_stop send_dtmf transfer
37
+ transcription_start transcription_stop record_pause
38
+ record_resume gather_stop refer enqueue leave_queue].freeze
37
39
 
38
40
  ACTIONS.each do |action|
39
41
  nested_resource_class_methods action,
@@ -5,11 +5,6 @@ module Telnyx
5
5
  include Telnyx::APIOperations::Save
6
6
  extend Telnyx::APIOperations::List
7
7
 
8
- def initialize(*)
9
- super
10
- warn "[DEPRECATION] MessagingPhoneNumber is deprecated, use PhoneNumber instead"
11
- end
12
-
13
8
  OBJECT_NAME = "messaging_phone_number".freeze
14
9
  def self.resource_path(id = nil)
15
10
  return "phone_numbers/#{CGI.escape(id)}/messaging" if id
@@ -35,8 +35,8 @@ module Telnyx
35
35
  self.class.list_inbound_channels(nil).channels
36
36
  end
37
37
 
38
- def self.list_voice
39
- list_voices nil
38
+ def self.list_voice(*args, **kwargs)
39
+ list_voices(nil, *args, **kwargs)
40
40
  end
41
41
 
42
42
  def self.messaging
@@ -5,5 +5,6 @@ module Telnyx
5
5
  extend APIOperations::List
6
6
 
7
7
  OBJECT_NAME = "phone_number_regulatory_requirement".freeze
8
+ RESOURCE_PATH = "phone_numbers_regulatory_requirements".freeze
8
9
  end
9
10
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telnyx
4
+ class TelephonyCredential < APIResource
5
+ extend Telnyx::APIOperations::List
6
+ extend Telnyx::APIOperations::Create
7
+ include Telnyx::APIOperations::Save
8
+ include Telnyx::APIOperations::Delete
9
+
10
+ OBJECT_NAME = "telephony_credential".freeze
11
+ end
12
+ end
@@ -240,7 +240,7 @@ module Telnyx
240
240
  end
241
241
 
242
242
  case e
243
- when Faraday::ClientError
243
+ when Faraday::Error
244
244
  if e.response
245
245
  handle_error_response(e.response, error_context)
246
246
  else
data/lib/telnyx/util.rb CHANGED
@@ -37,45 +37,18 @@ module Telnyx
37
37
  end
38
38
 
39
39
  def self.object_classes
40
- @object_classes ||= {
41
- # business objects
42
- Address::OBJECT_NAME => Address,
43
- AlphanumericSenderId::OBJECT_NAME => AlphanumericSenderId,
44
- AvailablePhoneNumber::OBJECT_NAME => AvailablePhoneNumber,
45
- BillingGroup::OBJECT_NAME => BillingGroup,
46
- Call::OBJECT_NAME => Call,
47
- CallControlApplication::OBJECT_NAME => CallControlApplication,
48
- Conferences::OBJECT_NAME => Conferences,
49
- Connection::OBJECT_NAME => Connection,
50
- CredentialConnection::OBJECT_NAME => CredentialConnection,
51
- Fax::OBJECT_NAME => Fax,
52
- FaxApplication::OBJECT_NAME => FaxApplication,
53
- FQDN::OBJECT_NAME => FQDN,
54
- FQDNConnection::OBJECT_NAME => FQDNConnection,
55
- IP::OBJECT_NAME => IP,
56
- IPConnection::OBJECT_NAME => IPConnection,
57
- Message::OBJECT_NAME => Message,
58
- MessagingPhoneNumber::OBJECT_NAME => MessagingPhoneNumber,
59
- "messaging_settings" => MessagingPhoneNumber,
60
- MessagingProfile::OBJECT_NAME => MessagingProfile,
61
- NumberLookup::OBJECT_NAME => NumberLookup,
62
- NumberOrder::OBJECT_NAME => NumberOrder,
63
- NumberOrderDocument::OBJECT_NAME => NumberOrderDocument,
64
- NumberReservation::OBJECT_NAME => NumberReservation,
65
- OutboundVoiceProfile::OBJECT_NAME => OutboundVoiceProfile,
66
- PhoneNumber::OBJECT_NAME => PhoneNumber,
67
- "phone_number_reservation" => NumberReservation,
68
- PhoneNumberRegulatoryRequirement::OBJECT_NAME => PhoneNumberRegulatoryRequirement,
69
- "phone_number_regulatory_group" => PhoneNumberRegulatoryRequirement,
70
- Portout::OBJECT_NAME => Portout,
71
- VerifyProfile::OBJECT_NAME => VerifyProfile,
72
- PublicKey::OBJECT_NAME => PublicKey,
73
- RegulatoryRequirement::OBJECT_NAME => RegulatoryRequirement,
74
- SimCard::OBJECT_NAME => SimCard,
75
- Verification::OBJECT_NAME => Verification,
76
- "verification" => Verification::Response,
77
- WirelessDetailRecordsReport::OBJECT_NAME => WirelessDetailRecordsReport,
78
- }
40
+ @object_classes ||= APIResource.descendants
41
+ .select { |klass| klass.constants(false).include? :OBJECT_NAME }
42
+ .map { |klass| [klass::OBJECT_NAME, klass] }
43
+ .to_h
44
+ .merge(
45
+ "credential" => TelephonyCredential,
46
+ "messaging_settings" => MessagingPhoneNumber,
47
+ "phone_number_regulatory_group" => PhoneNumberRegulatoryRequirement,
48
+ "phone_number_reservation" => NumberReservation,
49
+ "verification_profile" => VerifyProfile,
50
+ "verification" => Verification::Response
51
+ )
79
52
  end
80
53
 
81
54
  def self.push_object_class(key, klass)
@@ -8,6 +8,10 @@ module Telnyx
8
8
  extend APIOperations::Create
9
9
  extend APIOperations::NestedResource
10
10
 
11
+ class << self
12
+ private :create
13
+ end
14
+
11
15
  nested_resource_class_methods "by_telephone",
12
16
  path: "by_tn",
13
17
  operations: [:retrieve],
@@ -21,6 +25,31 @@ module Telnyx
21
25
  Response.construct_from resp.data[:data]
22
26
  end
23
27
 
28
+ # Trigger a call verification.
29
+ def self.call(params = {}, opts = {})
30
+ create(params, { **opts, resource_url: "#{resource_url}/call" })
31
+ end
32
+
33
+ # Trigger an SMS verification.
34
+ def self.sms(params = {}, opts = {})
35
+ create(params, { **opts, resource_url: "#{resource_url}/sms" })
36
+ end
37
+
38
+ # Trigger a PSD2 verification.
39
+ def self.psd2(params = {}, opts = {})
40
+ create(params, { **opts, resource_url: "#{resource_url}/psd2" })
41
+ end
42
+
43
+ # Trigger a flashcall verification.
44
+ def self.flashcall(params = {}, opts = {})
45
+ create(params, { **opts, resource_url: "#{resource_url}/flashcall" })
46
+ end
47
+
48
+ # Trigger a whatsapp verification.
49
+ def self.whatsapp(params = {}, opts = {})
50
+ create(params, { **opts, resource_url: "#{resource_url}/whatsapp" })
51
+ end
52
+
24
53
  OBJECT_NAME = "verify_verification".freeze
25
54
  RESOURCE_PATH = "verifications".freeze
26
55
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Telnyx
4
- VERSION = "2.4.0".freeze
4
+ VERSION = "2.8.0".freeze
5
5
  end
data/telnyx.gemspec CHANGED
@@ -22,8 +22,8 @@ Gem::Specification.new do |s|
22
22
  "source_code_uri" => "https://github.com/team-telnyx/telnyx-ruby",
23
23
  }
24
24
 
25
- s.add_dependency("faraday", "~> 0.13", "!= 0.16.0", "!= 0.16.1", "!= 0.16.2", "!= 0.17.1")
26
- s.add_dependency("net-http-persistent", "~> 3.0")
25
+ s.add_dependency("faraday", ">= 0.13", "< 2.0", "!= 0.16.0", "!= 0.16.1", "!= 0.16.2", "!= 0.17.1")
26
+ s.add_dependency("net-http-persistent", ">= 3.0", "< 5.0")
27
27
  s.add_dependency("ed25519", "~> 1")
28
28
 
29
29
  s.files = `git ls-files`.split("\n")
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require ::File.expand_path("../../test_helper", __FILE__)
3
+ require_relative "../test_helper"
4
4
 
5
5
  module Telnyx
6
6
  class AlphanumericSenderIdTest < Test::Unit::TestCase
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # frozen_string_literal: true
3
3
 
4
- require ::File.expand_path("../../test_helper", __FILE__)
4
+ require_relative "../test_helper"
5
5
 
6
6
  module Telnyx
7
7
  class ApiOperationsTest < Test::Unit::TestCase
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # frozen_string_literal: true
3
3
 
4
- require ::File.expand_path("../../test_helper", __FILE__)
4
+ require_relative "../test_helper"
5
5
 
6
6
  module Telnyx
7
7
  class ApiResourceTest < Test::Unit::TestCase
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require ::File.expand_path("../../test_helper", __FILE__)
3
+ require_relative "../test_helper"
4
4
 
5
5
  module Telnyx
6
6
  class AvailablePhoneNumberTest < Test::Unit::TestCase
@@ -37,6 +37,8 @@ module Telnyx
37
37
  assert defined? @call.record_stop
38
38
  assert defined? @call.send_dtmf
39
39
  assert defined? @call.transfer
40
+ assert defined? @call.enqueue
41
+ assert defined? @call.leave_queue
40
42
  end
41
43
  end
42
44
 
@@ -62,91 +64,92 @@ module Telnyx
62
64
  assert call.call_leg_id
63
65
  assert call.call_session_id
64
66
  end
65
-
66
- should "send all commands" do
67
- @call = Call.new
68
- @call.id = "1234"
69
- @call.reject cause: "CALL_REJECTED"
70
- assert_requested :post, format_url(@call, "reject")
71
- @call.answer
72
- assert_requested :post, format_url(@call, "answer")
73
- @call.hangup
74
- assert_requested :post, format_url(@call, "hangup")
75
- @call.bridge call_control_id: SecureRandom.base64(20)
76
- assert_requested :post, format_url(@call, "bridge")
77
- @call.speak language: "en-US", voice: "female", payload: "Telnyx call control test"
78
- assert_requested :post, format_url(@call, "speak")
79
- @call.fork_start call_control_id: SecureRandom.base64(20)
80
- assert_requested :post, format_url(@call, "fork_start")
81
- @call.fork_stop
82
- assert_requested :post, format_url(@call, "fork_stop")
83
- @call.gather_using_audio audio_url: "https://audio.example.com"
84
- assert_requested :post, format_url(@call, "gather_using_audio")
85
- @call.gather_using_speak language: "en-US", voice: "female", payload: "Telnyx call control test"
86
- assert_requested :post, format_url(@call, "gather_using_speak")
87
- @call.playback_start audio_url: "https://audio.example.com"
88
- assert_requested :post, format_url(@call, "playback_start")
89
- @call.playback_stop
90
- assert_requested :post, format_url(@call, "playback_stop")
91
- @call.send_dtmf digits: "1www2WABCDw9"
92
- assert_requested :post, format_url(@call, "send_dtmf")
93
- @call.transfer to: "+15552223333"
94
- assert_requested :post, format_url(@call, "transfer")
95
- end
96
67
  end
97
68
 
98
69
  context "commands" do
99
70
  should "reject" do
100
71
  @call.reject cause: "CALL_REJECTED"
101
- assert_requested :post, format_url(@call, "reject")
72
+ assert_requested :post, format_action_url(@call, "reject")
102
73
  end
103
74
  should "answer" do
104
75
  @call.answer
105
- assert_requested :post, format_url(@call, "answer")
76
+ assert_requested :post, format_action_url(@call, "answer")
106
77
  end
107
78
  should "hangup" do
108
79
  @call.hangup
109
- assert_requested :post, format_url(@call, "hangup")
80
+ assert_requested :post, format_action_url(@call, "hangup")
110
81
  end
111
82
  should "bridge" do
112
83
  @call.bridge call_control_id: SecureRandom.base64(20)
113
- assert_requested :post, format_url(@call, "bridge")
84
+ assert_requested :post, format_action_url(@call, "bridge")
114
85
  end
115
86
  should "speak" do
116
87
  @call.speak language: "en-US", voice: "female", payload: "Telnyx call control test"
117
- assert_requested :post, format_url(@call, "speak")
88
+ assert_requested :post, format_action_url(@call, "speak")
118
89
  end
119
90
  should "start fork" do
120
91
  @call.fork_start call_control_id: SecureRandom.base64(20)
121
- assert_requested :post, format_url(@call, "fork_start")
92
+ assert_requested :post, format_action_url(@call, "fork_start")
122
93
  end
123
94
  should "stop fork" do
124
95
  @call.fork_stop
125
- assert_requested :post, format_url(@call, "fork_stop")
96
+ assert_requested :post, format_action_url(@call, "fork_stop")
126
97
  end
127
98
  should "gather using audio" do
128
99
  @call.gather_using_audio audio_url: "https://audio.example.com"
129
- assert_requested :post, format_url(@call, "gather_using_audio")
100
+ assert_requested :post, format_action_url(@call, "gather_using_audio")
130
101
  end
131
102
  should "gather using speak" do
132
103
  @call.gather_using_speak language: "en-US", voice: "female", payload: "Telnyx call control test"
133
- assert_requested :post, format_url(@call, "gather_using_speak")
104
+ assert_requested :post, format_action_url(@call, "gather_using_speak")
134
105
  end
135
106
  should "playback start" do
136
107
  @call.playback_start audio_url: "https://audio.example.com"
137
- assert_requested :post, format_url(@call, "playback_start")
108
+ assert_requested :post, format_action_url(@call, "playback_start")
138
109
  end
139
110
  should "playback stop" do
140
111
  @call.playback_stop
141
- assert_requested :post, format_url(@call, "playback_stop")
112
+ assert_requested :post, format_action_url(@call, "playback_stop")
142
113
  end
143
114
  should "send dtmf" do
144
115
  @call.send_dtmf digits: "1www2WABCDw9"
145
- assert_requested :post, format_url(@call, "send_dtmf")
116
+ assert_requested :post, format_action_url(@call, "send_dtmf")
146
117
  end
147
118
  should "transfer" do
148
119
  @call.transfer to: "+15552223333"
149
- assert_requested :post, format_url(@call, "transfer")
120
+ assert_requested :post, format_action_url(@call, "transfer")
121
+ end
122
+ should "start transcription" do
123
+ @call.transcription_start
124
+ assert_requested :post, format_action_url(@call, "transcription_start")
125
+ end
126
+ should "end transcription" do
127
+ @call.transcription_stop
128
+ assert_requested :post, format_action_url(@call, "transcription_stop")
129
+ end
130
+ should "pause recording" do
131
+ @call.record_pause
132
+ assert_requested :post, format_action_url(@call, "record_pause")
133
+ end
134
+ should "resume recording" do
135
+ @call.record_resume
136
+ assert_requested :post, format_action_url(@call, "record_resume")
137
+ end
138
+ should "gather stop" do
139
+ @call.gather_stop
140
+ assert_requested :post, format_action_url(@call, "gather_stop")
141
+ end
142
+ should "refer" do
143
+ @call.refer sip_address: "sip:username@sip.non-telnyx-address.com"
144
+ assert_requested :post, format_action_url(@call, "refer")
145
+ end
146
+ should "enqueue" do
147
+ @call.enqueue call_control_id: SecureRandom.base64(20)
148
+ assert_requested :post, format_action_url(@call, "enqueue")
149
+ end
150
+ should "leave_queue" do
151
+ @call.leave_queue call_control_id: SecureRandom.base64(20)
152
+ assert_requested :post, format_action_url(@call, "leave_queue")
150
153
  end
151
154
  end
152
155
 
@@ -154,7 +157,7 @@ module Telnyx
154
157
  Telnyx::Call.create connection_id: "12345", to: "+15550001111", from: "+15550002222", cause: "test"
155
158
  end
156
159
 
157
- def format_url(call, action)
160
+ def format_action_url(call, action)
158
161
  "#{Telnyx.api_base}/v2/calls/#{call.call_control_id}/actions/#{action}"
159
162
  end
160
163
  end
@@ -97,7 +97,7 @@ module Telnyx
97
97
  end
98
98
 
99
99
  should "update" do
100
- @conference.update call_control_id: "foo"
100
+ @conference.update call_control_id: "foo", supervisor_role: "barge"
101
101
  assert_requested :post, action_url(@conference, "update")
102
102
  end
103
103
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require ::File.expand_path("../../test_helper", __FILE__)
3
+ require_relative "../test_helper"
4
4
 
5
5
  module Telnyx
6
6
  class TelnyxErrorTest < Test::Unit::TestCase
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "../test_helper"
4
+
4
5
  module Telnyx
5
6
  class FaxTest < Test::Unit::TestCase
6
7
  should "fetch index" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require ::File.expand_path("../../test_helper", __FILE__)
3
+ require_relative "../test_helper"
4
4
 
5
5
  module Telnyx
6
6
  class ListObjectTest < Test::Unit::TestCase
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require ::File.expand_path("../../test_helper", __FILE__)
3
+ require_relative "../test_helper"
4
4
 
5
5
  module Telnyx
6
6
  class MessageTest < Test::Unit::TestCase
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require ::File.expand_path("../../test_helper", __FILE__)
3
+ require_relative "../test_helper"
4
4
 
5
5
  module Telnyx
6
6
  class MessagingPhoneNumberTest < Test::Unit::TestCase
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require ::File.expand_path("../../test_helper", __FILE__)
3
+ require_relative "../test_helper"
4
4
 
5
5
  module Telnyx
6
6
  class MessagingProfileTest < Test::Unit::TestCase
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "../test_helper"
4
+
3
5
  module Telnyx
4
6
  class NumberReservationTest < Test::Unit::TestCase
5
7
  should "be listable" 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/phone_number_regulatory_requirements"
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require ::File.expand_path("../../test_helper", __FILE__)
3
+ require_relative "../test_helper"
4
4
 
5
5
  module Telnyx
6
6
  class PublicKeyTest < Test::Unit::TestCase
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../test_helper"
4
+
5
+ module Telnyx
6
+ class TelephonyCredentialTest < Test::Unit::TestCase
7
+ should "list telephony credentials" do
8
+ telephony_credentials = TelephonyCredential.list
9
+ assert_requested :get, "#{Telnyx.api_base}/v2/telephony_credentials"
10
+ assert_kind_of ListObject, telephony_credentials
11
+ assert_kind_of TelephonyCredential, telephony_credentials.first
12
+ end
13
+
14
+ should "create telephony credential" do
15
+ TelephonyCredential.create(
16
+ name: "Test credential",
17
+ connection_id: "1234567890"
18
+ )
19
+ assert_requested :post, "#{Telnyx.api_base}/v2/telephony_credentials"
20
+ end
21
+
22
+ should "retrieve telephony credential" do
23
+ telephony_credential = TelephonyCredential.retrieve("id")
24
+ assert_requested :get, "#{Telnyx.api_base}/v2/telephony_credentials/id"
25
+ assert_kind_of TelephonyCredential, telephony_credential
26
+ end
27
+
28
+ should "delete telephony credential" do
29
+ telephony_credential = TelephonyCredential.retrieve("id")
30
+
31
+ telephony_credential.delete
32
+ assert_requested :delete, "#{Telnyx.api_base}/v2/telephony_credentials/id"
33
+ end
34
+
35
+ should "update telephony credential" do
36
+ telephony_credential = TelephonyCredential.retrieve("id")
37
+
38
+ telephony_credential.expires_at = "2021-07-27T17:58:54Z"
39
+ telephony_credential.save
40
+ assert_requested :patch, "#{Telnyx.api_base}/v2/telephony_credentials/id"
41
+ end
42
+ end
43
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require ::File.expand_path("../../test_helper", __FILE__)
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
- begin
239
- old = Telnyx.telnyx_account
240
- Telnyx.telnyx_account = "acct_1234"
238
+ old = Telnyx.telnyx_account
239
+ Telnyx.telnyx_account = "acct_1234"
241
240
 
242
- stub_request(:post, "#{Telnyx.api_base}/v2/messaging_profiles")
243
- .with(headers: { "Telnyx-Account" => Telnyx.telnyx_account })
244
- .to_return(body: JSON.generate(object: "account"))
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
- client = TelnyxClient.new
247
- client.execute_request(:post, "/v2/messaging_profiles", params: { name: "foobar" })
248
- ensure
249
- Telnyx.telnyx_account = old
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
- begin
278
- old = Telnyx.app_info
279
- Telnyx.set_app_info(
280
- "MyAwesomePlugin",
281
- partner_id: "partner_1234",
282
- url: "https://myawesomeplugin.info",
283
- version: "1.2.34"
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
- stub_request(:post, "#{Telnyx.api_base}/v2/messaging_profiles")
287
- .with do |req|
288
- assert_equal \
289
- "Telnyx/v2 RubyBindings/#{Telnyx::VERSION} " \
290
- "MyAwesomePlugin/1.2.34 (https://myawesomeplugin.info)",
291
- req.headers["User-Agent"]
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
- data = JSON.parse(req.headers["X-Telnyx-Client-User-Agent"],
294
- symbolize_names: true)
290
+ data = JSON.parse(req.headers["X-Telnyx-Client-User-Agent"],
291
+ symbolize_names: true)
295
292
 
296
- assert_equal({
297
- name: "MyAwesomePlugin",
298
- partner_id: "partner_1234",
299
- url: "https://myawesomeplugin.info",
300
- version: "1.2.34",
301
- }, data[:application])
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
- true
304
- end.to_return(body: JSON.generate(record_type: "messaging_profile"))
300
+ true
301
+ end.to_return(body: JSON.generate(record_type: "messaging_profile"))
305
302
 
306
- client = TelnyxClient.new
307
- client.execute_request(:post, "/v2/messaging_profiles")
308
- ensure
309
- Telnyx.app_info = old
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
- begin
595
- Thread.current[:telnyx_client] = :telnyx_client
590
+ Thread.current[:telnyx_client] = :telnyx_client
596
591
 
597
- client = TelnyxClient.new
598
- client.request {}
592
+ client = TelnyxClient.new
593
+ client.request {}
599
594
 
600
- assert_equal :telnyx_client, Thread.current[:telnyx_client]
601
- ensure
602
- Thread.current[:telnyx_client] = nil
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require ::File.expand_path("../../test_helper", __FILE__)
3
+ require_relative "../test_helper"
4
4
 
5
5
  module Telnyx
6
6
  class TelnyxObjectTest < Test::Unit::TestCase
@@ -159,21 +159,19 @@ module Telnyx
159
159
 
160
160
  context "#to_hash" do
161
161
  should "skip calling to_hash on nil" do
162
- begin
163
- module NilWithToHash
164
- def to_hash
165
- raise "Can't call to_hash on nil"
166
- end
162
+ module NilWithToHash
163
+ def to_hash
164
+ raise "Can't call to_hash on nil"
167
165
  end
168
- ::NilClass.include NilWithToHash
169
-
170
- hash_with_nil = { id: 3, foo: nil }
171
- obj = TelnyxObject.construct_from(hash_with_nil)
172
- expected_hash = { id: 3, foo: nil }
173
- assert_equal expected_hash, obj.to_hash
174
- ensure
175
- ::NilClass.send(:undef_method, :to_hash)
176
166
  end
167
+ ::NilClass.include NilWithToHash
168
+
169
+ hash_with_nil = { id: 3, foo: nil }
170
+ obj = TelnyxObject.construct_from(hash_with_nil)
171
+ expected_hash = { id: 3, foo: nil }
172
+ assert_equal expected_hash, obj.to_hash
173
+ ensure
174
+ ::NilClass.send(:undef_method, :to_hash)
177
175
  end
178
176
 
179
177
  should "recursively call to_hash on its values" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require ::File.expand_path("../../test_helper", __FILE__)
3
+ require_relative "../test_helper"
4
4
 
5
5
  module Telnyx
6
6
  class TelnyxResponseTest < Test::Unit::TestCase
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require ::File.expand_path("../../test_helper", __FILE__)
3
+ require_relative "../test_helper"
4
4
 
5
5
  module Telnyx
6
6
  class UtilTest < Test::Unit::TestCase
@@ -1,10 +1,48 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "../test_helper"
4
+
3
5
  module Telnyx
4
6
  class VerificationTest < Test::Unit::TestCase
5
- should "create verification" do
6
- Verification.create phone_number: "+15555555555", twofa_profile_id: "1234", type: "sms", verify_profile_id: "foobar"
7
- assert_requested :post, "#{Telnyx.api_base}/v2/verifications"
7
+ context "create verification" do
8
+ should "call" do
9
+ Verification.call phone_number: "+15555555555",
10
+ verify_profile_id: "12ade33a-21c0-473b-b055-b3c836e1c292"
11
+ assert_requested :post, "#{Telnyx.api_base}/v2/verifications/call"
12
+ end
13
+
14
+ should "send sms" do
15
+ Verification.sms phone_number: "+15555555555",
16
+ verify_profile_id: "12ade33a-21c0-473b-b055-b3c836e1c292",
17
+ timeout_secs: 600
18
+ assert_requested :post, "#{Telnyx.api_base}/v2/verifications/sms"
19
+ end
20
+
21
+ should "trigger psd2" do
22
+ Verification.psd2 phone_number: "+15555555555",
23
+ verify_profile_id: "12ade33a-21c0-473b-b055-b3c836e1c292",
24
+ amount: "12.34",
25
+ currency: "USD",
26
+ payee: "FooBar Inc.",
27
+ timeout_secs: 600
28
+
29
+ assert_requested :post, "#{Telnyx.api_base}/v2/verifications/psd2"
30
+ end
31
+
32
+ should "flashcall" do
33
+ Verification.flashcall phone_number: "+15555555555",
34
+ timeout_secs: 600,
35
+ verify_profile_id: "12ade33a-21c0-473b-b055-b3c836e1c292"
36
+ assert_requested :post, "#{Telnyx.api_base}/v2/verifications/flashcall"
37
+ end
38
+
39
+ should "whatsapp" do
40
+ Verification.whatsapp phone_number: "+15555555555",
41
+ timeout_secs: 600,
42
+ verify_profile_id: "12ade33a-21c0-473b-b055-b3c836e1c292",
43
+ app_name: "FooBar"
44
+ assert_requested :post, "#{Telnyx.api_base}/v2/verifications/whatsapp"
45
+ end
8
46
  end
9
47
 
10
48
  should "retrieve verification" do
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "../test_helper"
4
+
3
5
  module Telnyx
4
6
  class VerifyProfileTest < Test::Unit::TestCase
5
7
  should "list verify_profiles" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require ::File.expand_path("../../test_helper", __FILE__)
3
+ require_relative "../test_helper"
4
4
  require "securerandom"
5
5
 
6
6
  module Telnyx
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "../test_helper"
4
+
4
5
  module Telnyx
5
6
  class WirelessDetailRecordsReportTest < Test::Unit::TestCase
6
7
  should "list detail records report" do
data/test/telnyx_test.rb CHANGED
@@ -4,33 +4,29 @@ require ::File.expand_path("../test_helper", __FILE__)
4
4
 
5
5
  class TelnyxTest < Test::Unit::TestCase
6
6
  should "allow app_info to be configured" do
7
- begin
8
- old = Telnyx.app_info
9
- Telnyx.set_app_info(
10
- "MyAwesomePlugin",
11
- partner_id: "partner_1234",
12
- url: "https://myawesomeplugin.info",
13
- version: "1.2.34"
14
- )
15
- assert_equal({
16
- name: "MyAwesomePlugin",
17
- partner_id: "partner_1234",
18
- url: "https://myawesomeplugin.info",
19
- version: "1.2.34",
20
- }, Telnyx.app_info)
21
- ensure
22
- Telnyx.app_info = old
23
- end
7
+ old = Telnyx.app_info
8
+ Telnyx.set_app_info(
9
+ "MyAwesomePlugin",
10
+ partner_id: "partner_1234",
11
+ url: "https://myawesomeplugin.info",
12
+ version: "1.2.34"
13
+ )
14
+ assert_equal({
15
+ name: "MyAwesomePlugin",
16
+ partner_id: "partner_1234",
17
+ url: "https://myawesomeplugin.info",
18
+ version: "1.2.34",
19
+ }, Telnyx.app_info)
20
+ ensure
21
+ Telnyx.app_info = old
24
22
  end
25
23
 
26
24
  should "allow max_network_retries to be configured" do
27
- begin
28
- old = Telnyx.max_network_retries
29
- Telnyx.max_network_retries = 99
30
- assert_equal 99, Telnyx.max_network_retries
31
- ensure
32
- Telnyx.max_network_retries = old
33
- end
25
+ old = Telnyx.max_network_retries
26
+ Telnyx.max_network_retries = 99
27
+ assert_equal 99, Telnyx.max_network_retries
28
+ ensure
29
+ Telnyx.max_network_retries = old
34
30
  end
35
31
 
36
32
  should "have default open and read timeouts" do
metadata CHANGED
@@ -1,22 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telnyx
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Telnyx
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-10 00:00:00.000000000 Z
11
+ date: 2021-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.13'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
20
23
  - - "!="
21
24
  - !ruby/object:Gem::Version
22
25
  version: 0.16.0
@@ -33,9 +36,12 @@ dependencies:
33
36
  prerelease: false
34
37
  version_requirements: !ruby/object:Gem::Requirement
35
38
  requirements:
36
- - - "~>"
39
+ - - ">="
37
40
  - !ruby/object:Gem::Version
38
41
  version: '0.13'
42
+ - - "<"
43
+ - !ruby/object:Gem::Version
44
+ version: '2.0'
39
45
  - - "!="
40
46
  - !ruby/object:Gem::Version
41
47
  version: 0.16.0
@@ -52,16 +58,22 @@ dependencies:
52
58
  name: net-http-persistent
53
59
  requirement: !ruby/object:Gem::Requirement
54
60
  requirements:
55
- - - "~>"
61
+ - - ">="
56
62
  - !ruby/object:Gem::Version
57
63
  version: '3.0'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '5.0'
58
67
  type: :runtime
59
68
  prerelease: false
60
69
  version_requirements: !ruby/object:Gem::Requirement
61
70
  requirements:
62
- - - "~>"
71
+ - - ">="
63
72
  - !ruby/object:Gem::Version
64
73
  version: '3.0'
74
+ - - "<"
75
+ - !ruby/object:Gem::Version
76
+ version: '5.0'
65
77
  - !ruby/object:Gem::Dependency
66
78
  name: ed25519
67
79
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +162,7 @@ files:
150
162
  - lib/telnyx/regulatory_requirement.rb
151
163
  - lib/telnyx/sim_card.rb
152
164
  - lib/telnyx/singleton_api_resource.rb
165
+ - lib/telnyx/telephony_credential.rb
153
166
  - lib/telnyx/telnyx_client.rb
154
167
  - lib/telnyx/telnyx_object.rb
155
168
  - lib/telnyx/telnyx_response.rb
@@ -194,6 +207,7 @@ files:
194
207
  - test/telnyx/public_key_test.rb
195
208
  - test/telnyx/regulatory_requirement_test.rb
196
209
  - test/telnyx/sim_card_test.rb
210
+ - test/telnyx/telephony_credential_test.rb
197
211
  - test/telnyx/telnyx_client_test.rb
198
212
  - test/telnyx/telnyx_object_test.rb
199
213
  - test/telnyx/telnyx_response_test.rb
@@ -229,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
243
  - !ruby/object:Gem::Version
230
244
  version: '0'
231
245
  requirements: []
232
- rubygems_version: 3.1.4
246
+ rubygems_version: 3.2.15
233
247
  signing_key:
234
248
  specification_version: 4
235
249
  summary: Ruby bindings for the Telnyx API
@@ -268,6 +282,7 @@ test_files:
268
282
  - test/telnyx/public_key_test.rb
269
283
  - test/telnyx/regulatory_requirement_test.rb
270
284
  - test/telnyx/sim_card_test.rb
285
+ - test/telnyx/telephony_credential_test.rb
271
286
  - test/telnyx/telnyx_client_test.rb
272
287
  - test/telnyx/telnyx_object_test.rb
273
288
  - test/telnyx/telnyx_response_test.rb