telnyx 0.0.8 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.github/scripts/before_install.sh +9 -0
  3. data/.github/workflows/ruby.yml +39 -0
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +6 -36
  6. data/.rubocop_todo.yml +300 -0
  7. data/.travis.yml.bak +48 -0
  8. data/Gemfile +6 -5
  9. data/README.md +42 -3
  10. data/VERSION +1 -1
  11. data/bin/telnyx-console +7 -1
  12. data/examples/2 factor authentication/Gemfile +7 -0
  13. data/examples/2 factor authentication/main.rb +67 -0
  14. data/examples/2 factor authentication/readme.md +5 -0
  15. data/examples/fax/Gemfile +7 -0
  16. data/examples/fax/config.yaml +4 -0
  17. data/examples/fax/fax.rb +42 -0
  18. data/examples/fax/options.rb +41 -0
  19. data/examples/fax/readme.md +18 -0
  20. data/lib/telnyx.rb +22 -2
  21. data/lib/telnyx/address.rb +12 -0
  22. data/lib/telnyx/api_operations/list.rb +1 -1
  23. data/lib/telnyx/api_operations/nested_resource.rb +2 -2
  24. data/lib/telnyx/api_operations/save.rb +1 -1
  25. data/lib/telnyx/api_resource.rb +13 -2
  26. data/lib/telnyx/billing_group.rb +12 -0
  27. data/lib/telnyx/call.rb +3 -1
  28. data/lib/telnyx/call_control_application.rb +12 -0
  29. data/lib/telnyx/conference.rb +36 -0
  30. data/lib/telnyx/connection.rb +9 -0
  31. data/lib/telnyx/credential_connection.rb +12 -0
  32. data/lib/telnyx/fax.rb +13 -0
  33. data/lib/telnyx/fax_application.rb +12 -0
  34. data/lib/telnyx/fqdn.rb +12 -0
  35. data/lib/telnyx/fqdn_connection.rb +12 -0
  36. data/lib/telnyx/ip.rb +12 -0
  37. data/lib/telnyx/ip_connection.rb +12 -0
  38. data/lib/telnyx/list_object.rb +30 -44
  39. data/lib/telnyx/messaging_phone_number.rb +9 -0
  40. data/lib/telnyx/number_lookup.rb +7 -0
  41. data/lib/telnyx/number_order_document.rb +11 -0
  42. data/lib/telnyx/outbound_voice_profile.rb +12 -0
  43. data/lib/telnyx/phone_number.rb +20 -1
  44. data/lib/telnyx/phone_number_regulatory_requirement.rb +10 -0
  45. data/lib/telnyx/portout.rb +12 -0
  46. data/lib/telnyx/regulatory_requirement.rb +9 -0
  47. data/lib/telnyx/sim_card.rb +12 -1
  48. data/lib/telnyx/telnyx_client.rb +17 -26
  49. data/lib/telnyx/util.rb +38 -14
  50. data/lib/telnyx/verification.rb +27 -0
  51. data/lib/telnyx/verify_profile.rb +11 -0
  52. data/lib/telnyx/version.rb +1 -1
  53. data/lib/telnyx/wireless_detail_records_report.rb +12 -0
  54. data/telnyx.gemspec +1 -1
  55. data/test/telnyx/address_test.rb +67 -0
  56. data/test/telnyx/alphanumeric_sender_id_test.rb +4 -0
  57. data/test/telnyx/api_resource_test.rb +14 -5
  58. data/test/telnyx/billing_group_test.rb +40 -0
  59. data/test/telnyx/call_control_application_test.rb +42 -0
  60. data/test/telnyx/call_control_test.rb +54 -30
  61. data/test/telnyx/conference_test.rb +113 -0
  62. data/test/telnyx/connection_test.rb +28 -0
  63. data/test/telnyx/credential_connection_test.rb +44 -0
  64. data/test/telnyx/errors_test.rb +4 -4
  65. data/test/telnyx/fax_application_test.rb +32 -0
  66. data/test/telnyx/fax_test.rb +32 -0
  67. data/test/telnyx/fqdn_connection_test.rb +40 -0
  68. data/test/telnyx/fqdn_test.rb +40 -0
  69. data/test/telnyx/ip_connection_test.rb +40 -0
  70. data/test/telnyx/ip_test.rb +40 -0
  71. data/test/telnyx/list_object_test.rb +48 -90
  72. data/test/telnyx/messaging_phone_number_test.rb +8 -4
  73. data/test/telnyx/messaging_profile_test.rb +16 -5
  74. data/test/telnyx/number_lookup_test.rb +18 -0
  75. data/test/telnyx/number_order_document_test.rb +35 -0
  76. data/test/telnyx/outbound_voice_profile_test.rb +67 -0
  77. data/test/telnyx/phone_number_regulatory_requirement_test.rb +14 -0
  78. data/test/telnyx/phone_number_test.rb +40 -9
  79. data/test/telnyx/public_key_test.rb +1 -0
  80. data/test/telnyx/regulatory_requirement_test.rb +21 -0
  81. data/test/telnyx/sim_card_test.rb +6 -18
  82. data/test/telnyx/telnyx_client_test.rb +1 -1
  83. data/test/telnyx/telnyx_object_test.rb +5 -5
  84. data/test/telnyx/verification_test.rb +22 -0
  85. data/test/telnyx/verify_profile_test.rb +31 -0
  86. data/test/telnyx/wireless_detail_records_report_test.rb +57 -0
  87. data/test/test_helper.rb +1 -1
  88. metadata +93 -12
  89. data/.travis.yml +0 -51
  90. data/lib/telnyx/conferences.rb +0 -19
  91. data/test/telnyx/conferences_test.rb +0 -76
@@ -6,14 +6,16 @@ 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
@@ -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
- messaging_profile.name = "value"
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 updateable" do
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
 
@@ -48,10 +58,11 @@ module Telnyx
48
58
  phone_numbers = messaging_profile.phone_numbers
49
59
  assert_requested :get, "#{Telnyx.api_base}/v2/messaging_profiles/123/phone_numbers"
50
60
  assert phone_numbers.data.is_a?(Array)
51
- assert phone_numbers.data[0].is_a?(Telnyx::MessagingPhoneNumber)
61
+ assert_kind_of Telnyx::MessagingPhoneNumber, phone_numbers.data[0]
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_numbers_regulatory_requirements"
11
+ assert_kind_of PhoneNumberRegulatoryRequirement, phone_number_reg_req.first
12
+ end
13
+ end
14
+ end
@@ -41,6 +41,11 @@ module Telnyx
41
41
  assert_requested stub
42
42
  end
43
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
+
44
49
  context "nested commands" do
45
50
  should "update voice" do
46
51
  stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123")
@@ -64,24 +69,50 @@ module Telnyx
64
69
  assert_equal voice.data.connection_id, "456"
65
70
  end
66
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
+
67
78
  should "get messaging" do
68
- stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123")
69
- .to_return(body: JSON.generate(data: mock_response("123")))
70
- command_stub = stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123/messaging")
71
- .to_return(body: JSON.generate(data: mock_messaging_response("456")))
72
79
  phone_number = Telnyx::PhoneNumber.retrieve("123")
73
80
  phone_number.messaging
74
- assert_requested command_stub
81
+ assert_requested :get, "#{Telnyx.api_base}/v2/phone_numbers/123/messaging"
75
82
  end
76
83
 
77
84
  should "update messaging" do
85
+ phone_number = Telnyx::PhoneNumber.retrieve("123")
86
+ phone_number.update_messaging(messaging_profile_id: "12345", messaging_product: "P2P")
87
+ assert_requested :patch, "#{Telnyx.api_base}/v2/phone_numbers/123/messaging"
88
+ end
89
+
90
+ should "list inbound channels" do
91
+ phone_number = Telnyx::PhoneNumber.retrieve("123")
92
+ inbound_channels = phone_number.inbound_channels
93
+ assert_equal inbound_channels, 7
94
+ assert_requested :get, "#{Telnyx.api_base}/v2/phone_numbers/inbound_channels"
95
+ end
96
+
97
+ should "update inbound channel" do
78
98
  stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/123")
79
99
  .to_return(body: JSON.generate(data: mock_response("123")))
80
- command_stub = stub_request(:patch, "#{Telnyx.api_base}/v2/phone_numbers/123/messaging")
81
- .with(body: { messaging_profile_id: "12345", messaging_product: "P2P" })
82
- .to_return(body: JSON.generate(data: mock_messaging_response))
100
+ stub_request(:get, "#{Telnyx.api_base}/v2/phone_numbers/inbound_channels")
101
+ .to_return(body: JSON.generate(
102
+ data: {
103
+ channels: 7,
104
+ record_type: "inbound_channels",
105
+ }
106
+ ))
107
+ command_stub = stub_request(:patch, "#{Telnyx.api_base}/v2/phone_numbers/inbound_channels")
108
+ .to_return(body: JSON.generate(
109
+ data: {
110
+ channels: 7,
111
+ record_type: "inbound_channels",
112
+ }
113
+ ))
83
114
  phone_number = Telnyx::PhoneNumber.retrieve("123")
84
- phone_number.update_messaging(messaging_profile_id: "12345", messaging_product: "P2P")
115
+ phone_number.update_inbound_channels = 3
85
116
  assert_requested command_stub
86
117
  end
87
118
  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
@@ -28,28 +28,16 @@ module Telnyx
28
28
  end
29
29
 
30
30
  context "actions" do
31
- should "deactivate" do
32
- stub_request(:get, "#{Telnyx.api_base}/v2/sim_cards/123")
33
- .to_return(body: JSON.generate(data: { record_type: "sim_card", id: "123" }))
34
-
35
- stub = stub_request(:post, "#{Telnyx.api_base}/v2/sim_cards/123/actions/deactivate")
36
- .to_return(body: JSON.generate(errors: []), status: 202)
37
-
31
+ should "disable" do
38
32
  sim = Telnyx::SimCard.retrieve "123"
39
- sim.deactivate
40
- assert_requested stub
33
+ sim.disable
34
+ assert_requested(:post, "#{Telnyx.api_base}/v2/sim_cards/#{sim.id}/actions/disable")
41
35
  end
42
36
 
43
- should "activate" do
44
- stub_request(:get, "#{Telnyx.api_base}/v2/sim_cards/123")
45
- .to_return(body: JSON.generate(data: { record_type: "sim_card", id: "123" }))
46
-
47
- stub = stub_request(:post, "#{Telnyx.api_base}/v2/sim_cards/123/actions/activate")
48
- .to_return(body: JSON.generate(errors: []), status: 202)
49
-
37
+ should "enable" do
50
38
  sim = Telnyx::SimCard.retrieve "123"
51
- sim.activate
52
- assert_requested stub
39
+ sim.enable
40
+ assert_requested(:post, "#{Telnyx.api_base}/v2/sim_cards/#{sim.id}/actions/enable")
53
41
  end
54
42
  end
55
43
  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
@@ -212,26 +212,26 @@ module Telnyx
212
212
 
213
213
  should "mass assign values with #update_attributes" do
214
214
  obj = Telnyx::TelnyxObject.construct_from(id: 1, name: "Telnyx")
215
- obj.update_attributes(name: "telnyx")
215
+ obj.update_attributes({ name: "telnyx" })
216
216
  assert_equal "telnyx", obj.name
217
217
 
218
218
  # unfortunately, we even assign unknown properties to duplicate the
219
219
  # behavior that we currently have via magic accessors with
220
220
  # method_missing
221
- obj.update_attributes(unknown: "foo")
221
+ obj.update_attributes({ unknown: "foo" })
222
222
  assert_equal "foo", obj.unknown
223
223
  end
224
224
 
225
225
  should "#update_attributes with a hash" do
226
226
  obj = Telnyx::TelnyxObject.construct_from({})
227
- obj.update_attributes(metadata: { foo: "bar" })
227
+ obj.update_attributes({ metadata: { foo: "bar" } })
228
228
  assert_equal Telnyx::TelnyxObject, obj.metadata.class
229
229
  end
230
230
 
231
231
  should "create accessors when #update_attributes is called" do
232
232
  obj = Telnyx::TelnyxObject.construct_from({})
233
233
  assert_equal false, obj.send(:metaclass).method_defined?(:foo)
234
- obj.update_attributes(foo: "bar")
234
+ obj.update_attributes({ foo: "bar" })
235
235
  assert_equal true, obj.send(:metaclass).method_defined?(:foo)
236
236
  end
237
237
 
@@ -268,7 +268,7 @@ module Telnyx
268
268
 
269
269
  should "#serialize_params on a basic object" do
270
270
  obj = Telnyx::TelnyxObject.construct_from(foo: nil)
271
- obj.update_attributes(foo: "bar")
271
+ obj.update_attributes({ foo: "bar" })
272
272
  assert_equal({ foo: "bar" }, obj.serialize_params)
273
273
  end
274
274
 
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telnyx
4
+ 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"
8
+ end
9
+
10
+ should "retrieve verification" do
11
+ verification = Verification.retrieve("id")
12
+ assert_requested :get, "#{Telnyx.api_base}/v2/verifications/id"
13
+ assert_kind_of Verification, verification
14
+ end
15
+
16
+ should "send verification code" do
17
+ Verification.submit_code code: "12345", phone_number: "+13035551234"
18
+
19
+ assert_requested :post, "#{Telnyx.api_base}/v2/verifications/by_phone_number/+13035551234/actions/verify"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telnyx
4
+ class VerifyProfileTest < Test::Unit::TestCase
5
+ should "list verify_profiles" do
6
+ verify_profile = VerifyProfile.list
7
+ assert_requested :get, "#{Telnyx.api_base}/v2/verify_profiles"
8
+ assert_kind_of ListObject, verify_profile
9
+ assert_kind_of VerifyProfile, verify_profile.first
10
+ end
11
+
12
+ should "create verify_profile" do
13
+ VerifyProfile.create name: "test"
14
+ assert_requested :post, "#{Telnyx.api_base}/v2/verify_profiles"
15
+ end
16
+
17
+ should "retrieve verify_profile" do
18
+ verify_profile = VerifyProfile.retrieve("id")
19
+ assert_requested :get, "#{Telnyx.api_base}/v2/verify_profiles/id"
20
+ assert_kind_of VerifyProfile, verify_profile
21
+ end
22
+
23
+ should "update verify_profile" do
24
+ verify_profile = VerifyProfile.retrieve("id")
25
+
26
+ verify_profile.name = "123"
27
+ verify_profile.save
28
+ assert_requested :patch, "#{Telnyx.api_base}/v2/verify_profiles/#{verify_profile.id}"
29
+ end
30
+ end
31
+ end