telnyx 2.6.0 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -1
  3. data/.rubocop.yml +1 -1
  4. data/Gemfile +4 -0
  5. data/VERSION +1 -1
  6. data/lib/telnyx/api_operations/create.rb +6 -1
  7. data/lib/telnyx/api_resource.rb +10 -0
  8. data/lib/telnyx/call.rb +1 -1
  9. data/lib/telnyx/messaging_phone_number.rb +0 -5
  10. data/lib/telnyx/phone_number.rb +2 -2
  11. data/lib/telnyx/util.rb +11 -39
  12. data/lib/telnyx/verification.rb +9 -0
  13. data/lib/telnyx/version.rb +1 -1
  14. data/test/telnyx/alphanumeric_sender_id_test.rb +1 -1
  15. data/test/telnyx/api_operations_test.rb +1 -1
  16. data/test/telnyx/api_resource_test.rb +1 -1
  17. data/test/telnyx/available_phone_number_test.rb +1 -1
  18. data/test/telnyx/call_control_test.rb +10 -31
  19. data/test/telnyx/conference_test.rb +1 -1
  20. data/test/telnyx/errors_test.rb +1 -1
  21. data/test/telnyx/fax_test.rb +1 -0
  22. data/test/telnyx/list_object_test.rb +1 -1
  23. data/test/telnyx/message_test.rb +1 -1
  24. data/test/telnyx/messaging_phone_number_test.rb +1 -1
  25. data/test/telnyx/messaging_profile_test.rb +1 -1
  26. data/test/telnyx/number_reservation_test.rb +2 -0
  27. data/test/telnyx/public_key_test.rb +1 -1
  28. data/test/telnyx/telnyx_client_test.rb +43 -49
  29. data/test/telnyx/telnyx_object_test.rb +12 -14
  30. data/test/telnyx/telnyx_response_test.rb +1 -1
  31. data/test/telnyx/util_test.rb +1 -1
  32. data/test/telnyx/verification_test.rb +4 -2
  33. data/test/telnyx/verify_profile_test.rb +2 -0
  34. data/test/telnyx/webhook_test.rb +1 -1
  35. data/test/telnyx/wireless_detail_records_report_test.rb +1 -0
  36. data/test/telnyx_test.rb +20 -24
  37. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00452326e11b54124b37dcbc7cd26c1d51b8daa45b53c4501f9eb3800c435271
4
- data.tar.gz: 122b158e03abf97ce731b9d2f6383005ecd335df0bd694f0b7ddfd98a0e49536
3
+ metadata.gz: 407a5714f7cb3d239c29e30db367cb2ce79529bd6c56d2cc618fae5a2d53445a
4
+ data.tar.gz: ca77fece83a957351b70886ec4e7df72c202c9a362e2c5210b2b8472f31dfc07
5
5
  SHA512:
6
- metadata.gz: f29626937689eba4d2f1f979065880228fb803dfaf584bb391e4a3d3ec84ac120f346c4d1a8f3ff615214cddccf514e75acf9e0b2d49ccb46b9a6b0683ad8c89
7
- data.tar.gz: 448228b59dc6587a87c65c168d20a9f7bf62996b028d645ef1fc45b53671bbefd02f159ceb8cf5b4da21c2a738d8628a9c372cdd09bc01c23f0859fd0f7c4850
6
+ metadata.gz: 5d3011d6cf70a2445963ebfde957ba1d6868ae8552990e483deea284d534bd7040162bddd059aa29369ca2813768f721eceed5dd8eb39512c322198d4d55b98f
7
+ data.tar.gz: c736dcdf467ea9a6ff49856d1fa2d3acdb0e11bde5e4d700c810d39abde29586c2b596b17cf51eab5ceb2fd07d4cc727fbc0dcf283a40ef8bc9f637627aa9854
@@ -16,7 +16,7 @@ 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:
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
@@ -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.6.0
1
+ 2.7.0
@@ -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
@@ -35,7 +35,7 @@ module Telnyx
35
35
  gather_using_audio gather_using_speak playback_start
36
36
  playback_stop record_start record_stop send_dtmf transfer
37
37
  transcription_start transcription_stop record_pause
38
- record_resume gather_stop refer].freeze
38
+ record_resume gather_stop refer enqueue leave_queue].freeze
39
39
 
40
40
  ACTIONS.each do |action|
41
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
data/lib/telnyx/util.rb CHANGED
@@ -37,45 +37,17 @@ 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
+ "messaging_settings" => MessagingPhoneNumber,
46
+ "phone_number_regulatory_group" => PhoneNumberRegulatoryRequirement,
47
+ "phone_number_reservation" => NumberReservation,
48
+ "verification_profile" => VerifyProfile,
49
+ "verification" => Verification::Response
50
+ )
79
51
  end
80
52
 
81
53
  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,11 @@ 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
+
24
33
  OBJECT_NAME = "verify_verification".freeze
25
34
  RESOURCE_PATH = "verifications".freeze
26
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Telnyx
4
- VERSION = "2.6.0".freeze
4
+ VERSION = "2.7.0".freeze
5
5
  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 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,37 +64,6 @@ 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_action_url(@call, "reject")
71
- @call.answer
72
- assert_requested :post, format_action_url(@call, "answer")
73
- @call.hangup
74
- assert_requested :post, format_action_url(@call, "hangup")
75
- @call.bridge call_control_id: SecureRandom.base64(20)
76
- assert_requested :post, format_action_url(@call, "bridge")
77
- @call.speak language: "en-US", voice: "female", payload: "Telnyx call control test"
78
- assert_requested :post, format_action_url(@call, "speak")
79
- @call.fork_start call_control_id: SecureRandom.base64(20)
80
- assert_requested :post, format_action_url(@call, "fork_start")
81
- @call.fork_stop
82
- assert_requested :post, format_action_url(@call, "fork_stop")
83
- @call.gather_using_audio audio_url: "https://audio.example.com"
84
- assert_requested :post, format_action_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_action_url(@call, "gather_using_speak")
87
- @call.playback_start audio_url: "https://audio.example.com"
88
- assert_requested :post, format_action_url(@call, "playback_start")
89
- @call.playback_stop
90
- assert_requested :post, format_action_url(@call, "playback_stop")
91
- @call.send_dtmf digits: "1www2WABCDw9"
92
- assert_requested :post, format_action_url(@call, "send_dtmf")
93
- @call.transfer to: "+15552223333"
94
- assert_requested :post, format_action_url(@call, "transfer")
95
- end
96
67
  end
97
68
 
98
69
  context "commands" do
@@ -172,6 +143,14 @@ module Telnyx
172
143
  @call.refer sip_address: "sip:username@sip.non-telnyx-address.com"
173
144
  assert_requested :post, format_action_url(@call, "refer")
174
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")
153
+ end
175
154
  end
176
155
 
177
156
  def create_call
@@ -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
@@ -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
@@ -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,12 @@
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
7
  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"
8
+ Verification.call phone_number: "+15555555555", twofa_profile_id: "1234", type: "sms", verify_profile_id: "foobar"
9
+ assert_requested :post, "#{Telnyx.api_base}/v2/verifications/call"
8
10
  end
9
11
 
10
12
  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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telnyx
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.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-04-08 00:00:00.000000000 Z
11
+ date: 2021-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday