twilio-ruby 5.12.4 → 5.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +13 -0
- data/README.md +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb +28 -13
- data/lib/twilio-ruby/rest/api/v2010/account/conference/recording.rb +14 -6
- data/lib/twilio-ruby/rest/client.rb +7 -0
- data/lib/twilio-ruby/rest/preview.rb +28 -8
- data/lib/twilio-ruby/rest/preview/authy.rb +43 -0
- data/lib/twilio-ruby/rest/preview/authy/service.rb +364 -0
- data/lib/twilio-ruby/rest/preview/authy/service/entity.rb +326 -0
- data/lib/twilio-ruby/rest/preview/permissions.rb +35 -0
- data/lib/twilio-ruby/rest/preview/permissions/voice_permission.rb +131 -0
- data/lib/twilio-ruby/rest/preview/permissions/voice_permission/bulk_country_update.rb +132 -0
- data/lib/twilio-ruby/rest/preview/permissions/voice_permission/country.rb +391 -0
- data/lib/twilio-ruby/rest/preview/permissions/voice_permission/country/highrisk_special_prefix.rb +192 -0
- data/lib/twilio-ruby/rest/preview/permissions/voice_permission/settings.rb +197 -0
- data/lib/twilio-ruby/rest/preview/understand/assistant.rb +12 -6
- data/lib/twilio-ruby/rest/preview/understand/assistant/intent/intent_actions.rb +13 -11
- data/lib/twilio-ruby/rest/pricing/v2/voice.rb +17 -0
- data/lib/twilio-ruby/rest/pricing/v2/voice/number.rb +214 -0
- data/lib/twilio-ruby/rest/verify.rb +46 -0
- data/lib/twilio-ruby/rest/verify/v1.rb +43 -0
- data/lib/twilio-ruby/rest/verify/v1/service.rb +391 -0
- data/lib/twilio-ruby/rest/verify/v1/service/verification.rb +185 -0
- data/lib/twilio-ruby/rest/verify/v1/service/verification_check.rb +182 -0
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/integration/preview/authy/service/entity_spec.rb +173 -0
- data/spec/integration/preview/authy/service_spec.rb +201 -0
- data/spec/integration/preview/permissions/voice_permission/bulk_country_update_spec.rb +45 -0
- data/spec/integration/preview/permissions/voice_permission/country/highrisk_special_prefix_spec.rb +61 -0
- data/spec/integration/preview/permissions/voice_permission/country_spec.rb +112 -0
- data/spec/integration/preview/permissions/voice_permission/settings_spec.rb +77 -0
- data/spec/integration/preview/permissions/voice_permission_spec.rb +12 -0
- data/spec/integration/pricing/v2/voice/number_spec.rb +62 -0
- data/spec/integration/verify/v1/service/verification_check_spec.rb +52 -0
- data/spec/integration/verify/v1/service/verification_spec.rb +52 -0
- data/spec/integration/verify/v1/service_spec.rb +185 -0
- metadata +39 -2
@@ -23,6 +23,7 @@ module Twilio
|
|
23
23
|
|
24
24
|
# Components
|
25
25
|
@countries = nil
|
26
|
+
@numbers = nil
|
26
27
|
end
|
27
28
|
|
28
29
|
##
|
@@ -41,6 +42,22 @@ module Twilio
|
|
41
42
|
@countries ||= CountryList.new(@version, )
|
42
43
|
end
|
43
44
|
|
45
|
+
##
|
46
|
+
# Access the numbers
|
47
|
+
# @param [String] destination_number This fetches the origin-based voice pricing
|
48
|
+
# information for a phone number
|
49
|
+
# @return [NumberList]
|
50
|
+
# @return [NumberContext] if destination_number was passed.
|
51
|
+
def numbers(destination_number=:unset)
|
52
|
+
raise ArgumentError, 'destination_number cannot be nil' if destination_number.nil?
|
53
|
+
|
54
|
+
if destination_number != :unset
|
55
|
+
return NumberContext.new(@version, destination_number, )
|
56
|
+
end
|
57
|
+
|
58
|
+
@numbers ||= NumberList.new(@version, )
|
59
|
+
end
|
60
|
+
|
44
61
|
##
|
45
62
|
# Provide a user friendly representation
|
46
63
|
def to_s
|
@@ -0,0 +1,214 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
#
|
7
|
+
# frozen_string_literal: true
|
8
|
+
|
9
|
+
module Twilio
|
10
|
+
module REST
|
11
|
+
class Pricing < Domain
|
12
|
+
class V2 < Version
|
13
|
+
class VoiceList < ListResource
|
14
|
+
class NumberList < ListResource
|
15
|
+
##
|
16
|
+
# Initialize the NumberList
|
17
|
+
# @param [Version] version Version that contains the resource
|
18
|
+
# @return [NumberList] NumberList
|
19
|
+
def initialize(version)
|
20
|
+
super(version)
|
21
|
+
|
22
|
+
# Path Solution
|
23
|
+
@solution = {}
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# Provide a user friendly representation
|
28
|
+
def to_s
|
29
|
+
'#<Twilio.Pricing.V2.NumberList>'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class NumberPage < Page
|
34
|
+
##
|
35
|
+
# Initialize the NumberPage
|
36
|
+
# @param [Version] version Version that contains the resource
|
37
|
+
# @param [Response] response Response from the API
|
38
|
+
# @param [Hash] solution Path solution for the resource
|
39
|
+
# @return [NumberPage] NumberPage
|
40
|
+
def initialize(version, response, solution)
|
41
|
+
super(version, response)
|
42
|
+
|
43
|
+
# Path Solution
|
44
|
+
@solution = solution
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# Build an instance of NumberInstance
|
49
|
+
# @param [Hash] payload Payload response from the API
|
50
|
+
# @return [NumberInstance] NumberInstance
|
51
|
+
def get_instance(payload)
|
52
|
+
NumberInstance.new(@version, payload, )
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Provide a user friendly representation
|
57
|
+
def to_s
|
58
|
+
'<Twilio.Pricing.V2.NumberPage>'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class NumberContext < InstanceContext
|
63
|
+
##
|
64
|
+
# Initialize the NumberContext
|
65
|
+
# @param [Version] version Version that contains the resource
|
66
|
+
# @param [String] destination_number This fetches the origin-based voice pricing
|
67
|
+
# information for a phone number
|
68
|
+
# @return [NumberContext] NumberContext
|
69
|
+
def initialize(version, destination_number)
|
70
|
+
super(version)
|
71
|
+
|
72
|
+
# Path Solution
|
73
|
+
@solution = {destination_number: destination_number, }
|
74
|
+
@uri = "/Voice/Numbers/#{@solution[:destination_number]}"
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
# Fetch a NumberInstance
|
79
|
+
# @param [String] origination_number The origination_number
|
80
|
+
# @return [NumberInstance] Fetched NumberInstance
|
81
|
+
def fetch(origination_number: :unset)
|
82
|
+
params = Twilio::Values.of({'OriginationNumber' => origination_number, })
|
83
|
+
|
84
|
+
payload = @version.fetch(
|
85
|
+
'GET',
|
86
|
+
@uri,
|
87
|
+
params,
|
88
|
+
)
|
89
|
+
|
90
|
+
NumberInstance.new(@version, payload, destination_number: @solution[:destination_number], )
|
91
|
+
end
|
92
|
+
|
93
|
+
##
|
94
|
+
# Provide a user friendly representation
|
95
|
+
def to_s
|
96
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
97
|
+
"#<Twilio.Pricing.V2.NumberContext #{context}>"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
class NumberInstance < InstanceResource
|
102
|
+
##
|
103
|
+
# Initialize the NumberInstance
|
104
|
+
# @param [Version] version Version that contains the resource
|
105
|
+
# @param [Hash] payload payload that contains response from Twilio
|
106
|
+
# @param [String] destination_number This fetches the origin-based voice pricing
|
107
|
+
# information for a phone number
|
108
|
+
# @return [NumberInstance] NumberInstance
|
109
|
+
def initialize(version, payload, destination_number: nil)
|
110
|
+
super(version)
|
111
|
+
|
112
|
+
# Marshaled Properties
|
113
|
+
@properties = {
|
114
|
+
'destination_number' => payload['destination_number'],
|
115
|
+
'origination_number' => payload['origination_number'],
|
116
|
+
'country' => payload['country'],
|
117
|
+
'iso_country' => payload['iso_country'],
|
118
|
+
'outbound_call_prices' => payload['outbound_call_prices'],
|
119
|
+
'inbound_call_price' => payload['inbound_call_price'],
|
120
|
+
'price_unit' => payload['price_unit'],
|
121
|
+
'url' => payload['url'],
|
122
|
+
}
|
123
|
+
|
124
|
+
# Context
|
125
|
+
@instance_context = nil
|
126
|
+
@params = {'destination_number' => destination_number || @properties['destination_number'], }
|
127
|
+
end
|
128
|
+
|
129
|
+
##
|
130
|
+
# Generate an instance context for the instance, the context is capable of
|
131
|
+
# performing various actions. All instance actions are proxied to the context
|
132
|
+
# @return [NumberContext] NumberContext for this NumberInstance
|
133
|
+
def context
|
134
|
+
unless @instance_context
|
135
|
+
@instance_context = NumberContext.new(@version, @params['destination_number'], )
|
136
|
+
end
|
137
|
+
@instance_context
|
138
|
+
end
|
139
|
+
|
140
|
+
##
|
141
|
+
# @return [String] The destination phone number, in E.164
|
142
|
+
def destination_number
|
143
|
+
@properties['destination_number']
|
144
|
+
end
|
145
|
+
|
146
|
+
##
|
147
|
+
# @return [String] The origination phone number, in E.164
|
148
|
+
def origination_number
|
149
|
+
@properties['origination_number']
|
150
|
+
end
|
151
|
+
|
152
|
+
##
|
153
|
+
# @return [String] Name of the country
|
154
|
+
def country
|
155
|
+
@properties['country']
|
156
|
+
end
|
157
|
+
|
158
|
+
##
|
159
|
+
# @return [String] The ISO country code
|
160
|
+
def iso_country
|
161
|
+
@properties['iso_country']
|
162
|
+
end
|
163
|
+
|
164
|
+
##
|
165
|
+
# @return [String] List of OutboundCallPriceWithOrigin records
|
166
|
+
def outbound_call_prices
|
167
|
+
@properties['outbound_call_prices']
|
168
|
+
end
|
169
|
+
|
170
|
+
##
|
171
|
+
# @return [String] List of InboundCallPrice records
|
172
|
+
def inbound_call_price
|
173
|
+
@properties['inbound_call_price']
|
174
|
+
end
|
175
|
+
|
176
|
+
##
|
177
|
+
# @return [String] The currency in which prices are measured, in ISO 4127 format (e.g. usd, eur, jpy).
|
178
|
+
def price_unit
|
179
|
+
@properties['price_unit']
|
180
|
+
end
|
181
|
+
|
182
|
+
##
|
183
|
+
# @return [String] The URL of this resource.
|
184
|
+
def url
|
185
|
+
@properties['url']
|
186
|
+
end
|
187
|
+
|
188
|
+
##
|
189
|
+
# Fetch a NumberInstance
|
190
|
+
# @param [String] origination_number The origination_number
|
191
|
+
# @return [NumberInstance] Fetched NumberInstance
|
192
|
+
def fetch(origination_number: :unset)
|
193
|
+
context.fetch(origination_number: origination_number, )
|
194
|
+
end
|
195
|
+
|
196
|
+
##
|
197
|
+
# Provide a user friendly representation
|
198
|
+
def to_s
|
199
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
200
|
+
"<Twilio.Pricing.V2.NumberInstance #{values}>"
|
201
|
+
end
|
202
|
+
|
203
|
+
##
|
204
|
+
# Provide a detailed, user friendly representation
|
205
|
+
def inspect
|
206
|
+
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
|
207
|
+
"<Twilio.Pricing.V2.NumberInstance #{values}>"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
#
|
7
|
+
# frozen_string_literal: true
|
8
|
+
|
9
|
+
module Twilio
|
10
|
+
module REST
|
11
|
+
class Verify < Domain
|
12
|
+
##
|
13
|
+
# Initialize the Verify Domain
|
14
|
+
def initialize(twilio)
|
15
|
+
super
|
16
|
+
|
17
|
+
@base_url = 'https://verify.twilio.com'
|
18
|
+
@host = 'verify.twilio.com'
|
19
|
+
@port = 443
|
20
|
+
|
21
|
+
# Versions
|
22
|
+
@v1 = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
##
|
26
|
+
# Version v1 of verify
|
27
|
+
def v1
|
28
|
+
@v1 ||= V1.new self
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# @param [String] sid A 34 character string that uniquely identifies this Service.
|
33
|
+
# @return [Twilio::REST::Verify::V1::ServiceInstance] if sid was passed.
|
34
|
+
# @return [Twilio::REST::Verify::V1::ServiceList]
|
35
|
+
def services(sid=:unset)
|
36
|
+
self.v1.services(sid)
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# Provide a user friendly representation
|
41
|
+
def to_s
|
42
|
+
'#<Twilio::REST::Verify>'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
#
|
7
|
+
# frozen_string_literal: true
|
8
|
+
|
9
|
+
module Twilio
|
10
|
+
module REST
|
11
|
+
class Verify
|
12
|
+
class V1 < Version
|
13
|
+
##
|
14
|
+
# Initialize the V1 version of Verify
|
15
|
+
def initialize(domain)
|
16
|
+
super
|
17
|
+
@version = 'v1'
|
18
|
+
@services = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# @param [String] sid The unique SID identifier of Verification Service Instance.
|
23
|
+
# @return [Twilio::REST::Verify::V1::ServiceContext] if sid was passed.
|
24
|
+
# @return [Twilio::REST::Verify::V1::ServiceList]
|
25
|
+
def services(sid=:unset)
|
26
|
+
if sid.nil?
|
27
|
+
raise ArgumentError, 'sid cannot be nil'
|
28
|
+
elsif sid == :unset
|
29
|
+
@services ||= ServiceList.new self
|
30
|
+
else
|
31
|
+
ServiceContext.new(self, sid)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
##
|
36
|
+
# Provide a user friendly representation
|
37
|
+
def to_s
|
38
|
+
'<Twilio::REST::Verify::V1>'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,391 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
#
|
7
|
+
# frozen_string_literal: true
|
8
|
+
|
9
|
+
module Twilio
|
10
|
+
module REST
|
11
|
+
class Verify < Domain
|
12
|
+
class V1 < Version
|
13
|
+
##
|
14
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
15
|
+
class ServiceList < ListResource
|
16
|
+
##
|
17
|
+
# Initialize the ServiceList
|
18
|
+
# @param [Version] version Version that contains the resource
|
19
|
+
# @return [ServiceList] ServiceList
|
20
|
+
def initialize(version)
|
21
|
+
super(version)
|
22
|
+
|
23
|
+
# Path Solution
|
24
|
+
@solution = {}
|
25
|
+
@uri = "/Services"
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Retrieve a single page of ServiceInstance records from the API.
|
30
|
+
# Request is executed immediately.
|
31
|
+
# @param [String] friendly_name A 1-64 character string with friendly name of
|
32
|
+
# service
|
33
|
+
# @param [String] code_length The length of the verification code to be generated.
|
34
|
+
# Must be an integer value between 4-10
|
35
|
+
# @return [ServiceInstance] Newly created ServiceInstance
|
36
|
+
def create(friendly_name: nil, code_length: :unset)
|
37
|
+
data = Twilio::Values.of({'FriendlyName' => friendly_name, 'CodeLength' => code_length, })
|
38
|
+
|
39
|
+
payload = @version.create(
|
40
|
+
'POST',
|
41
|
+
@uri,
|
42
|
+
data: data
|
43
|
+
)
|
44
|
+
|
45
|
+
ServiceInstance.new(@version, payload, )
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# Lists ServiceInstance records from the API as a list.
|
50
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
51
|
+
# memory before returning.
|
52
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
53
|
+
# guarantees to never return more than limit. Default is no limit
|
54
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
55
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
56
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
57
|
+
# efficient page size, i.e. min(limit, 1000)
|
58
|
+
# @return [Array] Array of up to limit results
|
59
|
+
def list(limit: nil, page_size: nil)
|
60
|
+
self.stream(limit: limit, page_size: page_size).entries
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# Streams ServiceInstance records from the API as an Enumerable.
|
65
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
66
|
+
# is reached.
|
67
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
68
|
+
# guarantees to never return more than limit. Default is no limit.
|
69
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
70
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
71
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
72
|
+
# efficient page size, i.e. min(limit, 1000)
|
73
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
74
|
+
def stream(limit: nil, page_size: nil)
|
75
|
+
limits = @version.read_limits(limit, page_size)
|
76
|
+
|
77
|
+
page = self.page(page_size: limits[:page_size], )
|
78
|
+
|
79
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# When passed a block, yields ServiceInstance records from the API.
|
84
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
85
|
+
# is reached.
|
86
|
+
def each
|
87
|
+
limits = @version.read_limits
|
88
|
+
|
89
|
+
page = self.page(page_size: limits[:page_size], )
|
90
|
+
|
91
|
+
@version.stream(page,
|
92
|
+
limit: limits[:limit],
|
93
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
94
|
+
end
|
95
|
+
|
96
|
+
##
|
97
|
+
# Retrieve a single page of ServiceInstance records from the API.
|
98
|
+
# Request is executed immediately.
|
99
|
+
# @param [String] page_token PageToken provided by the API
|
100
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
101
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
102
|
+
# @return [Page] Page of ServiceInstance
|
103
|
+
def page(page_token: :unset, page_number: :unset, page_size: :unset)
|
104
|
+
params = Twilio::Values.of({
|
105
|
+
'PageToken' => page_token,
|
106
|
+
'Page' => page_number,
|
107
|
+
'PageSize' => page_size,
|
108
|
+
})
|
109
|
+
response = @version.page(
|
110
|
+
'GET',
|
111
|
+
@uri,
|
112
|
+
params
|
113
|
+
)
|
114
|
+
ServicePage.new(@version, response, @solution)
|
115
|
+
end
|
116
|
+
|
117
|
+
##
|
118
|
+
# Retrieve a single page of ServiceInstance records from the API.
|
119
|
+
# Request is executed immediately.
|
120
|
+
# @param [String] target_url API-generated URL for the requested results page
|
121
|
+
# @return [Page] Page of ServiceInstance
|
122
|
+
def get_page(target_url)
|
123
|
+
response = @version.domain.request(
|
124
|
+
'GET',
|
125
|
+
target_url
|
126
|
+
)
|
127
|
+
ServicePage.new(@version, response, @solution)
|
128
|
+
end
|
129
|
+
|
130
|
+
##
|
131
|
+
# Provide a user friendly representation
|
132
|
+
def to_s
|
133
|
+
'#<Twilio.Verify.V1.ServiceList>'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
##
|
138
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
139
|
+
class ServicePage < Page
|
140
|
+
##
|
141
|
+
# Initialize the ServicePage
|
142
|
+
# @param [Version] version Version that contains the resource
|
143
|
+
# @param [Response] response Response from the API
|
144
|
+
# @param [Hash] solution Path solution for the resource
|
145
|
+
# @return [ServicePage] ServicePage
|
146
|
+
def initialize(version, response, solution)
|
147
|
+
super(version, response)
|
148
|
+
|
149
|
+
# Path Solution
|
150
|
+
@solution = solution
|
151
|
+
end
|
152
|
+
|
153
|
+
##
|
154
|
+
# Build an instance of ServiceInstance
|
155
|
+
# @param [Hash] payload Payload response from the API
|
156
|
+
# @return [ServiceInstance] ServiceInstance
|
157
|
+
def get_instance(payload)
|
158
|
+
ServiceInstance.new(@version, payload, )
|
159
|
+
end
|
160
|
+
|
161
|
+
##
|
162
|
+
# Provide a user friendly representation
|
163
|
+
def to_s
|
164
|
+
'<Twilio.Verify.V1.ServicePage>'
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
##
|
169
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
170
|
+
class ServiceContext < InstanceContext
|
171
|
+
##
|
172
|
+
# Initialize the ServiceContext
|
173
|
+
# @param [Version] version Version that contains the resource
|
174
|
+
# @param [String] sid The unique SID identifier of Verification Service Instance.
|
175
|
+
# @return [ServiceContext] ServiceContext
|
176
|
+
def initialize(version, sid)
|
177
|
+
super(version)
|
178
|
+
|
179
|
+
# Path Solution
|
180
|
+
@solution = {sid: sid, }
|
181
|
+
@uri = "/Services/#{@solution[:sid]}"
|
182
|
+
|
183
|
+
# Dependents
|
184
|
+
@verifications = nil
|
185
|
+
@verification_checks = nil
|
186
|
+
end
|
187
|
+
|
188
|
+
##
|
189
|
+
# Fetch a ServiceInstance
|
190
|
+
# @return [ServiceInstance] Fetched ServiceInstance
|
191
|
+
def fetch
|
192
|
+
params = Twilio::Values.of({})
|
193
|
+
|
194
|
+
payload = @version.fetch(
|
195
|
+
'GET',
|
196
|
+
@uri,
|
197
|
+
params,
|
198
|
+
)
|
199
|
+
|
200
|
+
ServiceInstance.new(@version, payload, sid: @solution[:sid], )
|
201
|
+
end
|
202
|
+
|
203
|
+
##
|
204
|
+
# Update the ServiceInstance
|
205
|
+
# @param [String] friendly_name A 1-64 character string with friendly name of
|
206
|
+
# service
|
207
|
+
# @param [String] code_length The length of the verification code to be generated.
|
208
|
+
# Must be an integer value between 4-10
|
209
|
+
# @return [ServiceInstance] Updated ServiceInstance
|
210
|
+
def update(friendly_name: :unset, code_length: :unset)
|
211
|
+
data = Twilio::Values.of({'FriendlyName' => friendly_name, 'CodeLength' => code_length, })
|
212
|
+
|
213
|
+
payload = @version.update(
|
214
|
+
'POST',
|
215
|
+
@uri,
|
216
|
+
data: data,
|
217
|
+
)
|
218
|
+
|
219
|
+
ServiceInstance.new(@version, payload, sid: @solution[:sid], )
|
220
|
+
end
|
221
|
+
|
222
|
+
##
|
223
|
+
# Access the verifications
|
224
|
+
# @return [VerificationList]
|
225
|
+
# @return [VerificationContext]
|
226
|
+
def verifications
|
227
|
+
unless @verifications
|
228
|
+
@verifications = VerificationList.new(@version, service_sid: @solution[:sid], )
|
229
|
+
end
|
230
|
+
|
231
|
+
@verifications
|
232
|
+
end
|
233
|
+
|
234
|
+
##
|
235
|
+
# Access the verification_checks
|
236
|
+
# @return [VerificationCheckList]
|
237
|
+
# @return [VerificationCheckContext]
|
238
|
+
def verification_checks
|
239
|
+
unless @verification_checks
|
240
|
+
@verification_checks = VerificationCheckList.new(@version, service_sid: @solution[:sid], )
|
241
|
+
end
|
242
|
+
|
243
|
+
@verification_checks
|
244
|
+
end
|
245
|
+
|
246
|
+
##
|
247
|
+
# Provide a user friendly representation
|
248
|
+
def to_s
|
249
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
250
|
+
"#<Twilio.Verify.V1.ServiceContext #{context}>"
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
##
|
255
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
256
|
+
class ServiceInstance < InstanceResource
|
257
|
+
##
|
258
|
+
# Initialize the ServiceInstance
|
259
|
+
# @param [Version] version Version that contains the resource
|
260
|
+
# @param [Hash] payload payload that contains response from Twilio
|
261
|
+
# @param [String] sid The unique SID identifier of Verification Service Instance.
|
262
|
+
# @return [ServiceInstance] ServiceInstance
|
263
|
+
def initialize(version, payload, sid: nil)
|
264
|
+
super(version)
|
265
|
+
|
266
|
+
# Marshaled Properties
|
267
|
+
@properties = {
|
268
|
+
'sid' => payload['sid'],
|
269
|
+
'account_sid' => payload['account_sid'],
|
270
|
+
'friendly_name' => payload['friendly_name'],
|
271
|
+
'code_length' => payload['code_length'].to_i,
|
272
|
+
'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
|
273
|
+
'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
|
274
|
+
'url' => payload['url'],
|
275
|
+
'links' => payload['links'],
|
276
|
+
}
|
277
|
+
|
278
|
+
# Context
|
279
|
+
@instance_context = nil
|
280
|
+
@params = {'sid' => sid || @properties['sid'], }
|
281
|
+
end
|
282
|
+
|
283
|
+
##
|
284
|
+
# Generate an instance context for the instance, the context is capable of
|
285
|
+
# performing various actions. All instance actions are proxied to the context
|
286
|
+
# @return [ServiceContext] ServiceContext for this ServiceInstance
|
287
|
+
def context
|
288
|
+
unless @instance_context
|
289
|
+
@instance_context = ServiceContext.new(@version, @params['sid'], )
|
290
|
+
end
|
291
|
+
@instance_context
|
292
|
+
end
|
293
|
+
|
294
|
+
##
|
295
|
+
# @return [String] A string that uniquely identifies this Service.
|
296
|
+
def sid
|
297
|
+
@properties['sid']
|
298
|
+
end
|
299
|
+
|
300
|
+
##
|
301
|
+
# @return [String] Account Sid.
|
302
|
+
def account_sid
|
303
|
+
@properties['account_sid']
|
304
|
+
end
|
305
|
+
|
306
|
+
##
|
307
|
+
# @return [String] Friendly name of the service
|
308
|
+
def friendly_name
|
309
|
+
@properties['friendly_name']
|
310
|
+
end
|
311
|
+
|
312
|
+
##
|
313
|
+
# @return [String] Length of verification code. Valid values are 4-10
|
314
|
+
def code_length
|
315
|
+
@properties['code_length']
|
316
|
+
end
|
317
|
+
|
318
|
+
##
|
319
|
+
# @return [Time] The date this Service was created
|
320
|
+
def date_created
|
321
|
+
@properties['date_created']
|
322
|
+
end
|
323
|
+
|
324
|
+
##
|
325
|
+
# @return [Time] The date this Service was updated
|
326
|
+
def date_updated
|
327
|
+
@properties['date_updated']
|
328
|
+
end
|
329
|
+
|
330
|
+
##
|
331
|
+
# @return [String] The url
|
332
|
+
def url
|
333
|
+
@properties['url']
|
334
|
+
end
|
335
|
+
|
336
|
+
##
|
337
|
+
# @return [String] The links
|
338
|
+
def links
|
339
|
+
@properties['links']
|
340
|
+
end
|
341
|
+
|
342
|
+
##
|
343
|
+
# Fetch a ServiceInstance
|
344
|
+
# @return [ServiceInstance] Fetched ServiceInstance
|
345
|
+
def fetch
|
346
|
+
context.fetch
|
347
|
+
end
|
348
|
+
|
349
|
+
##
|
350
|
+
# Update the ServiceInstance
|
351
|
+
# @param [String] friendly_name A 1-64 character string with friendly name of
|
352
|
+
# service
|
353
|
+
# @param [String] code_length The length of the verification code to be generated.
|
354
|
+
# Must be an integer value between 4-10
|
355
|
+
# @return [ServiceInstance] Updated ServiceInstance
|
356
|
+
def update(friendly_name: :unset, code_length: :unset)
|
357
|
+
context.update(friendly_name: friendly_name, code_length: code_length, )
|
358
|
+
end
|
359
|
+
|
360
|
+
##
|
361
|
+
# Access the verifications
|
362
|
+
# @return [verifications] verifications
|
363
|
+
def verifications
|
364
|
+
context.verifications
|
365
|
+
end
|
366
|
+
|
367
|
+
##
|
368
|
+
# Access the verification_checks
|
369
|
+
# @return [verification_checks] verification_checks
|
370
|
+
def verification_checks
|
371
|
+
context.verification_checks
|
372
|
+
end
|
373
|
+
|
374
|
+
##
|
375
|
+
# Provide a user friendly representation
|
376
|
+
def to_s
|
377
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
378
|
+
"<Twilio.Verify.V1.ServiceInstance #{values}>"
|
379
|
+
end
|
380
|
+
|
381
|
+
##
|
382
|
+
# Provide a detailed, user friendly representation
|
383
|
+
def inspect
|
384
|
+
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
|
385
|
+
"<Twilio.Verify.V1.ServiceInstance #{values}>"
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|