telnyx 0.0.7 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) 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 -5
  8. data/README.md +42 -3
  9. data/VERSION +1 -1
  10. data/bin/telnyx-console +7 -1
  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 +22 -2
  20. data/lib/telnyx/address.rb +12 -0
  21. data/lib/telnyx/api_operations/list.rb +1 -1
  22. data/lib/telnyx/api_operations/nested_resource.rb +2 -2
  23. data/lib/telnyx/api_operations/save.rb +1 -1
  24. data/lib/telnyx/api_resource.rb +13 -2
  25. data/lib/telnyx/billing_group.rb +12 -0
  26. data/lib/telnyx/call_control_application.rb +12 -0
  27. data/lib/telnyx/conference.rb +36 -0
  28. data/lib/telnyx/connection.rb +9 -0
  29. data/lib/telnyx/credential_connection.rb +12 -0
  30. data/lib/telnyx/fax.rb +13 -0
  31. data/lib/telnyx/fax_application.rb +12 -0
  32. data/lib/telnyx/fqdn.rb +12 -0
  33. data/lib/telnyx/fqdn_connection.rb +12 -0
  34. data/lib/telnyx/ip.rb +12 -0
  35. data/lib/telnyx/ip_connection.rb +12 -0
  36. data/lib/telnyx/list_object.rb +30 -44
  37. data/lib/telnyx/messaging_phone_number.rb +9 -0
  38. data/lib/telnyx/number_lookup.rb +7 -0
  39. data/lib/telnyx/number_order_document.rb +11 -0
  40. data/lib/telnyx/outbound_voice_profile.rb +12 -0
  41. data/lib/telnyx/phone_number.rb +20 -1
  42. data/lib/telnyx/phone_number_regulatory_requirement.rb +9 -0
  43. data/lib/telnyx/portout.rb +12 -0
  44. data/lib/telnyx/regulatory_requirement.rb +9 -0
  45. data/lib/telnyx/sim_card.rb +17 -1
  46. data/lib/telnyx/telnyx_client.rb +16 -25
  47. data/lib/telnyx/util.rb +38 -14
  48. data/lib/telnyx/verification.rb +27 -0
  49. data/lib/telnyx/verify_profile.rb +11 -0
  50. data/lib/telnyx/version.rb +1 -1
  51. data/lib/telnyx/wireless_detail_records_report.rb +12 -0
  52. data/telnyx.gemspec +1 -1
  53. data/test/telnyx/address_test.rb +67 -0
  54. data/test/telnyx/alphanumeric_sender_id_test.rb +4 -0
  55. data/test/telnyx/api_resource_test.rb +14 -5
  56. data/test/telnyx/billing_group_test.rb +40 -0
  57. data/test/telnyx/call_control_application_test.rb +42 -0
  58. data/test/telnyx/call_control_test.rb +3 -3
  59. data/test/telnyx/conference_test.rb +113 -0
  60. data/test/telnyx/connection_test.rb +28 -0
  61. data/test/telnyx/credential_connection_test.rb +44 -0
  62. data/test/telnyx/errors_test.rb +4 -4
  63. data/test/telnyx/fax_application_test.rb +32 -0
  64. data/test/telnyx/fax_test.rb +32 -0
  65. data/test/telnyx/fqdn_connection_test.rb +40 -0
  66. data/test/telnyx/fqdn_test.rb +40 -0
  67. data/test/telnyx/ip_connection_test.rb +40 -0
  68. data/test/telnyx/ip_test.rb +40 -0
  69. data/test/telnyx/list_object_test.rb +48 -90
  70. data/test/telnyx/messaging_phone_number_test.rb +8 -4
  71. data/test/telnyx/messaging_profile_test.rb +16 -5
  72. data/test/telnyx/number_lookup_test.rb +18 -0
  73. data/test/telnyx/number_order_document_test.rb +35 -0
  74. data/test/telnyx/outbound_voice_profile_test.rb +67 -0
  75. data/test/telnyx/phone_number_regulatory_requirement_test.rb +14 -0
  76. data/test/telnyx/phone_number_test.rb +40 -9
  77. data/test/telnyx/public_key_test.rb +1 -0
  78. data/test/telnyx/regulatory_requirement_test.rb +21 -0
  79. data/test/telnyx/sim_card_test.rb +14 -29
  80. data/test/telnyx/telnyx_client_test.rb +1 -1
  81. data/test/telnyx/telnyx_object_test.rb +5 -5
  82. data/test/telnyx/verification_test.rb +22 -0
  83. data/test/telnyx/verify_profile_test.rb +31 -0
  84. data/test/telnyx/wireless_detail_records_report_test.rb +57 -0
  85. data/test/test_helper.rb +1 -1
  86. metadata +85 -10
  87. data/.travis.yml +0 -51
  88. data/lib/telnyx/conferences.rb +0 -19
  89. data/test/telnyx/conferences_test.rb +0 -76
data/lib/telnyx/util.rb CHANGED
@@ -39,18 +39,42 @@ module Telnyx
39
39
  def self.object_classes
40
40
  @object_classes ||= {
41
41
  # business objects
42
- AlphanumericSenderId::OBJECT_NAME => AlphanumericSenderId,
43
- AvailablePhoneNumber::OBJECT_NAME => AvailablePhoneNumber,
44
- Call::OBJECT_NAME => Call,
45
- Conferences::OBJECT_NAME => Conferences,
46
- Message::OBJECT_NAME => Message,
47
- MessagingPhoneNumber::OBJECT_NAME => MessagingPhoneNumber,
48
- MessagingProfile::OBJECT_NAME => MessagingProfile,
49
- NumberOrder::OBJECT_NAME => NumberOrder,
50
- NumberReservation::OBJECT_NAME => NumberReservation,
51
- PublicKey::OBJECT_NAME => PublicKey,
52
- PhoneNumber::OBJECT_NAME => PhoneNumber,
53
- SimCard::OBJECT_NAME => SimCard,
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,
54
78
  }
55
79
  end
56
80
 
@@ -68,7 +92,7 @@ module Telnyx
68
92
  #
69
93
  # ==== Attributes
70
94
  #
71
- # * +data+ - Hash of fields and values to be converted into a TelnyxObject.
95
+ # * +Data+ - Hash of fields and values to be converted into a TelnyxObject.
72
96
  # * +opts+ - Options for +TelnyxObject+ like an API key that will be reused
73
97
  # on subsequent API calls.
74
98
  def self.convert_to_telnyx_object(data, opts = {})
@@ -79,7 +103,7 @@ module Telnyx
79
103
  # Try converting to a known object class. If none available, fall back to generic TelnyxObject
80
104
  if data[:data].is_a?(Array)
81
105
  ListObject.construct_from(data, opts)
82
- elsif data[:data] && data[:data][:record_type]
106
+ elsif data[:data].is_a?(Hash) && data[:data][:record_type]
83
107
  object_classes.fetch(data[:data][:record_type], TelnyxObject).construct_from(data[:data], opts)
84
108
  elsif data[:record_type]
85
109
  object_classes.fetch(data[:record_type], TelnyxObject).construct_from(data, opts)
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telnyx
4
+ class Verification < APIResource
5
+ # Type for verification responses
6
+ class Response < TelnyxObject; end
7
+
8
+ extend APIOperations::Create
9
+ extend APIOperations::NestedResource
10
+
11
+ nested_resource_class_methods "by_telephone",
12
+ path: "by_tn",
13
+ operations: [:retrieve],
14
+ instance_methods: {
15
+ retrieve: "by_telephone",
16
+ }
17
+
18
+ def self.submit_code(phone_number: nil, code: nil)
19
+ url = "#{resource_url}/by_phone_number/#{CGI.escape phone_number}/actions/verify"
20
+ resp, _opts = request(:post, url, code: code)
21
+ Response.construct_from resp.data[:data]
22
+ end
23
+
24
+ OBJECT_NAME = "verify_verification".freeze
25
+ RESOURCE_PATH = "verifications".freeze
26
+ end
27
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telnyx
4
+ class VerifyProfile < APIResource
5
+ extend APIOperations::List
6
+ extend APIOperations::Create
7
+ include APIOperations::Save
8
+
9
+ OBJECT_NAME = "verify_profile".freeze
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Telnyx
4
- VERSION = "0.0.7".freeze
4
+ VERSION = "2.4.0".freeze
5
5
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telnyx
4
+ class WirelessDetailRecordsReport < APIResource
5
+ include APIOperations::Delete
6
+ extend APIOperations::List
7
+ extend APIOperations::Create
8
+
9
+ OBJECT_NAME = "detail_records_report".freeze
10
+ RESOURCE_PATH = "wireless/detail_records_reports".freeze
11
+ end
12
+ end
data/telnyx.gemspec CHANGED
@@ -22,7 +22,7 @@ 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")
25
+ s.add_dependency("faraday", "~> 0.13", "!= 0.16.0", "!= 0.16.1", "!= 0.16.2", "!= 0.17.1")
26
26
  s.add_dependency("net-http-persistent", "~> 3.0")
27
27
  s.add_dependency("ed25519", "~> 1")
28
28
 
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../test_helper"
4
+
5
+ module Telnyx
6
+ class AddressTest < Test::Unit::TestCase
7
+ should "list addresses" do
8
+ stub = stub_request(:get, "#{Telnyx.api_base}/v2/addresses")
9
+ .to_return(body: JSON.generate(data: [FIXTURE]))
10
+ addresses = Address.list
11
+ # assert_requested :get, "#{Telnyx.api_base}/v2/addresses"
12
+ assert_requested stub
13
+ assert_kind_of ListObject, addresses
14
+ assert_kind_of Address, addresses.first
15
+ end
16
+
17
+ should "create address" do
18
+ stub = stub_request(:post, "#{Telnyx.api_base}/v2/addresses")
19
+ .to_return(body: JSON.generate(data: FIXTURE))
20
+ address = Address.create
21
+ # assert_requested :post, "#{Telnyx.api_base}/v2/addresses"
22
+ assert_requested stub
23
+ assert_kind_of Address, address
24
+ end
25
+
26
+ should "retrieve address" do
27
+ stub = stub_request(:get, "#{Telnyx.api_base}/v2/addresses/id")
28
+ .to_return(body: JSON.generate(data: FIXTURE))
29
+ address = Address.retrieve("id")
30
+ # assert_requested :get, "#{Telnyx.api_base}/v2/addresses/id"
31
+ assert_requested stub
32
+ assert_kind_of Address, address
33
+ end
34
+
35
+ should "delete address" do
36
+ stub_request(:get, "#{Telnyx.api_base}/v2/addresses/id")
37
+ .to_return(body: JSON.generate(data: FIXTURE))
38
+ stub = stub_request(:delete, "#{Telnyx.api_base}/v2/addresses/id")
39
+ .to_return(body: JSON.generate(data: FIXTURE))
40
+ address = Address.retrieve("id")
41
+
42
+ address.delete
43
+ # assert_requested :delete, "#{Telnyx.api_base}/v2/addresses/id"
44
+ assert_requested stub
45
+ end
46
+
47
+ FIXTURE = {
48
+ "address_book" => false,
49
+ "administrative_area" => "IL",
50
+ "borough" => "Guadalajara",
51
+ "business_name" => "Toy-O'Kon",
52
+ "country_code" => "us",
53
+ "created_at" => "2018-02-02T22:25:27.521Z",
54
+ "extended_address" => "Suite 123",
55
+ "first_name" => "Alfred",
56
+ "id" => "id",
57
+ "last_name" => "Foster",
58
+ "locality" => "Chicago",
59
+ "neighborhood" => "Ciudad de los deportes",
60
+ "phone_number" => "+12125559000",
61
+ "postal_code" => 2904,
62
+ "record_type" => "address",
63
+ "street_address" => "457 Flatley Stream",
64
+ "updated_at" => "2018-02-02T22:25:27.521Z",
65
+ }.freeze
66
+ end
67
+ end
@@ -4,6 +4,10 @@ require ::File.expand_path("../../test_helper", __FILE__)
4
4
 
5
5
  module Telnyx
6
6
  class AlphanumericSenderIdTest < Test::Unit::TestCase
7
+ setup do
8
+ omit "alphanumeric ids mock spec removed"
9
+ end
10
+
7
11
  should "be listable" do
8
12
  alphanumeric_sender_ids = Telnyx::AlphanumericSenderId.list
9
13
  assert_requested :get, "#{Telnyx.api_base}/v2/alphanumeric_sender_ids"
@@ -108,9 +108,12 @@ module Telnyx
108
108
 
109
109
  assert_requested(stub_get)
110
110
 
111
+ stub_get = stub_request(:post, "#{Telnyx.api_base}/v2/messaging_profiles")
112
+ .with(body: { "foo" => "bar" })
113
+ .to_return(body: JSON.generate(data: [messaging_profile_fixture]))
111
114
  Telnyx::MessagingProfile.create(name: nil, foo: "bar")
112
115
 
113
- assert_requested(:post, "#{Telnyx.api_base}/v2/messaging_profiles", body: { "foo" => "bar" })
116
+ assert_requested stub_get
114
117
  end
115
118
 
116
119
  should "requesting with a unicode ID should result in a request" do
@@ -155,19 +158,25 @@ module Telnyx
155
158
  end
156
159
 
157
160
  should "updating an object should issue a PATCH request with only the changed properties" do
158
- mp = Telnyx::MessagingProfile.construct_from(messaging_profile_fixture)
161
+ stub_patch = stub_request(:patch, "#{Telnyx.api_base}/v2/messaging_profiles/123")
162
+ .with(body: hash_including("name" => "new name"))
163
+ .to_return(body: JSON.generate(data: messaging_profile_fixture))
164
+ mp = Telnyx::MessagingProfile.retrieve("123")
159
165
  mp.name = "new name"
160
166
  mp.save
161
- assert_requested(:patch, "#{Telnyx.api_base}/v2/messaging_profiles/123", body: { "name" => "new name" })
167
+ assert_requested(stub_patch)
162
168
  end
163
169
 
164
170
  should "updating should merge in returned properties" do
171
+ stub_patch = stub_request(:patch, "#{Telnyx.api_base}/v2/messaging_profiles/123")
172
+ .with(body: hash_including("name" => "new name"))
173
+ .to_return(body: JSON.generate(data: messaging_profile_fixture))
165
174
  mp = Telnyx::MessagingProfile.new("123")
166
175
  mp.name = "new name"
167
176
  mp.save
168
177
 
169
- assert_requested(:patch, "#{Telnyx.api_base}/v2/messaging_profiles/123", body: { "name" => "new name" })
170
- assert mp.name == "new name"
178
+ assert_requested(stub_patch)
179
+ assert mp
171
180
  end
172
181
 
173
182
  should "updating should fail if api_key is overwritten with nil" do
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../test_helper"
4
+
5
+ module Telnyx
6
+ class BillingGroupTest < Test::Unit::TestCase
7
+ should "list billing groups" do
8
+ billing_groups = BillingGroup.list
9
+ assert_requested :get, "#{Telnyx.api_base}/v2/billing_groups"
10
+ assert_kind_of ListObject, billing_groups
11
+ assert_kind_of BillingGroup, billing_groups.first
12
+ end
13
+
14
+ should "create billing group" do
15
+ BillingGroup.create
16
+ assert_requested :post, "#{Telnyx.api_base}/v2/billing_groups"
17
+ end
18
+
19
+ should "retrieve billing group" do
20
+ billing_group = BillingGroup.retrieve("id")
21
+ assert_requested :get, "#{Telnyx.api_base}/v2/billing_groups/id"
22
+ assert_kind_of BillingGroup, billing_group
23
+ end
24
+
25
+ should "delete billing group" do
26
+ billing_group = BillingGroup.retrieve("id")
27
+
28
+ billing_group.delete
29
+ assert_requested :delete, "#{Telnyx.api_base}/v2/billing_groups/id"
30
+ end
31
+
32
+ should "update billing group" do
33
+ billing_group = BillingGroup.retrieve("id")
34
+
35
+ billing_group.active = false
36
+ billing_group.save
37
+ assert_requested :patch, "#{Telnyx.api_base}/v2/billing_groups/id"
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../test_helper"
4
+
5
+ module Telnyx
6
+ class CallControlApplicationTest < Test::Unit::TestCase
7
+ should "list call_control_application" do
8
+ call_control_application = CallControlApplication.list
9
+ assert_requested :get, "#{Telnyx.api_base}/v2/call_control_applications"
10
+ assert_kind_of ListObject, call_control_application
11
+ assert_kind_of CallControlApplication, call_control_application.first
12
+ end
13
+
14
+ should "create call_control_application" do
15
+ CallControlApplication.create webhook_event_url: "example.com", connection_name: "telnyx", application_name: "telnyx"
16
+ assert_requested :post, "#{Telnyx.api_base}/v2/call_control_applications"
17
+ end
18
+
19
+ should "retrieve call_control_application" do
20
+ call_control_application = CallControlApplication.retrieve("id")
21
+ assert_requested :get, "#{Telnyx.api_base}/v2/call_control_applications/id"
22
+ assert_kind_of CallControlApplication, call_control_application
23
+ end
24
+
25
+ should "delete call_control_application" do
26
+ call_control_application = CallControlApplication.retrieve("id")
27
+
28
+ call_control_application.delete
29
+ assert_requested :delete, "#{Telnyx.api_base}/v2/call_control_applications/id"
30
+ end
31
+
32
+ should "update call_control_application" do
33
+ call_control_application = CallControlApplication.retrieve("id")
34
+
35
+ call_control_application.webhook_event_url = "example.com"
36
+ call_control_application.connection_name = "telnyx"
37
+ call_control_application.application_name = "telnyx"
38
+ call_control_application.save
39
+ assert_requested :patch, "#{Telnyx.api_base}/v2/call_control_applications/id"
40
+ end
41
+ end
42
+ end
@@ -66,7 +66,7 @@ module Telnyx
66
66
  should "send all commands" do
67
67
  @call = Call.new
68
68
  @call.id = "1234"
69
- @call.reject
69
+ @call.reject cause: "CALL_REJECTED"
70
70
  assert_requested :post, format_url(@call, "reject")
71
71
  @call.answer
72
72
  assert_requested :post, format_url(@call, "answer")
@@ -97,7 +97,7 @@ module Telnyx
97
97
 
98
98
  context "commands" do
99
99
  should "reject" do
100
- @call.reject
100
+ @call.reject cause: "CALL_REJECTED"
101
101
  assert_requested :post, format_url(@call, "reject")
102
102
  end
103
103
  should "answer" do
@@ -151,7 +151,7 @@ module Telnyx
151
151
  end
152
152
 
153
153
  def create_call
154
- Telnyx::Call.create connection_id: "12345", to: "+15550001111", from: "+15550002222"
154
+ Telnyx::Call.create connection_id: "12345", to: "+15550001111", from: "+15550002222", cause: "test"
155
155
  end
156
156
 
157
157
  def format_url(call, action)
@@ -0,0 +1,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../test_helper"
4
+
5
+ module Telnyx
6
+ class ConferenceTest < Test::Unit::TestCase
7
+ setup do
8
+ @conference = Conference.create call_control_id: "foobar", name: "conference!"
9
+ end
10
+ should "create conference" do
11
+ assert_requested :post, "#{Telnyx.api_base}/v2/conferences"
12
+ assert_kind_of Conference, @conference
13
+ end
14
+
15
+ should "retrieve conference" do
16
+ conference = Conference.retrieve "foobar"
17
+ assert_kind_of Conference, conference
18
+ assert_requested :get, "#{Telnyx.api_base}/v2/conferences/foobar"
19
+ end
20
+
21
+ should "list conferences" do
22
+ conferences = Conference.list
23
+
24
+ assert_requested :get, "#{Telnyx.api_base}/v2/conferences"
25
+ assert_kind_of ListObject, conferences
26
+ assert_kind_of Conference, conferences.first
27
+ end
28
+
29
+ should "list participants" do
30
+ participants = @conference.participants
31
+ assert_requested :get, "#{Telnyx.api_base}/v2/conferences/#{@conference.id}/participants"
32
+ assert_kind_of ListObject, participants
33
+ end
34
+
35
+ should "have nested command instance methods" do
36
+ assert defined? @conference.join
37
+ assert defined? @conference.mute
38
+ assert defined? @conference.unmute
39
+ assert defined? @conference.unhold
40
+ assert defined? @conference.play
41
+ assert defined? @conference.start_recording
42
+ assert defined? @conference.stop_recording
43
+ assert defined? @conference.speak
44
+ assert defined? @conference.dial_participant
45
+ assert defined? @conference.update
46
+ end
47
+
48
+ context "commands" do
49
+ should "join" do
50
+ @conference.join call_control_id: "foo_bar_baz"
51
+ assert_requested :post, action_url(@conference, "join")
52
+ end
53
+
54
+ should "mute" do
55
+ @conference.mute
56
+ assert_requested :post, action_url(@conference, "mute")
57
+ end
58
+
59
+ should "unmute" do
60
+ @conference.unmute
61
+ assert_requested :post, action_url(@conference, "unmute")
62
+ end
63
+
64
+ should "hold" do
65
+ @conference.hold
66
+ assert_requested :post, action_url(@conference, "hold")
67
+ end
68
+
69
+ should "unhold" do
70
+ @conference.unhold call_control_ids: %w[foo bar baz]
71
+ assert_requested :post, action_url(@conference, "unhold")
72
+ end
73
+
74
+ should "play" do
75
+ @conference.play audio_url: "https://example.com/audio.mp3"
76
+ assert_requested :post, action_url(@conference, "play")
77
+ end
78
+
79
+ should "start recording" do
80
+ @conference.start_recording channels: "dual", format: "mp3"
81
+ assert_requested :post, action_url(@conference, "record_start")
82
+ end
83
+
84
+ should "stop recording" do
85
+ @conference.stop_recording
86
+ assert_requested :post, action_url(@conference, "record_stop")
87
+ end
88
+
89
+ should "speak" do
90
+ @conference.speak language: "en-US", payload: "test speech", voice: "female"
91
+ assert_requested :post, action_url(@conference, "speak")
92
+ end
93
+
94
+ should "dial participant" do
95
+ @conference.dial_participant call_control_id: "foo", to: "+12223334444", from: "+12223335555"
96
+ assert_requested :post, action_url(@conference, "dial_participant")
97
+ end
98
+
99
+ should "update" do
100
+ @conference.update call_control_id: "foo"
101
+ assert_requested :post, action_url(@conference, "update")
102
+ end
103
+ end
104
+
105
+ def create_call
106
+ Telnyx::Call.create connection_id: "12345", to: "+15550001111", from: "+15550002222"
107
+ end
108
+
109
+ def action_url(conf, action)
110
+ "#{Telnyx.api_base}/v2/conferences/#{conf.id}/actions/#{action}"
111
+ end
112
+ end
113
+ end