telnyx 0.0.8 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/scripts/before_install.sh +9 -0
- data/.github/workflows/ruby.yml +39 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +6 -36
- data/.rubocop_todo.yml +300 -0
- data/.travis.yml.bak +48 -0
- data/Gemfile +6 -5
- data/README.md +42 -3
- data/VERSION +1 -1
- data/bin/telnyx-console +7 -1
- data/examples/2 factor authentication/Gemfile +7 -0
- data/examples/2 factor authentication/main.rb +67 -0
- data/examples/2 factor authentication/readme.md +5 -0
- data/examples/fax/Gemfile +7 -0
- data/examples/fax/config.yaml +4 -0
- data/examples/fax/fax.rb +42 -0
- data/examples/fax/options.rb +41 -0
- data/examples/fax/readme.md +18 -0
- data/lib/telnyx.rb +22 -2
- data/lib/telnyx/address.rb +12 -0
- data/lib/telnyx/api_operations/list.rb +1 -1
- data/lib/telnyx/api_operations/nested_resource.rb +2 -2
- data/lib/telnyx/api_operations/save.rb +1 -1
- data/lib/telnyx/api_resource.rb +13 -2
- data/lib/telnyx/billing_group.rb +12 -0
- data/lib/telnyx/call.rb +3 -1
- data/lib/telnyx/call_control_application.rb +12 -0
- data/lib/telnyx/conference.rb +36 -0
- data/lib/telnyx/connection.rb +9 -0
- data/lib/telnyx/credential_connection.rb +12 -0
- data/lib/telnyx/fax.rb +13 -0
- data/lib/telnyx/fax_application.rb +12 -0
- data/lib/telnyx/fqdn.rb +12 -0
- data/lib/telnyx/fqdn_connection.rb +12 -0
- data/lib/telnyx/ip.rb +12 -0
- data/lib/telnyx/ip_connection.rb +12 -0
- data/lib/telnyx/list_object.rb +30 -44
- data/lib/telnyx/messaging_phone_number.rb +9 -0
- data/lib/telnyx/number_lookup.rb +7 -0
- data/lib/telnyx/number_order_document.rb +11 -0
- data/lib/telnyx/outbound_voice_profile.rb +12 -0
- data/lib/telnyx/phone_number.rb +20 -1
- data/lib/telnyx/phone_number_regulatory_requirement.rb +10 -0
- data/lib/telnyx/portout.rb +12 -0
- data/lib/telnyx/regulatory_requirement.rb +9 -0
- data/lib/telnyx/sim_card.rb +12 -1
- data/lib/telnyx/telnyx_client.rb +17 -26
- data/lib/telnyx/util.rb +38 -14
- data/lib/telnyx/verification.rb +27 -0
- data/lib/telnyx/verify_profile.rb +11 -0
- data/lib/telnyx/version.rb +1 -1
- data/lib/telnyx/wireless_detail_records_report.rb +12 -0
- data/telnyx.gemspec +1 -1
- data/test/telnyx/address_test.rb +67 -0
- data/test/telnyx/alphanumeric_sender_id_test.rb +4 -0
- data/test/telnyx/api_resource_test.rb +14 -5
- data/test/telnyx/billing_group_test.rb +40 -0
- data/test/telnyx/call_control_application_test.rb +42 -0
- data/test/telnyx/call_control_test.rb +54 -30
- data/test/telnyx/conference_test.rb +113 -0
- data/test/telnyx/connection_test.rb +28 -0
- data/test/telnyx/credential_connection_test.rb +44 -0
- data/test/telnyx/errors_test.rb +4 -4
- data/test/telnyx/fax_application_test.rb +32 -0
- data/test/telnyx/fax_test.rb +32 -0
- data/test/telnyx/fqdn_connection_test.rb +40 -0
- data/test/telnyx/fqdn_test.rb +40 -0
- data/test/telnyx/ip_connection_test.rb +40 -0
- data/test/telnyx/ip_test.rb +40 -0
- data/test/telnyx/list_object_test.rb +48 -90
- data/test/telnyx/messaging_phone_number_test.rb +8 -4
- data/test/telnyx/messaging_profile_test.rb +16 -5
- data/test/telnyx/number_lookup_test.rb +18 -0
- data/test/telnyx/number_order_document_test.rb +35 -0
- data/test/telnyx/outbound_voice_profile_test.rb +67 -0
- data/test/telnyx/phone_number_regulatory_requirement_test.rb +14 -0
- data/test/telnyx/phone_number_test.rb +40 -9
- data/test/telnyx/public_key_test.rb +1 -0
- data/test/telnyx/regulatory_requirement_test.rb +21 -0
- data/test/telnyx/sim_card_test.rb +6 -18
- data/test/telnyx/telnyx_client_test.rb +1 -1
- data/test/telnyx/telnyx_object_test.rb +5 -5
- data/test/telnyx/verification_test.rb +22 -0
- data/test/telnyx/verify_profile_test.rb +31 -0
- data/test/telnyx/wireless_detail_records_report_test.rb +57 -0
- data/test/test_helper.rb +1 -1
- metadata +93 -12
- data/.travis.yml +0 -51
- data/lib/telnyx/conferences.rb +0 -19
- data/test/telnyx/conferences_test.rb +0 -76
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Telnyx
|
4
|
+
class BillingGroup < APIResource
|
5
|
+
extend APIOperations::List
|
6
|
+
extend APIOperations::Create
|
7
|
+
include APIOperations::Delete
|
8
|
+
include APIOperations::Save
|
9
|
+
|
10
|
+
OBJECT_NAME = "billing_group".freeze
|
11
|
+
end
|
12
|
+
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
|
36
|
+
playback_stop record_start record_stop send_dtmf transfer
|
37
|
+
transcription_start transcription_stop record_pause
|
38
|
+
record_resume gather_stop refer].freeze
|
37
39
|
|
38
40
|
ACTIONS.each do |action|
|
39
41
|
nested_resource_class_methods action,
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Telnyx
|
4
|
+
class CallControlApplication < APIResource
|
5
|
+
extend APIOperations::List
|
6
|
+
extend APIOperations::Create
|
7
|
+
include APIOperations::Delete
|
8
|
+
include APIOperations::Save
|
9
|
+
|
10
|
+
OBJECT_NAME = "call_control_application".freeze
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Telnyx
|
4
|
+
class Conference < APIResource
|
5
|
+
extend APIOperations::List
|
6
|
+
extend APIOperations::Create
|
7
|
+
extend APIOperations::NestedResource
|
8
|
+
|
9
|
+
ACTIONS = %w[join mute unmute hold unhold speak play dial_participant update].freeze
|
10
|
+
|
11
|
+
ACTIONS.each do |action|
|
12
|
+
nested_resource_class_methods action,
|
13
|
+
path: ["actions", action],
|
14
|
+
operations: [:create],
|
15
|
+
instance_methods: { create: action }
|
16
|
+
end
|
17
|
+
|
18
|
+
nested_resource_class_methods "record_start",
|
19
|
+
path: ["actions", "record_start"],
|
20
|
+
operations: [:create],
|
21
|
+
instance_methods: { create: "start_recording" }
|
22
|
+
|
23
|
+
nested_resource_class_methods "record_stop",
|
24
|
+
path: ["actions", "record_stop"],
|
25
|
+
operations: [:create],
|
26
|
+
instance_methods: { create: "stop_recording" }
|
27
|
+
|
28
|
+
nested_resource_class_methods "participants",
|
29
|
+
path: "participants",
|
30
|
+
operations: [:list],
|
31
|
+
instance_methods: { list: "participants" }
|
32
|
+
|
33
|
+
OBJECT_NAME = "conference".freeze
|
34
|
+
end
|
35
|
+
Conferences = Conference # Name change without breaking existing code
|
36
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Telnyx
|
4
|
+
class CredentialConnection < 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 = "credential_connection".freeze
|
11
|
+
end
|
12
|
+
end
|
data/lib/telnyx/fax.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Telnyx
|
4
|
+
class Fax < APIResource
|
5
|
+
extend Telnyx::APIOperations::List
|
6
|
+
extend Telnyx::APIOperations::Create
|
7
|
+
include Telnyx::APIOperations::Delete
|
8
|
+
include Telnyx::APIOperations::Save
|
9
|
+
|
10
|
+
OBJECT_NAME = "fax".freeze
|
11
|
+
RESOURCE_PATH = "faxes".freeze
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Telnyx
|
4
|
+
class FaxApplication < APIResource
|
5
|
+
extend Telnyx::APIOperations::List
|
6
|
+
extend Telnyx::APIOperations::Create
|
7
|
+
include Telnyx::APIOperations::Delete
|
8
|
+
include Telnyx::APIOperations::Save
|
9
|
+
|
10
|
+
OBJECT_NAME = "fax_application".freeze
|
11
|
+
end
|
12
|
+
end
|
data/lib/telnyx/fqdn.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Telnyx
|
4
|
+
class FQDN < APIResource
|
5
|
+
extend Telnyx::APIOperations::List
|
6
|
+
extend Telnyx::APIOperations::Create
|
7
|
+
include Telnyx::APIOperations::Delete
|
8
|
+
include Telnyx::APIOperations::Save
|
9
|
+
|
10
|
+
OBJECT_NAME = "fqdn".freeze
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Telnyx
|
4
|
+
class FQDNConnection < APIResource
|
5
|
+
extend Telnyx::APIOperations::List
|
6
|
+
extend Telnyx::APIOperations::Create
|
7
|
+
include Telnyx::APIOperations::Delete
|
8
|
+
include Telnyx::APIOperations::Save
|
9
|
+
|
10
|
+
OBJECT_NAME = "fqdn_connection".freeze
|
11
|
+
end
|
12
|
+
end
|
data/lib/telnyx/ip.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Telnyx
|
4
|
+
class IP < APIResource
|
5
|
+
extend Telnyx::APIOperations::List
|
6
|
+
extend Telnyx::APIOperations::Create
|
7
|
+
include Telnyx::APIOperations::Delete
|
8
|
+
include Telnyx::APIOperations::Save
|
9
|
+
|
10
|
+
OBJECT_NAME = "ip".freeze
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Telnyx
|
4
|
+
class IPConnection < APIResource
|
5
|
+
extend APIOperations::List
|
6
|
+
extend APIOperations::Create
|
7
|
+
include APIOperations::Delete
|
8
|
+
include APIOperations::Save
|
9
|
+
|
10
|
+
OBJECT_NAME = "ip_connection".freeze
|
11
|
+
end
|
12
|
+
end
|
data/lib/telnyx/list_object.rb
CHANGED
@@ -59,23 +59,6 @@ module Telnyx
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
# Iterates through each resource in all pages, making additional fetches to
|
63
|
-
# the API as necessary.
|
64
|
-
#
|
65
|
-
# Note that this method will make as many API calls as necessary to fetch
|
66
|
-
# all resources. For more granular control, please see +each+ and
|
67
|
-
# +next_page_by_token+.
|
68
|
-
def auto_paging_each_by_token(&blk)
|
69
|
-
return enum_for(:auto_paging_each_by_token) unless block_given?
|
70
|
-
|
71
|
-
page = self
|
72
|
-
loop do
|
73
|
-
page.each(&blk)
|
74
|
-
page = page.next_page_by_token
|
75
|
-
break if page.empty?
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
62
|
# Returns true if the page object contains no elements.
|
80
63
|
def empty?
|
81
64
|
data.empty?
|
@@ -98,15 +81,7 @@ module Telnyx
|
|
98
81
|
def next_page(params = {}, opts = {})
|
99
82
|
return self.class.empty_list(opts) unless more?
|
100
83
|
next_page_number = page_number.to_i + 1
|
101
|
-
pagination = { number: next_page_number, size:
|
102
|
-
params = filters.merge(params).merge(page: pagination)
|
103
|
-
|
104
|
-
list(params, opts)
|
105
|
-
end
|
106
|
-
|
107
|
-
def next_page_by_token(params = {}, opts = {})
|
108
|
-
return self.class.empty_list(opts) unless token
|
109
|
-
pagination = { token: token }
|
84
|
+
pagination = { number: next_page_number, size: filter_page_size }
|
110
85
|
params = filters.merge(params).merge(page: pagination)
|
111
86
|
|
112
87
|
list(params, opts)
|
@@ -119,37 +94,48 @@ module Telnyx
|
|
119
94
|
def previous_page(params = {}, opts = {})
|
120
95
|
prev_page_number = page_number.to_i - 1
|
121
96
|
prev_page_number = [prev_page_number, 1].max
|
122
|
-
pagination = { number: prev_page_number, size:
|
97
|
+
pagination = { number: prev_page_number, size: filter_page_size }
|
123
98
|
params = filters.merge(params).merge(page: pagination)
|
124
99
|
|
125
100
|
list(params, opts)
|
126
101
|
end
|
127
102
|
|
128
|
-
# Fetch the current page size
|
129
|
-
def page_size
|
130
|
-
|
131
|
-
params[:page][:size]
|
132
|
-
else
|
133
|
-
20
|
134
|
-
end
|
103
|
+
# Fetch the current page size from metadata.
|
104
|
+
def page_size
|
105
|
+
from_meta(:page_size, 20)
|
135
106
|
end
|
136
107
|
|
137
|
-
# Fetch the current page number
|
108
|
+
# Fetch the current page number from metadata.
|
138
109
|
def page_number
|
139
|
-
|
140
|
-
meta.page_number
|
141
|
-
else
|
142
|
-
1
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def token
|
147
|
-
return meta.next_page_token if meta && meta[:next_page_token]
|
110
|
+
from_meta(:page_number, 1)
|
148
111
|
end
|
149
112
|
|
150
113
|
def resource_url
|
151
114
|
url ||
|
152
115
|
raise(ArgumentError, "List object does not contain a 'url' field.")
|
153
116
|
end
|
117
|
+
|
118
|
+
private
|
119
|
+
|
120
|
+
# Determine page size from filters
|
121
|
+
def filter_page_size
|
122
|
+
if filters && filters[:page] && filters[:page][:size]
|
123
|
+
filters[:page][:size]
|
124
|
+
else
|
125
|
+
20
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Fetches `attribute` from current page metada. If it's not found returns
|
130
|
+
# `default`, which defaults to `nil`.
|
131
|
+
def from_meta(attribute, default = nil)
|
132
|
+
attribute = attribute.to_sym
|
133
|
+
|
134
|
+
if meta && meta[attribute]
|
135
|
+
meta.public_send(attribute)
|
136
|
+
else
|
137
|
+
default
|
138
|
+
end
|
139
|
+
end
|
154
140
|
end
|
155
141
|
end
|
@@ -5,6 +5,15 @@ 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
|
+
|
8
13
|
OBJECT_NAME = "messaging_phone_number".freeze
|
14
|
+
def self.resource_path(id = nil)
|
15
|
+
return "phone_numbers/#{CGI.escape(id)}/messaging" if id
|
16
|
+
"phone_numbers/messaging"
|
17
|
+
end
|
9
18
|
end
|
10
19
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Telnyx
|
4
|
+
class OutboundVoiceProfile < APIResource
|
5
|
+
include Telnyx::APIOperations::Save
|
6
|
+
include Telnyx::APIOperations::Delete
|
7
|
+
extend Telnyx::APIOperations::List
|
8
|
+
extend Telnyx::APIOperations::Create
|
9
|
+
|
10
|
+
OBJECT_NAME = "outbound_voice_profile".freeze
|
11
|
+
end
|
12
|
+
end
|
data/lib/telnyx/phone_number.rb
CHANGED
@@ -13,8 +13,11 @@ module Telnyx
|
|
13
13
|
instance_methods: { list: "voice" }
|
14
14
|
nested_resource_class_methods "messaging",
|
15
15
|
path: ["messaging"],
|
16
|
-
operations: %i[update list],
|
16
|
+
operations: %i[update list retrieve],
|
17
17
|
instance_methods: { list: "messaging" }
|
18
|
+
nested_resource_class_methods "inbound_channel",
|
19
|
+
path: ["inbound_channels"],
|
20
|
+
operations: %i[update list]
|
18
21
|
|
19
22
|
def update_messaging(opts)
|
20
23
|
self.class.update_messaging(id, nil, opts)
|
@@ -24,6 +27,22 @@ module Telnyx
|
|
24
27
|
self.class.update_voice(id, nil, opts)
|
25
28
|
end
|
26
29
|
|
30
|
+
def update_inbound_channels=(val)
|
31
|
+
self.class.update_inbound_channel(nil, nil, channels: val)
|
32
|
+
end
|
33
|
+
|
34
|
+
def inbound_channels
|
35
|
+
self.class.list_inbound_channels(nil).channels
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.list_voice
|
39
|
+
list_voices nil
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.messaging
|
43
|
+
list_messagings(nil)
|
44
|
+
end
|
45
|
+
|
27
46
|
OBJECT_NAME = "phone_number".freeze
|
28
47
|
end
|
29
48
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Telnyx
|
4
|
+
class PhoneNumberRegulatoryRequirement < APIResource
|
5
|
+
extend APIOperations::List
|
6
|
+
|
7
|
+
OBJECT_NAME = "phone_number_regulatory_requirement".freeze
|
8
|
+
RESOURCE_PATH = "phone_numbers_regulatory_requirements".freeze
|
9
|
+
end
|
10
|
+
end
|
data/lib/telnyx/sim_card.rb
CHANGED
@@ -6,7 +6,7 @@ module Telnyx
|
|
6
6
|
extend APIOperations::NestedResource
|
7
7
|
extend APIOperations::List
|
8
8
|
|
9
|
-
ACTIONS = %w[
|
9
|
+
ACTIONS = %w[enable disable].freeze
|
10
10
|
ACTIONS.each do |action|
|
11
11
|
nested_resource_class_methods action,
|
12
12
|
path: %W[actions #{action}],
|
@@ -20,5 +20,16 @@ module Telnyx
|
|
20
20
|
end
|
21
21
|
|
22
22
|
OBJECT_NAME = "sim_card".freeze
|
23
|
+
|
24
|
+
# depreciated api
|
25
|
+
def activate
|
26
|
+
warn "[DEPRECATION] SimCard#activate is deprecated, use enable instead."
|
27
|
+
enable
|
28
|
+
end
|
29
|
+
|
30
|
+
def deactivate
|
31
|
+
warn "[DEPRECATION] SimCard#deactivate is deprecated, use enable instead."
|
32
|
+
disable
|
33
|
+
end
|
23
34
|
end
|
24
35
|
end
|