telnyx 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) 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/.rubocop.yml +6 -36
  5. data/.rubocop_todo.yml +300 -0
  6. data/.travis.yml.bak +48 -0
  7. data/Gemfile +6 -6
  8. data/README.md +1 -1
  9. data/VERSION +1 -1
  10. data/bin/telnyx-console +5 -0
  11. data/examples/2 factor authentication/Gemfile +7 -0
  12. data/examples/2 factor authentication/main.rb +67 -0
  13. data/examples/2 factor authentication/readme.md +5 -0
  14. data/examples/fax/Gemfile +7 -0
  15. data/examples/fax/config.yaml +4 -0
  16. data/examples/fax/fax.rb +42 -0
  17. data/examples/fax/options.rb +41 -0
  18. data/examples/fax/readme.md +18 -0
  19. data/lib/telnyx.rb +5 -1
  20. data/lib/telnyx/api_operations/save.rb +1 -1
  21. data/lib/telnyx/api_resource.rb +14 -3
  22. data/lib/telnyx/conference.rb +17 -1
  23. data/lib/telnyx/fax.rb +13 -0
  24. data/lib/telnyx/fax_application.rb +12 -0
  25. data/lib/telnyx/messaging_phone_number.rb +9 -0
  26. data/lib/telnyx/phone_number.rb +5 -1
  27. data/lib/telnyx/sim_card.rb +12 -1
  28. data/lib/telnyx/telnyx_client.rb +15 -24
  29. data/lib/telnyx/util.rb +7 -1
  30. data/lib/telnyx/verification.rb +27 -0
  31. data/lib/telnyx/verify_profile.rb +11 -0
  32. data/lib/telnyx/version.rb +1 -1
  33. data/telnyx.gemspec +1 -1
  34. data/test/telnyx/call_control_test.rb +3 -3
  35. data/test/telnyx/conference_test.rb +57 -20
  36. data/test/telnyx/credential_connection_test.rb +5 -1
  37. data/test/telnyx/fax_application_test.rb +32 -0
  38. data/test/telnyx/fax_test.rb +32 -0
  39. data/test/telnyx/fqdn_connection_test.rb +1 -1
  40. data/test/telnyx/fqdn_test.rb +1 -1
  41. data/test/telnyx/messaging_phone_number_test.rb +8 -4
  42. data/test/telnyx/messaging_profile_test.rb +1 -1
  43. data/test/telnyx/phone_number_test.rb +9 -21
  44. data/test/telnyx/sim_card_test.rb +6 -6
  45. data/test/telnyx/telnyx_object_test.rb +5 -5
  46. data/test/telnyx/verification_test.rb +22 -0
  47. data/test/telnyx/verify_profile_test.rb +31 -0
  48. data/test/test_helper.rb +1 -1
  49. metadata +36 -7
  50. data/.travis.yml +0 -51
@@ -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 command_stub
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 command_stub
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 command_stub
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 "deactivate" do
31
+ should "disable" do
32
32
  sim = Telnyx::SimCard.retrieve "123"
33
- sim.deactivate
34
- assert_requested(:post, "#{Telnyx.api_base}/v2/sim_cards/#{sim.id}/actions/deactivate")
33
+ sim.disable
34
+ assert_requested(:post, "#{Telnyx.api_base}/v2/sim_cards/#{sim.id}/actions/disable")
35
35
  end
36
36
 
37
- should "activate" do
37
+ should "enable" do
38
38
  sim = Telnyx::SimCard.retrieve "123"
39
- sim.activate
40
- assert_requested(:post, "#{Telnyx.api_base}/v2/sim_cards/#{sim.id}/actions/activate")
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
@@ -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
data/test/test_helper.rb CHANGED
@@ -17,7 +17,7 @@ require ::File.expand_path("../test_data", __FILE__)
17
17
  require ::File.expand_path("../telnyx_mock", __FILE__)
18
18
 
19
19
  # If changing this number, please also change it in `.travis.yml`.
20
- MOCK_MINIMUM_VERSION = "0.8.9".freeze
20
+ MOCK_MINIMUM_VERSION = "0.8.10".freeze
21
21
  MOCK_PORT = Telnyx::TelnyxMock.start
22
22
 
23
23
  # Disable all real network connections except those that are outgoing to
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.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Telnyx
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-16 00:00:00.000000000 Z
11
+ date: 2021-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -26,6 +26,9 @@ dependencies:
26
26
  - - "!="
27
27
  - !ruby/object:Gem::Version
28
28
  version: 0.16.2
29
+ - - "!="
30
+ - !ruby/object:Gem::Version
31
+ version: 0.17.1
29
32
  type: :runtime
30
33
  prerelease: false
31
34
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,6 +45,9 @@ dependencies:
42
45
  - - "!="
43
46
  - !ruby/object:Gem::Version
44
47
  version: 0.16.2
48
+ - - "!="
49
+ - !ruby/object:Gem::Version
50
+ version: 0.17.1
45
51
  - !ruby/object:Gem::Dependency
46
52
  name: net-http-persistent
47
53
  requirement: !ruby/object:Gem::Requirement
@@ -79,9 +85,12 @@ extensions: []
79
85
  extra_rdoc_files: []
80
86
  files:
81
87
  - ".github/ISSUE_TEMPLATE.md"
88
+ - ".github/scripts/before_install.sh"
89
+ - ".github/workflows/ruby.yml"
82
90
  - ".gitignore"
83
91
  - ".rubocop.yml"
84
- - ".travis.yml"
92
+ - ".rubocop_todo.yml"
93
+ - ".travis.yml.bak"
85
94
  - CHANGELOG.md
86
95
  - CONTRIBUTORS
87
96
  - Gemfile
@@ -91,6 +100,14 @@ files:
91
100
  - Rakefile
92
101
  - VERSION
93
102
  - bin/telnyx-console
103
+ - examples/2 factor authentication/Gemfile
104
+ - examples/2 factor authentication/main.rb
105
+ - examples/2 factor authentication/readme.md
106
+ - examples/fax/Gemfile
107
+ - examples/fax/config.yaml
108
+ - examples/fax/fax.rb
109
+ - examples/fax/options.rb
110
+ - examples/fax/readme.md
94
111
  - lib/telnyx.rb
95
112
  - lib/telnyx/address.rb
96
113
  - lib/telnyx/alphanumeric_sender_id.rb
@@ -111,6 +128,8 @@ files:
111
128
  - lib/telnyx/credential_connection.rb
112
129
  - lib/telnyx/errors.rb
113
130
  - lib/telnyx/event.rb
131
+ - lib/telnyx/fax.rb
132
+ - lib/telnyx/fax_application.rb
114
133
  - lib/telnyx/fqdn.rb
115
134
  - lib/telnyx/fqdn_connection.rb
116
135
  - lib/telnyx/ip.rb
@@ -135,6 +154,8 @@ files:
135
154
  - lib/telnyx/telnyx_object.rb
136
155
  - lib/telnyx/telnyx_response.rb
137
156
  - lib/telnyx/util.rb
157
+ - lib/telnyx/verification.rb
158
+ - lib/telnyx/verify_profile.rb
138
159
  - lib/telnyx/version.rb
139
160
  - lib/telnyx/webhook.rb
140
161
  - lib/telnyx/wireless_detail_records_report.rb
@@ -153,6 +174,8 @@ files:
153
174
  - test/telnyx/connection_test.rb
154
175
  - test/telnyx/credential_connection_test.rb
155
176
  - test/telnyx/errors_test.rb
177
+ - test/telnyx/fax_application_test.rb
178
+ - test/telnyx/fax_test.rb
156
179
  - test/telnyx/fqdn_connection_test.rb
157
180
  - test/telnyx/fqdn_test.rb
158
181
  - test/telnyx/ip_connection_test.rb
@@ -175,6 +198,8 @@ files:
175
198
  - test/telnyx/telnyx_object_test.rb
176
199
  - test/telnyx/telnyx_response_test.rb
177
200
  - test/telnyx/util_test.rb
201
+ - test/telnyx/verification_test.rb
202
+ - test/telnyx/verify_profile_test.rb
178
203
  - test/telnyx/webhook_test.rb
179
204
  - test/telnyx/wireless_detail_records_report_test.rb
180
205
  - test/telnyx_mock.rb
@@ -189,7 +214,7 @@ metadata:
189
214
  github_repo: ssh://github.com/team-telnyx/telnyx-ruby
190
215
  homepage_uri: https://telnyx.com
191
216
  source_code_uri: https://github.com/team-telnyx/telnyx-ruby
192
- post_install_message:
217
+ post_install_message:
193
218
  rdoc_options: []
194
219
  require_paths:
195
220
  - lib
@@ -204,8 +229,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
229
  - !ruby/object:Gem::Version
205
230
  version: '0'
206
231
  requirements: []
207
- rubygems_version: 3.1.2
208
- signing_key:
232
+ rubygems_version: 3.1.4
233
+ signing_key:
209
234
  specification_version: 4
210
235
  summary: Ruby bindings for the Telnyx API
211
236
  test_files:
@@ -223,6 +248,8 @@ test_files:
223
248
  - test/telnyx/connection_test.rb
224
249
  - test/telnyx/credential_connection_test.rb
225
250
  - test/telnyx/errors_test.rb
251
+ - test/telnyx/fax_application_test.rb
252
+ - test/telnyx/fax_test.rb
226
253
  - test/telnyx/fqdn_connection_test.rb
227
254
  - test/telnyx/fqdn_test.rb
228
255
  - test/telnyx/ip_connection_test.rb
@@ -245,6 +272,8 @@ test_files:
245
272
  - test/telnyx/telnyx_object_test.rb
246
273
  - test/telnyx/telnyx_response_test.rb
247
274
  - test/telnyx/util_test.rb
275
+ - test/telnyx/verification_test.rb
276
+ - test/telnyx/verify_profile_test.rb
248
277
  - test/telnyx/webhook_test.rb
249
278
  - test/telnyx/wireless_detail_records_report_test.rb
250
279
  - test/telnyx_mock.rb
data/.travis.yml DELETED
@@ -1,51 +0,0 @@
1
- language: ruby
2
-
3
-
4
- rvm:
5
- - 2.1
6
- - 2.2
7
- - 2.3
8
- - 2.4
9
- - 2.5
10
- - 2.6
11
-
12
- matrix:
13
- include:
14
- - rvm: jruby-9.2.11.0
15
- jdk: oraclejdk11
16
-
17
-
18
- notifications:
19
- email:
20
- on_success: never
21
- slack:
22
- secure: AMXcZSwIL8SRZQ+opSFrlvNKoUXv1rZkWDgorBmz+BEHwGKWgVzYcZ4GwD5p6Z5uNdtvl9FZz6oLvvAcbW6CblbAPM+f2qLVDlZ/sazpOK8l6QIo7X86U3SuwJicY2CbbKvqN/A3u23Bbvf5u4djvm5oc73qASZY/RJHxm2xcmD57+z6hY12AvWtLJN95BsjVZ9RHXy8/qkJehqGnzSi9VGojNmd0voU9UrxJU0xS10kBA7dQFCCf+NZv9utguyFfAATpa9JTlD1a8QiB2fzvdPkBym1bnqr3nQPk5rNbgiFHf14OIlq7C2jwaNNoB1dDpkT/Vfvmn5EHzBDZQ30PrVpq9uNgQg45pOIMXp9ZLY0zYi/Gzk5tF/lTKUxk5evJ2+2Dtmzv4mzbk98pvGrA+MIkSXuYy6GHZuXanb3OQ5y42dSYVdy1c+WHdbYx1LOJSEGtALr9ADyjDu9KAu2eJMnmGQ14cJarl/33BF4UzCRKpPxV5CwOqI82+fK9pNiW0CLijfxpkFr9aaxViVsf43r5Ag12Jqme18IWCGJ1P5sMEo6bz/Gp4BuVMXQtYExorK+fWkrm1Wus6HGINlRonUswJ9LJ995M384j6KyP1121MJuiPAc1AdNqS1C992j/cDoUDlxsxW9HTX15nGoM712w00wNrj/vdQt0TlmENo=
23
-
24
- sudo: false
25
-
26
- env:
27
- global:
28
- # If changing this number, please also change it in `test/test_helper.rb`.
29
- - TELNYX_MOCK_VERSION=0.8.9
30
-
31
- cache:
32
- directories:
33
- - telnyx-mock
34
-
35
- before_install:
36
- # Install bundler 1.x, because we need to support Ruby 2.1 for now
37
- - gem install bundler -v "~> 1.0"
38
- # Unpack and start telnyx-mock so that the test suite can talk to it
39
- - |
40
- if [ ! -d "telnyx-mock/telnyx-mock_${TELNYX_MOCK_VERSION}" ]; then
41
- mkdir -p telnyx-mock/${TELNYX_MOCK_VERSION}/
42
- curl -L "https://github.com/team-telnyx/telnyx-mock/releases/download/v${TELNYX_MOCK_VERSION}/telnyx-mock_${TELNYX_MOCK_VERSION}_linux_amd64.tar.gz" -o "telnyx-mock/telnyx-mock_${TELNYX_MOCK_VERSION}_linux_amd64.tar.gz"
43
- tar -zxf "telnyx-mock/telnyx-mock_${TELNYX_MOCK_VERSION}_linux_amd64.tar.gz" -C "telnyx-mock/${TELNYX_MOCK_VERSION}/"
44
- fi
45
- - |
46
- telnyx-mock/${TELNYX_MOCK_VERSION}/telnyx-mock > /dev/null &
47
- TELNYX_MOCK_PID=$!
48
- - export PATH="${PATH}:${PWD}/telnyx-mock/${TELNYX_MOCK_VERSION}"
49
-
50
- script:
51
- - bundle exec rake