twilio-ruby 5.37.0 → 5.38.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +32 -9
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +41 -5
  5. data/lib/twilio-ruby/rest/autopilot/v1/assistant.rb +0 -16
  6. data/lib/twilio-ruby/rest/client.rb +0 -7
  7. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +28 -3
  8. data/lib/twilio-ruby/rest/monitor/v1/alert.rb +8 -8
  9. data/lib/twilio-ruby/rest/verify/v2/service.rb +26 -0
  10. data/lib/twilio-ruby/rest/{authy/v1/service/entity.rb → verify/v2/service/webhook.rb} +154 -108
  11. data/lib/twilio-ruby/version.rb +1 -1
  12. data/spec/integration/api/v2010/account/conference/participant_spec.rb +60 -0
  13. data/spec/integration/autopilot/v1/assistant_spec.rb +4 -8
  14. data/spec/integration/conversations/v1/conversation_spec.rb +16 -0
  15. data/spec/integration/verify/v2/service/webhook_spec.rb +262 -0
  16. data/spec/integration/verify/v2/service_spec.rb +8 -4
  17. metadata +5 -22
  18. data/lib/twilio-ruby/rest/authy.rb +0 -55
  19. data/lib/twilio-ruby/rest/authy/v1.rb +0 -59
  20. data/lib/twilio-ruby/rest/authy/v1/form.rb +0 -197
  21. data/lib/twilio-ruby/rest/authy/v1/service.rb +0 -404
  22. data/lib/twilio-ruby/rest/authy/v1/service/entity/factor.rb +0 -500
  23. data/lib/twilio-ruby/rest/authy/v1/service/entity/factor/challenge.rb +0 -494
  24. data/lib/twilio-ruby/rest/autopilot/v1/assistant/export_assistant.rb +0 -222
  25. data/spec/integration/authy/v1/form_spec.rb +0 -48
  26. data/spec/integration/authy/v1/service/entity/factor/challenge_spec.rb +0 -353
  27. data/spec/integration/authy/v1/service/entity/factor_spec.rb +0 -298
  28. data/spec/integration/authy/v1/service/entity_spec.rb +0 -201
  29. data/spec/integration/authy/v1/service_spec.rb +0 -231
  30. data/spec/integration/autopilot/v1/assistant/export_assistant_spec.rb +0 -49
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.37.0
4
+ version: 5.38.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Twilio API Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-10 00:00:00.000000000 Z
11
+ date: 2020-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -320,19 +320,11 @@ files:
320
320
  - lib/twilio-ruby/rest/api/v2010/account/usage/record/yesterday.rb
321
321
  - lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb
322
322
  - lib/twilio-ruby/rest/api/v2010/account/validation_request.rb
323
- - lib/twilio-ruby/rest/authy.rb
324
- - lib/twilio-ruby/rest/authy/v1.rb
325
- - lib/twilio-ruby/rest/authy/v1/form.rb
326
- - lib/twilio-ruby/rest/authy/v1/service.rb
327
- - lib/twilio-ruby/rest/authy/v1/service/entity.rb
328
- - lib/twilio-ruby/rest/authy/v1/service/entity/factor.rb
329
- - lib/twilio-ruby/rest/authy/v1/service/entity/factor/challenge.rb
330
323
  - lib/twilio-ruby/rest/autopilot.rb
331
324
  - lib/twilio-ruby/rest/autopilot/v1.rb
332
325
  - lib/twilio-ruby/rest/autopilot/v1/assistant.rb
333
326
  - lib/twilio-ruby/rest/autopilot/v1/assistant/defaults.rb
334
327
  - lib/twilio-ruby/rest/autopilot/v1/assistant/dialogue.rb
335
- - lib/twilio-ruby/rest/autopilot/v1/assistant/export_assistant.rb
336
328
  - lib/twilio-ruby/rest/autopilot/v1/assistant/field_type.rb
337
329
  - lib/twilio-ruby/rest/autopilot/v1/assistant/field_type/field_value.rb
338
330
  - lib/twilio-ruby/rest/autopilot/v1/assistant/model_build.rb
@@ -642,6 +634,7 @@ files:
642
634
  - lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb
643
635
  - lib/twilio-ruby/rest/verify/v2/service/verification.rb
644
636
  - lib/twilio-ruby/rest/verify/v2/service/verification_check.rb
637
+ - lib/twilio-ruby/rest/verify/v2/service/webhook.rb
645
638
  - lib/twilio-ruby/rest/video.rb
646
639
  - lib/twilio-ruby/rest/video/v1.rb
647
640
  - lib/twilio-ruby/rest/video/v1/composition.rb
@@ -765,14 +758,8 @@ files:
765
758
  - spec/integration/api/v2010/account/usage_spec.rb
766
759
  - spec/integration/api/v2010/account/validation_request_spec.rb
767
760
  - spec/integration/api/v2010/account_spec.rb
768
- - spec/integration/authy/v1/form_spec.rb
769
- - spec/integration/authy/v1/service/entity/factor/challenge_spec.rb
770
- - spec/integration/authy/v1/service/entity/factor_spec.rb
771
- - spec/integration/authy/v1/service/entity_spec.rb
772
- - spec/integration/authy/v1/service_spec.rb
773
761
  - spec/integration/autopilot/v1/assistant/defaults_spec.rb
774
762
  - spec/integration/autopilot/v1/assistant/dialogue_spec.rb
775
- - spec/integration/autopilot/v1/assistant/export_assistant_spec.rb
776
763
  - spec/integration/autopilot/v1/assistant/field_type/field_value_spec.rb
777
764
  - spec/integration/autopilot/v1/assistant/field_type_spec.rb
778
765
  - spec/integration/autopilot/v1/assistant/model_build_spec.rb
@@ -1026,6 +1013,7 @@ files:
1026
1013
  - spec/integration/verify/v2/service/rate_limit_spec.rb
1027
1014
  - spec/integration/verify/v2/service/verification_check_spec.rb
1028
1015
  - spec/integration/verify/v2/service/verification_spec.rb
1016
+ - spec/integration/verify/v2/service/webhook_spec.rb
1029
1017
  - spec/integration/verify/v2/service_spec.rb
1030
1018
  - spec/integration/video/v1/composition_hook_spec.rb
1031
1019
  - spec/integration/video/v1/composition_settings_spec.rb
@@ -1182,14 +1170,8 @@ test_files:
1182
1170
  - spec/integration/api/v2010/account/usage_spec.rb
1183
1171
  - spec/integration/api/v2010/account/validation_request_spec.rb
1184
1172
  - spec/integration/api/v2010/account_spec.rb
1185
- - spec/integration/authy/v1/form_spec.rb
1186
- - spec/integration/authy/v1/service/entity/factor/challenge_spec.rb
1187
- - spec/integration/authy/v1/service/entity/factor_spec.rb
1188
- - spec/integration/authy/v1/service/entity_spec.rb
1189
- - spec/integration/authy/v1/service_spec.rb
1190
1173
  - spec/integration/autopilot/v1/assistant/defaults_spec.rb
1191
1174
  - spec/integration/autopilot/v1/assistant/dialogue_spec.rb
1192
- - spec/integration/autopilot/v1/assistant/export_assistant_spec.rb
1193
1175
  - spec/integration/autopilot/v1/assistant/field_type/field_value_spec.rb
1194
1176
  - spec/integration/autopilot/v1/assistant/field_type_spec.rb
1195
1177
  - spec/integration/autopilot/v1/assistant/model_build_spec.rb
@@ -1443,6 +1425,7 @@ test_files:
1443
1425
  - spec/integration/verify/v2/service/rate_limit_spec.rb
1444
1426
  - spec/integration/verify/v2/service/verification_check_spec.rb
1445
1427
  - spec/integration/verify/v2/service/verification_spec.rb
1428
+ - spec/integration/verify/v2/service/webhook_spec.rb
1446
1429
  - spec/integration/verify/v2/service_spec.rb
1447
1430
  - spec/integration/video/v1/composition_hook_spec.rb
1448
1431
  - spec/integration/video/v1/composition_settings_spec.rb
@@ -1,55 +0,0 @@
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 Authy < Domain
12
- ##
13
- # Initialize the Authy Domain
14
- def initialize(twilio)
15
- super
16
-
17
- @base_url = 'https://authy.twilio.com'
18
- @host = 'authy.twilio.com'
19
- @port = 443
20
-
21
- # Versions
22
- @v1 = nil
23
- end
24
-
25
- ##
26
- # Version v1 of authy
27
- def v1
28
- @v1 ||= V1.new self
29
- end
30
-
31
- ##
32
- # @param [form.FormTypes] form_type The Type of this Form. One of `form-app-push`,
33
- # `form-sms` or `form-totp`.
34
- # @return [Twilio::REST::Authy::V1::FormInstance] if form_type was passed.
35
- # @return [Twilio::REST::Authy::V1::FormList]
36
- def forms(form_type=:unset)
37
- self.v1.forms(form_type)
38
- end
39
-
40
- ##
41
- # @param [String] sid A 34 character string that uniquely identifies this Service.
42
- # @return [Twilio::REST::Authy::V1::ServiceInstance] if sid was passed.
43
- # @return [Twilio::REST::Authy::V1::ServiceList]
44
- def services(sid=:unset)
45
- self.v1.services(sid)
46
- end
47
-
48
- ##
49
- # Provide a user friendly representation
50
- def to_s
51
- '#<Twilio::REST::Authy>'
52
- end
53
- end
54
- end
55
- end
@@ -1,59 +0,0 @@
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 Authy
12
- class V1 < Version
13
- ##
14
- # Initialize the V1 version of Authy
15
- def initialize(domain)
16
- super
17
- @version = 'v1'
18
- @forms = nil
19
- @services = nil
20
- end
21
-
22
- ##
23
- # @param [form.FormTypes] form_type The Type of this Form. One of `form-app-push`,
24
- # `form-sms` or `form-totp`.
25
- # @return [Twilio::REST::Authy::V1::FormContext] if form_type was passed.
26
- # @return [Twilio::REST::Authy::V1::FormList]
27
- def forms(form_type=:unset)
28
- if form_type.nil?
29
- raise ArgumentError, 'form_type cannot be nil'
30
- elsif form_type == :unset
31
- @forms ||= FormList.new self
32
- else
33
- FormContext.new(self, form_type)
34
- end
35
- end
36
-
37
- ##
38
- # @param [String] sid A 34 character string that uniquely identifies this Service.
39
- # @return [Twilio::REST::Authy::V1::ServiceContext] if sid was passed.
40
- # @return [Twilio::REST::Authy::V1::ServiceList]
41
- def services(sid=:unset)
42
- if sid.nil?
43
- raise ArgumentError, 'sid cannot be nil'
44
- elsif sid == :unset
45
- @services ||= ServiceList.new self
46
- else
47
- ServiceContext.new(self, sid)
48
- end
49
- end
50
-
51
- ##
52
- # Provide a user friendly representation
53
- def to_s
54
- '<Twilio::REST::Authy::V1>'
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,197 +0,0 @@
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 Authy < Domain
12
- class V1 < Version
13
- ##
14
- # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
15
- class FormList < ListResource
16
- ##
17
- # Initialize the FormList
18
- # @param [Version] version Version that contains the resource
19
- # @return [FormList] FormList
20
- def initialize(version)
21
- super(version)
22
-
23
- # Path Solution
24
- @solution = {}
25
- end
26
-
27
- ##
28
- # Provide a user friendly representation
29
- def to_s
30
- '#<Twilio.Authy.V1.FormList>'
31
- end
32
- end
33
-
34
- ##
35
- # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
36
- class FormPage < Page
37
- ##
38
- # Initialize the FormPage
39
- # @param [Version] version Version that contains the resource
40
- # @param [Response] response Response from the API
41
- # @param [Hash] solution Path solution for the resource
42
- # @return [FormPage] FormPage
43
- def initialize(version, response, solution)
44
- super(version, response)
45
-
46
- # Path Solution
47
- @solution = solution
48
- end
49
-
50
- ##
51
- # Build an instance of FormInstance
52
- # @param [Hash] payload Payload response from the API
53
- # @return [FormInstance] FormInstance
54
- def get_instance(payload)
55
- FormInstance.new(@version, payload, )
56
- end
57
-
58
- ##
59
- # Provide a user friendly representation
60
- def to_s
61
- '<Twilio.Authy.V1.FormPage>'
62
- end
63
- end
64
-
65
- ##
66
- # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
67
- class FormContext < InstanceContext
68
- ##
69
- # Initialize the FormContext
70
- # @param [Version] version Version that contains the resource
71
- # @param [form.FormTypes] form_type The Type of this Form. One of `form-app-push`,
72
- # `form-sms` or `form-totp`.
73
- # @return [FormContext] FormContext
74
- def initialize(version, form_type)
75
- super(version)
76
-
77
- # Path Solution
78
- @solution = {form_type: form_type, }
79
- @uri = "/Forms/#{@solution[:form_type]}"
80
- end
81
-
82
- ##
83
- # Fetch a FormInstance
84
- # @return [FormInstance] Fetched FormInstance
85
- def fetch
86
- params = Twilio::Values.of({})
87
-
88
- payload = @version.fetch(
89
- 'GET',
90
- @uri,
91
- params,
92
- )
93
-
94
- FormInstance.new(@version, payload, form_type: @solution[:form_type], )
95
- end
96
-
97
- ##
98
- # Provide a user friendly representation
99
- def to_s
100
- context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
101
- "#<Twilio.Authy.V1.FormContext #{context}>"
102
- end
103
-
104
- ##
105
- # Provide a detailed, user friendly representation
106
- def inspect
107
- context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
108
- "#<Twilio.Authy.V1.FormContext #{context}>"
109
- end
110
- end
111
-
112
- ##
113
- # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
114
- class FormInstance < InstanceResource
115
- ##
116
- # Initialize the FormInstance
117
- # @param [Version] version Version that contains the resource
118
- # @param [Hash] payload payload that contains response from Twilio
119
- # @param [form.FormTypes] form_type The Type of this Form. One of `form-app-push`,
120
- # `form-sms` or `form-totp`.
121
- # @return [FormInstance] FormInstance
122
- def initialize(version, payload, form_type: nil)
123
- super(version)
124
-
125
- # Marshaled Properties
126
- @properties = {
127
- 'form_type' => payload['form_type'],
128
- 'forms' => payload['forms'],
129
- 'form_meta' => payload['form_meta'],
130
- 'url' => payload['url'],
131
- }
132
-
133
- # Context
134
- @instance_context = nil
135
- @params = {'form_type' => form_type || @properties['form_type'], }
136
- end
137
-
138
- ##
139
- # Generate an instance context for the instance, the context is capable of
140
- # performing various actions. All instance actions are proxied to the context
141
- # @return [FormContext] FormContext for this FormInstance
142
- def context
143
- unless @instance_context
144
- @instance_context = FormContext.new(@version, @params['form_type'], )
145
- end
146
- @instance_context
147
- end
148
-
149
- ##
150
- # @return [form.FormTypes] The Type of this Form
151
- def form_type
152
- @properties['form_type']
153
- end
154
-
155
- ##
156
- # @return [Hash] Object that contains the available forms for this type.
157
- def forms
158
- @properties['forms']
159
- end
160
-
161
- ##
162
- # @return [Hash] Additional information for the available forms for this type.
163
- def form_meta
164
- @properties['form_meta']
165
- end
166
-
167
- ##
168
- # @return [String] The URL to access the forms for this type.
169
- def url
170
- @properties['url']
171
- end
172
-
173
- ##
174
- # Fetch a FormInstance
175
- # @return [FormInstance] Fetched FormInstance
176
- def fetch
177
- context.fetch
178
- end
179
-
180
- ##
181
- # Provide a user friendly representation
182
- def to_s
183
- values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
184
- "<Twilio.Authy.V1.FormInstance #{values}>"
185
- end
186
-
187
- ##
188
- # Provide a detailed, user friendly representation
189
- def inspect
190
- values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
191
- "<Twilio.Authy.V1.FormInstance #{values}>"
192
- end
193
- end
194
- end
195
- end
196
- end
197
- end
@@ -1,404 +0,0 @@
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 Authy < Domain
12
- class V1 < Version
13
- ##
14
- # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
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 human readable description of this resource, up
32
- # to 64 characters.
33
- # @param [String] push The optional service level push factors configuration. If
34
- # present it must be a json string with the following format:
35
- # {"notify_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "include_date":
36
- # true}
37
- # @return [ServiceInstance] Newly created ServiceInstance
38
- def create(friendly_name: nil, push: :unset)
39
- data = Twilio::Values.of({'FriendlyName' => friendly_name, 'Push' => push, })
40
-
41
- payload = @version.create(
42
- 'POST',
43
- @uri,
44
- data: data
45
- )
46
-
47
- ServiceInstance.new(@version, payload, )
48
- end
49
-
50
- ##
51
- # Lists ServiceInstance records from the API as a list.
52
- # Unlike stream(), this operation is eager and will load `limit` records into
53
- # memory before returning.
54
- # @param [Integer] limit Upper limit for the number of records to return. stream()
55
- # guarantees to never return more than limit. Default is no limit
56
- # @param [Integer] page_size Number of records to fetch per request, when
57
- # not set will use the default value of 50 records. If no page_size is defined
58
- # but a limit is defined, stream() will attempt to read the limit with the most
59
- # efficient page size, i.e. min(limit, 1000)
60
- # @return [Array] Array of up to limit results
61
- def list(limit: nil, page_size: nil)
62
- self.stream(limit: limit, page_size: page_size).entries
63
- end
64
-
65
- ##
66
- # Streams ServiceInstance records from the API as an Enumerable.
67
- # This operation lazily loads records as efficiently as possible until the limit
68
- # is reached.
69
- # @param [Integer] limit Upper limit for the number of records to return. stream()
70
- # guarantees to never return more than limit. Default is no limit.
71
- # @param [Integer] page_size Number of records to fetch per request, when
72
- # not set will use the default value of 50 records. If no page_size is defined
73
- # but a limit is defined, stream() will attempt to read the limit with the most
74
- # efficient page size, i.e. min(limit, 1000)
75
- # @return [Enumerable] Enumerable that will yield up to limit results
76
- def stream(limit: nil, page_size: nil)
77
- limits = @version.read_limits(limit, page_size)
78
-
79
- page = self.page(page_size: limits[:page_size], )
80
-
81
- @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
82
- end
83
-
84
- ##
85
- # When passed a block, yields ServiceInstance records from the API.
86
- # This operation lazily loads records as efficiently as possible until the limit
87
- # is reached.
88
- def each
89
- limits = @version.read_limits
90
-
91
- page = self.page(page_size: limits[:page_size], )
92
-
93
- @version.stream(page,
94
- limit: limits[:limit],
95
- page_limit: limits[:page_limit]).each {|x| yield x}
96
- end
97
-
98
- ##
99
- # Retrieve a single page of ServiceInstance records from the API.
100
- # Request is executed immediately.
101
- # @param [String] page_token PageToken provided by the API
102
- # @param [Integer] page_number Page Number, this value is simply for client state
103
- # @param [Integer] page_size Number of records to return, defaults to 50
104
- # @return [Page] Page of ServiceInstance
105
- def page(page_token: :unset, page_number: :unset, page_size: :unset)
106
- params = Twilio::Values.of({
107
- 'PageToken' => page_token,
108
- 'Page' => page_number,
109
- 'PageSize' => page_size,
110
- })
111
- response = @version.page(
112
- 'GET',
113
- @uri,
114
- params
115
- )
116
- ServicePage.new(@version, response, @solution)
117
- end
118
-
119
- ##
120
- # Retrieve a single page of ServiceInstance records from the API.
121
- # Request is executed immediately.
122
- # @param [String] target_url API-generated URL for the requested results page
123
- # @return [Page] Page of ServiceInstance
124
- def get_page(target_url)
125
- response = @version.domain.request(
126
- 'GET',
127
- target_url
128
- )
129
- ServicePage.new(@version, response, @solution)
130
- end
131
-
132
- ##
133
- # Provide a user friendly representation
134
- def to_s
135
- '#<Twilio.Authy.V1.ServiceList>'
136
- end
137
- end
138
-
139
- ##
140
- # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
141
- class ServicePage < Page
142
- ##
143
- # Initialize the ServicePage
144
- # @param [Version] version Version that contains the resource
145
- # @param [Response] response Response from the API
146
- # @param [Hash] solution Path solution for the resource
147
- # @return [ServicePage] ServicePage
148
- def initialize(version, response, solution)
149
- super(version, response)
150
-
151
- # Path Solution
152
- @solution = solution
153
- end
154
-
155
- ##
156
- # Build an instance of ServiceInstance
157
- # @param [Hash] payload Payload response from the API
158
- # @return [ServiceInstance] ServiceInstance
159
- def get_instance(payload)
160
- ServiceInstance.new(@version, payload, )
161
- end
162
-
163
- ##
164
- # Provide a user friendly representation
165
- def to_s
166
- '<Twilio.Authy.V1.ServicePage>'
167
- end
168
- end
169
-
170
- ##
171
- # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
172
- class ServiceContext < InstanceContext
173
- ##
174
- # Initialize the ServiceContext
175
- # @param [Version] version Version that contains the resource
176
- # @param [String] sid A 34 character string that uniquely identifies this Service.
177
- # @return [ServiceContext] ServiceContext
178
- def initialize(version, sid)
179
- super(version)
180
-
181
- # Path Solution
182
- @solution = {sid: sid, }
183
- @uri = "/Services/#{@solution[:sid]}"
184
-
185
- # Dependents
186
- @entities = nil
187
- end
188
-
189
- ##
190
- # Deletes the ServiceInstance
191
- # @return [Boolean] true if delete succeeds, false otherwise
192
- def delete
193
- @version.delete('delete', @uri)
194
- end
195
-
196
- ##
197
- # Fetch a ServiceInstance
198
- # @return [ServiceInstance] Fetched ServiceInstance
199
- def fetch
200
- params = Twilio::Values.of({})
201
-
202
- payload = @version.fetch(
203
- 'GET',
204
- @uri,
205
- params,
206
- )
207
-
208
- ServiceInstance.new(@version, payload, sid: @solution[:sid], )
209
- end
210
-
211
- ##
212
- # Update the ServiceInstance
213
- # @param [String] friendly_name A human readable description of this resource, up
214
- # to 64 characters.
215
- # @param [String] push The optional service level push factors configuration. If
216
- # present it must be a json string with the following format:
217
- # {"notify_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "include_date":
218
- # true}
219
- # @return [ServiceInstance] Updated ServiceInstance
220
- def update(friendly_name: :unset, push: :unset)
221
- data = Twilio::Values.of({'FriendlyName' => friendly_name, 'Push' => push, })
222
-
223
- payload = @version.update(
224
- 'POST',
225
- @uri,
226
- data: data,
227
- )
228
-
229
- ServiceInstance.new(@version, payload, sid: @solution[:sid], )
230
- end
231
-
232
- ##
233
- # Access the entities
234
- # @return [EntityList]
235
- # @return [EntityContext] if identity was passed.
236
- def entities(identity=:unset)
237
- raise ArgumentError, 'identity cannot be nil' if identity.nil?
238
-
239
- if identity != :unset
240
- return EntityContext.new(@version, @solution[:sid], identity, )
241
- end
242
-
243
- unless @entities
244
- @entities = EntityList.new(@version, service_sid: @solution[:sid], )
245
- end
246
-
247
- @entities
248
- end
249
-
250
- ##
251
- # Provide a user friendly representation
252
- def to_s
253
- context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
254
- "#<Twilio.Authy.V1.ServiceContext #{context}>"
255
- end
256
-
257
- ##
258
- # Provide a detailed, user friendly representation
259
- def inspect
260
- context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
261
- "#<Twilio.Authy.V1.ServiceContext #{context}>"
262
- end
263
- end
264
-
265
- ##
266
- # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
267
- class ServiceInstance < InstanceResource
268
- ##
269
- # Initialize the ServiceInstance
270
- # @param [Version] version Version that contains the resource
271
- # @param [Hash] payload payload that contains response from Twilio
272
- # @param [String] sid A 34 character string that uniquely identifies this Service.
273
- # @return [ServiceInstance] ServiceInstance
274
- def initialize(version, payload, sid: nil)
275
- super(version)
276
-
277
- # Marshaled Properties
278
- @properties = {
279
- 'sid' => payload['sid'],
280
- 'friendly_name' => payload['friendly_name'],
281
- 'account_sid' => payload['account_sid'],
282
- 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
283
- 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
284
- 'url' => payload['url'],
285
- 'links' => payload['links'],
286
- 'configuration' => payload['configuration'],
287
- }
288
-
289
- # Context
290
- @instance_context = nil
291
- @params = {'sid' => sid || @properties['sid'], }
292
- end
293
-
294
- ##
295
- # Generate an instance context for the instance, the context is capable of
296
- # performing various actions. All instance actions are proxied to the context
297
- # @return [ServiceContext] ServiceContext for this ServiceInstance
298
- def context
299
- unless @instance_context
300
- @instance_context = ServiceContext.new(@version, @params['sid'], )
301
- end
302
- @instance_context
303
- end
304
-
305
- ##
306
- # @return [String] A string that uniquely identifies this Service.
307
- def sid
308
- @properties['sid']
309
- end
310
-
311
- ##
312
- # @return [String] A human readable description of this resource.
313
- def friendly_name
314
- @properties['friendly_name']
315
- end
316
-
317
- ##
318
- # @return [String] Account Sid.
319
- def account_sid
320
- @properties['account_sid']
321
- end
322
-
323
- ##
324
- # @return [Time] The date this Service was created
325
- def date_created
326
- @properties['date_created']
327
- end
328
-
329
- ##
330
- # @return [Time] The date this Service was updated
331
- def date_updated
332
- @properties['date_updated']
333
- end
334
-
335
- ##
336
- # @return [String] The URL of this resource.
337
- def url
338
- @properties['url']
339
- end
340
-
341
- ##
342
- # @return [String] Nested resource URLs.
343
- def links
344
- @properties['links']
345
- end
346
-
347
- ##
348
- # @return [Hash] The service level configuration of all the factor types.
349
- def configuration
350
- @properties['configuration']
351
- end
352
-
353
- ##
354
- # Deletes the ServiceInstance
355
- # @return [Boolean] true if delete succeeds, false otherwise
356
- def delete
357
- context.delete
358
- end
359
-
360
- ##
361
- # Fetch a ServiceInstance
362
- # @return [ServiceInstance] Fetched ServiceInstance
363
- def fetch
364
- context.fetch
365
- end
366
-
367
- ##
368
- # Update the ServiceInstance
369
- # @param [String] friendly_name A human readable description of this resource, up
370
- # to 64 characters.
371
- # @param [String] push The optional service level push factors configuration. If
372
- # present it must be a json string with the following format:
373
- # {"notify_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "include_date":
374
- # true}
375
- # @return [ServiceInstance] Updated ServiceInstance
376
- def update(friendly_name: :unset, push: :unset)
377
- context.update(friendly_name: friendly_name, push: push, )
378
- end
379
-
380
- ##
381
- # Access the entities
382
- # @return [entities] entities
383
- def entities
384
- context.entities
385
- end
386
-
387
- ##
388
- # Provide a user friendly representation
389
- def to_s
390
- values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
391
- "<Twilio.Authy.V1.ServiceInstance #{values}>"
392
- end
393
-
394
- ##
395
- # Provide a detailed, user friendly representation
396
- def inspect
397
- values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
398
- "<Twilio.Authy.V1.ServiceInstance #{values}>"
399
- end
400
- end
401
- end
402
- end
403
- end
404
- end