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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +13 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb +28 -13
  5. data/lib/twilio-ruby/rest/api/v2010/account/conference/recording.rb +14 -6
  6. data/lib/twilio-ruby/rest/client.rb +7 -0
  7. data/lib/twilio-ruby/rest/preview.rb +28 -8
  8. data/lib/twilio-ruby/rest/preview/authy.rb +43 -0
  9. data/lib/twilio-ruby/rest/preview/authy/service.rb +364 -0
  10. data/lib/twilio-ruby/rest/preview/authy/service/entity.rb +326 -0
  11. data/lib/twilio-ruby/rest/preview/permissions.rb +35 -0
  12. data/lib/twilio-ruby/rest/preview/permissions/voice_permission.rb +131 -0
  13. data/lib/twilio-ruby/rest/preview/permissions/voice_permission/bulk_country_update.rb +132 -0
  14. data/lib/twilio-ruby/rest/preview/permissions/voice_permission/country.rb +391 -0
  15. data/lib/twilio-ruby/rest/preview/permissions/voice_permission/country/highrisk_special_prefix.rb +192 -0
  16. data/lib/twilio-ruby/rest/preview/permissions/voice_permission/settings.rb +197 -0
  17. data/lib/twilio-ruby/rest/preview/understand/assistant.rb +12 -6
  18. data/lib/twilio-ruby/rest/preview/understand/assistant/intent/intent_actions.rb +13 -11
  19. data/lib/twilio-ruby/rest/pricing/v2/voice.rb +17 -0
  20. data/lib/twilio-ruby/rest/pricing/v2/voice/number.rb +214 -0
  21. data/lib/twilio-ruby/rest/verify.rb +46 -0
  22. data/lib/twilio-ruby/rest/verify/v1.rb +43 -0
  23. data/lib/twilio-ruby/rest/verify/v1/service.rb +391 -0
  24. data/lib/twilio-ruby/rest/verify/v1/service/verification.rb +185 -0
  25. data/lib/twilio-ruby/rest/verify/v1/service/verification_check.rb +182 -0
  26. data/lib/twilio-ruby/version.rb +1 -1
  27. data/spec/integration/preview/authy/service/entity_spec.rb +173 -0
  28. data/spec/integration/preview/authy/service_spec.rb +201 -0
  29. data/spec/integration/preview/permissions/voice_permission/bulk_country_update_spec.rb +45 -0
  30. data/spec/integration/preview/permissions/voice_permission/country/highrisk_special_prefix_spec.rb +61 -0
  31. data/spec/integration/preview/permissions/voice_permission/country_spec.rb +112 -0
  32. data/spec/integration/preview/permissions/voice_permission/settings_spec.rb +77 -0
  33. data/spec/integration/preview/permissions/voice_permission_spec.rb +12 -0
  34. data/spec/integration/pricing/v2/voice/number_spec.rb +62 -0
  35. data/spec/integration/verify/v1/service/verification_check_spec.rb +52 -0
  36. data/spec/integration/verify/v1/service/verification_spec.rb +52 -0
  37. data/spec/integration/verify/v1/service_spec.rb +185 -0
  38. metadata +39 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1067889a70a6093ed700c5b18b1bdb9905974d9a
4
- data.tar.gz: 179b4ad89db463e0dfa97eac08064c58dfa449c0
3
+ metadata.gz: f4ce16d26c62514428db1b1c37f62028e0f7ee7a
4
+ data.tar.gz: a56c95b413a42d40568a9b9bff97324106ae5eec
5
5
  SHA512:
6
- metadata.gz: e8ab39d6718adfb193361c499e862c2783502692568a6244d8424c0da54195074a954bcb1791248bf5987d1eca03cc3178fc518b84b6623850f69da0973b0a14
7
- data.tar.gz: bcf88f2120c5373af54170bc6831e58d44ab67081e43b355883302df1ed145365f0cd6ac92ac0fa16237af0cf466ef1d0e5b614a67930d243b8b92240321f259
6
+ metadata.gz: d26d08ff46decea3088152be428ea457a0a32b8f479f17948527821e4b102869ecbb2b27e4ffe5ad7c49702f34822a2e475b2e3f4c28575c131649769220a9d3
7
+ data.tar.gz: 447f2b394fab6112de58c3784f85bac91f128777592b40f90336d10164d8a7b30595fb46e946e34e41161b52491d754e71b74a88a57106246ef21d949390fc56
data/CHANGES.md CHANGED
@@ -1,6 +1,19 @@
1
1
  twilio-ruby changelog
2
2
  =====================
3
3
 
4
+ [2018-09-20] Version 5.13.0
5
+ ----------------------------
6
+ **Preview**
7
+ - Add `Form` resource to Authy preview given a `form_type`
8
+ - Add Authy initial api-definitions in the 4 main resources: Services, Entities, Factors, Challenges
9
+
10
+ **Pricing**
11
+ - add voice_numbers resource (v2)
12
+
13
+ **Verify**
14
+ - Move from preview to beta **(breaking change)**
15
+
16
+
4
17
  [2018-08-31] Version 5.12.4
5
18
  ----------------------------
6
19
  **Library**
data/README.md CHANGED
@@ -27,13 +27,13 @@ in-line code documentation here in the library.
27
27
  To install using [Bundler][bundler] grab the latest stable version:
28
28
 
29
29
  ```ruby
30
- gem 'twilio-ruby', '~> 5.12.4'
30
+ gem 'twilio-ruby', '~> 5.13.0'
31
31
  ```
32
32
 
33
33
  To manually install `twilio-ruby` via [Rubygems][rubygems] simply gem install:
34
34
 
35
35
  ```bash
36
- gem install twilio-ruby -v 5.12.4
36
+ gem install twilio-ruby -v 5.13.0
37
37
  ```
38
38
 
39
39
  To build and install the development branch yourself from the latest source:
@@ -33,15 +33,22 @@ module Twilio
33
33
  ##
34
34
  # Retrieve a single page of RecordingInstance records from the API.
35
35
  # Request is executed immediately.
36
- # @param [String] recording_status_callback_event The
37
- # recording_status_callback_event
38
- # @param [String] recording_status_callback The recording_status_callback
39
- # @param [String] recording_status_callback_method The
40
- # recording_status_callback_method
41
- # @param [String] trim Possible values `trim-silence` or `do-not-trim`.
36
+ # @param [String] recording_status_callback_event The recording status changes
37
+ # that should generate a request to the URL specified in RecordingStatusCallback.
38
+ # Possible values: `in-progress`, `completed`, `failed`. To specify multiple
39
+ # values separate them with a space. Defaults to `completed`.
40
+ # @param [String] recording_status_callback The URL which Twilio will make its GET
41
+ # or POST request to for the recording events specified in parameter
42
+ # RecordingStatusCallbackEvent.
43
+ # @param [String] recording_status_callback_method The HTTP method Twilio should
44
+ # use when making a request to the RecordingStatusCallback URL. Possible values:
45
+ # `GET`, `POST`. Defaults to `POST`.
46
+ # @param [String] trim Possible values: `trim-silence` or `do-not-trim`.
42
47
  # `trim-silence` will trim the silence from the beginning and end of the
43
48
  # recording. `do-not-trim` will not trim the silence. Defaults to `do-not-trim`
44
- # @param [String] recording_channels The recording_channels
49
+ # @param [String] recording_channels Possible values: `mono` or `dual`. `mono`
50
+ # records all parties of your call into one channel. `dual` records a 2 party call
51
+ # into separate channels. Defaults to `mono`.
45
52
  # @return [RecordingInstance] Newly created RecordingInstance
46
53
  def create(recording_status_callback_event: :unset, recording_status_callback: :unset, recording_status_callback_method: :unset, trim: :unset, recording_channels: :unset)
47
54
  data = Twilio::Values.of({
@@ -231,10 +238,14 @@ module Twilio
231
238
  ##
232
239
  # Update the RecordingInstance
233
240
  # @param [recording.Status] status The status to change the recording to.
234
- # Possible values : stopped, paused, in-progress
241
+ # Possible values: `stopped`, `paused`, `in-progress`
242
+ # @param [String] pause_behavior Possible values: `skip` or `silence`. `skip` will
243
+ # result in no recording at all during the pause period. `silence` will replace
244
+ # the actual audio of the call with silence during the pause period. Defaults to
245
+ # `silence`
235
246
  # @return [RecordingInstance] Updated RecordingInstance
236
- def update(status: nil)
237
- data = Twilio::Values.of({'Status' => status, })
247
+ def update(status: nil, pause_behavior: :unset)
248
+ data = Twilio::Values.of({'Status' => status, 'PauseBehavior' => pause_behavior, })
238
249
 
239
250
  payload = @version.update(
240
251
  'POST',
@@ -449,10 +460,14 @@ module Twilio
449
460
  ##
450
461
  # Update the RecordingInstance
451
462
  # @param [recording.Status] status The status to change the recording to.
452
- # Possible values : stopped, paused, in-progress
463
+ # Possible values: `stopped`, `paused`, `in-progress`
464
+ # @param [String] pause_behavior Possible values: `skip` or `silence`. `skip` will
465
+ # result in no recording at all during the pause period. `silence` will replace
466
+ # the actual audio of the call with silence during the pause period. Defaults to
467
+ # `silence`
453
468
  # @return [RecordingInstance] Updated RecordingInstance
454
- def update(status: nil)
455
- context.update(status: status, )
469
+ def update(status: nil, pause_behavior: :unset)
470
+ context.update(status: status, pause_behavior: pause_behavior, )
456
471
  end
457
472
 
458
473
  ##
@@ -196,10 +196,14 @@ module Twilio
196
196
  ##
197
197
  # Update the RecordingInstance
198
198
  # @param [recording.Status] status The status to change the recording to.
199
- # Possible values : stopped, paused, in-progress
199
+ # Possible values: `stopped`, `paused`, `in-progress`
200
+ # @param [String] pause_behavior Possible values: `skip` or `silence`. `skip` will
201
+ # result in no recording at all during the pause period. `silence` will replace
202
+ # the actual audio of the call with silence during the pause period. Defaults to
203
+ # `silence`
200
204
  # @return [RecordingInstance] Updated RecordingInstance
201
- def update(status: nil)
202
- data = Twilio::Values.of({'Status' => status, })
205
+ def update(status: nil, pause_behavior: :unset)
206
+ data = Twilio::Values.of({'Status' => status, 'PauseBehavior' => pause_behavior, })
203
207
 
204
208
  payload = @version.update(
205
209
  'POST',
@@ -418,10 +422,14 @@ module Twilio
418
422
  ##
419
423
  # Update the RecordingInstance
420
424
  # @param [recording.Status] status The status to change the recording to.
421
- # Possible values : stopped, paused, in-progress
425
+ # Possible values: `stopped`, `paused`, `in-progress`
426
+ # @param [String] pause_behavior Possible values: `skip` or `silence`. `skip` will
427
+ # result in no recording at all during the pause period. `silence` will replace
428
+ # the actual audio of the call with silence during the pause period. Defaults to
429
+ # `silence`
422
430
  # @return [RecordingInstance] Updated RecordingInstance
423
- def update(status: nil)
424
- context.update(status: status, )
431
+ def update(status: nil, pause_behavior: :unset)
432
+ context.update(status: status, pause_behavior: pause_behavior, )
425
433
  end
426
434
 
427
435
  ##
@@ -43,6 +43,7 @@ module Twilio
43
43
  @wireless = nil
44
44
  @sync = nil
45
45
  @studio = nil
46
+ @verify = nil
46
47
  end
47
48
 
48
49
  ##
@@ -201,6 +202,12 @@ module Twilio
201
202
  @studio ||= Studio.new self
202
203
  end
203
204
 
205
+ ##
206
+ # Access the Verify Twilio Domain
207
+ def verify
208
+ @verify ||= Verify.new self
209
+ end
210
+
204
211
  ##
205
212
  # @param [String] sid A 34 character string that uniquely identifies this address.
206
213
  # @return [Twilio::REST::Api::V2010::AccountContext::AddressInstance] if sid was passed.
@@ -19,6 +19,7 @@ module Twilio
19
19
  @port = 443
20
20
 
21
21
  # Versions
22
+ @authy = nil
22
23
  @bulk_exports = nil
23
24
  @deployed_devices = nil
24
25
  @hosted_numbers = nil
@@ -27,6 +28,13 @@ module Twilio
27
28
  @sync = nil
28
29
  @understand = nil
29
30
  @wireless = nil
31
+ @permissions = nil
32
+ end
33
+
34
+ ##
35
+ # Version authy of preview
36
+ def authy
37
+ @authy ||= Authy.new self
30
38
  end
31
39
 
32
40
  ##
@@ -77,6 +85,20 @@ module Twilio
77
85
  @wireless ||= Wireless.new self
78
86
  end
79
87
 
88
+ ##
89
+ # Version permissions of preview
90
+ def permissions
91
+ @permissions ||= Permissions.new self
92
+ end
93
+
94
+ ##
95
+ # @param [String] sid The sid
96
+ # @return [Twilio::REST::Preview::Sync::ServiceInstance] if sid was passed.
97
+ # @return [Twilio::REST::Preview::Sync::ServiceList]
98
+ def services(sid=:unset)
99
+ self.sync.services(sid)
100
+ end
101
+
80
102
  ##
81
103
  # @param [String] resource_type The resource_type
82
104
  # @return [Twilio::REST::Preview::BulkExports::ExportInstance] if resource_type was passed.
@@ -138,14 +160,6 @@ module Twilio
138
160
  self.marketplace.available_add_ons(sid)
139
161
  end
140
162
 
141
- ##
142
- # @param [String] sid The sid
143
- # @return [Twilio::REST::Preview::Sync::ServiceInstance] if sid was passed.
144
- # @return [Twilio::REST::Preview::Sync::ServiceList]
145
- def services(sid=:unset)
146
- self.sync.services(sid)
147
- end
148
-
149
163
  ##
150
164
  # @param [String] sid A 34 character string that uniquely identifies this
151
165
  # resource.
@@ -179,6 +193,12 @@ module Twilio
179
193
  self.wireless.sims(sid)
180
194
  end
181
195
 
196
+ ##
197
+ # @return [Twilio::REST::Preview::Permissions::VoicePermissionInstance]
198
+ def voice_permissions
199
+ self.permissions.voice_permissions()
200
+ end
201
+
182
202
  ##
183
203
  # Provide a user friendly representation
184
204
  def to_s
@@ -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 Preview
12
+ class Authy < Version
13
+ ##
14
+ # Initialize the Authy version of Preview
15
+ def initialize(domain)
16
+ super
17
+ @version = 'Authy'
18
+ @services = nil
19
+ end
20
+
21
+ ##
22
+ # @param [String] sid A 34 character string that uniquely identifies this Service.
23
+ # @return [Twilio::REST::Preview::Authy::ServiceContext] if sid was passed.
24
+ # @return [Twilio::REST::Preview::Authy::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::Preview::Authy>'
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,364 @@
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 Preview < Domain
12
+ class Authy < 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
+ # @return [ServiceInstance] Newly created ServiceInstance
34
+ def create(friendly_name: nil)
35
+ data = Twilio::Values.of({'FriendlyName' => friendly_name, })
36
+
37
+ payload = @version.create(
38
+ 'POST',
39
+ @uri,
40
+ data: data
41
+ )
42
+
43
+ ServiceInstance.new(@version, payload, )
44
+ end
45
+
46
+ ##
47
+ # Lists ServiceInstance records from the API as a list.
48
+ # Unlike stream(), this operation is eager and will load `limit` records into
49
+ # memory before returning.
50
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
51
+ # guarantees to never return more than limit. Default is no limit
52
+ # @param [Integer] page_size Number of records to fetch per request, when
53
+ # not set will use the default value of 50 records. If no page_size is defined
54
+ # but a limit is defined, stream() will attempt to read the limit with the most
55
+ # efficient page size, i.e. min(limit, 1000)
56
+ # @return [Array] Array of up to limit results
57
+ def list(limit: nil, page_size: nil)
58
+ self.stream(limit: limit, page_size: page_size).entries
59
+ end
60
+
61
+ ##
62
+ # Streams ServiceInstance records from the API as an Enumerable.
63
+ # This operation lazily loads records as efficiently as possible until the limit
64
+ # is reached.
65
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
66
+ # guarantees to never return more than limit. Default is no limit.
67
+ # @param [Integer] page_size Number of records to fetch per request, when
68
+ # not set will use the default value of 50 records. If no page_size is defined
69
+ # but a limit is defined, stream() will attempt to read the limit with the most
70
+ # efficient page size, i.e. min(limit, 1000)
71
+ # @return [Enumerable] Enumerable that will yield up to limit results
72
+ def stream(limit: nil, page_size: nil)
73
+ limits = @version.read_limits(limit, page_size)
74
+
75
+ page = self.page(page_size: limits[:page_size], )
76
+
77
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
78
+ end
79
+
80
+ ##
81
+ # When passed a block, yields ServiceInstance records from the API.
82
+ # This operation lazily loads records as efficiently as possible until the limit
83
+ # is reached.
84
+ def each
85
+ limits = @version.read_limits
86
+
87
+ page = self.page(page_size: limits[:page_size], )
88
+
89
+ @version.stream(page,
90
+ limit: limits[:limit],
91
+ page_limit: limits[:page_limit]).each {|x| yield x}
92
+ end
93
+
94
+ ##
95
+ # Retrieve a single page of ServiceInstance records from the API.
96
+ # Request is executed immediately.
97
+ # @param [String] page_token PageToken provided by the API
98
+ # @param [Integer] page_number Page Number, this value is simply for client state
99
+ # @param [Integer] page_size Number of records to return, defaults to 50
100
+ # @return [Page] Page of ServiceInstance
101
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
102
+ params = Twilio::Values.of({
103
+ 'PageToken' => page_token,
104
+ 'Page' => page_number,
105
+ 'PageSize' => page_size,
106
+ })
107
+ response = @version.page(
108
+ 'GET',
109
+ @uri,
110
+ params
111
+ )
112
+ ServicePage.new(@version, response, @solution)
113
+ end
114
+
115
+ ##
116
+ # Retrieve a single page of ServiceInstance records from the API.
117
+ # Request is executed immediately.
118
+ # @param [String] target_url API-generated URL for the requested results page
119
+ # @return [Page] Page of ServiceInstance
120
+ def get_page(target_url)
121
+ response = @version.domain.request(
122
+ 'GET',
123
+ target_url
124
+ )
125
+ ServicePage.new(@version, response, @solution)
126
+ end
127
+
128
+ ##
129
+ # Provide a user friendly representation
130
+ def to_s
131
+ '#<Twilio.Preview.Authy.ServiceList>'
132
+ end
133
+ end
134
+
135
+ ##
136
+ # 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.
137
+ class ServicePage < Page
138
+ ##
139
+ # Initialize the ServicePage
140
+ # @param [Version] version Version that contains the resource
141
+ # @param [Response] response Response from the API
142
+ # @param [Hash] solution Path solution for the resource
143
+ # @return [ServicePage] ServicePage
144
+ def initialize(version, response, solution)
145
+ super(version, response)
146
+
147
+ # Path Solution
148
+ @solution = solution
149
+ end
150
+
151
+ ##
152
+ # Build an instance of ServiceInstance
153
+ # @param [Hash] payload Payload response from the API
154
+ # @return [ServiceInstance] ServiceInstance
155
+ def get_instance(payload)
156
+ ServiceInstance.new(@version, payload, )
157
+ end
158
+
159
+ ##
160
+ # Provide a user friendly representation
161
+ def to_s
162
+ '<Twilio.Preview.Authy.ServicePage>'
163
+ end
164
+ end
165
+
166
+ ##
167
+ # 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.
168
+ class ServiceContext < InstanceContext
169
+ ##
170
+ # Initialize the ServiceContext
171
+ # @param [Version] version Version that contains the resource
172
+ # @param [String] sid A 34 character string that uniquely identifies this Service.
173
+ # @return [ServiceContext] ServiceContext
174
+ def initialize(version, sid)
175
+ super(version)
176
+
177
+ # Path Solution
178
+ @solution = {sid: sid, }
179
+ @uri = "/Services/#{@solution[:sid]}"
180
+
181
+ # Dependents
182
+ @entities = nil
183
+ end
184
+
185
+ ##
186
+ # Fetch a ServiceInstance
187
+ # @return [ServiceInstance] Fetched ServiceInstance
188
+ def fetch
189
+ params = Twilio::Values.of({})
190
+
191
+ payload = @version.fetch(
192
+ 'GET',
193
+ @uri,
194
+ params,
195
+ )
196
+
197
+ ServiceInstance.new(@version, payload, sid: @solution[:sid], )
198
+ end
199
+
200
+ ##
201
+ # Update the ServiceInstance
202
+ # @param [String] friendly_name A human readable description of this resource, up
203
+ # to 64 characters.
204
+ # @return [ServiceInstance] Updated ServiceInstance
205
+ def update(friendly_name: :unset)
206
+ data = Twilio::Values.of({'FriendlyName' => friendly_name, })
207
+
208
+ payload = @version.update(
209
+ 'POST',
210
+ @uri,
211
+ data: data,
212
+ )
213
+
214
+ ServiceInstance.new(@version, payload, sid: @solution[:sid], )
215
+ end
216
+
217
+ ##
218
+ # Access the entities
219
+ # @return [EntityList]
220
+ # @return [EntityContext] if identity was passed.
221
+ def entities(identity=:unset)
222
+ raise ArgumentError, 'identity cannot be nil' if identity.nil?
223
+
224
+ if identity != :unset
225
+ return EntityContext.new(@version, @solution[:sid], identity, )
226
+ end
227
+
228
+ unless @entities
229
+ @entities = EntityList.new(@version, service_sid: @solution[:sid], )
230
+ end
231
+
232
+ @entities
233
+ end
234
+
235
+ ##
236
+ # Provide a user friendly representation
237
+ def to_s
238
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
239
+ "#<Twilio.Preview.Authy.ServiceContext #{context}>"
240
+ end
241
+ end
242
+
243
+ ##
244
+ # 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.
245
+ class ServiceInstance < InstanceResource
246
+ ##
247
+ # Initialize the ServiceInstance
248
+ # @param [Version] version Version that contains the resource
249
+ # @param [Hash] payload payload that contains response from Twilio
250
+ # @param [String] sid A 34 character string that uniquely identifies this Service.
251
+ # @return [ServiceInstance] ServiceInstance
252
+ def initialize(version, payload, sid: nil)
253
+ super(version)
254
+
255
+ # Marshaled Properties
256
+ @properties = {
257
+ 'sid' => payload['sid'],
258
+ 'friendly_name' => payload['friendly_name'],
259
+ 'account_sid' => payload['account_sid'],
260
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
261
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
262
+ 'url' => payload['url'],
263
+ 'links' => payload['links'],
264
+ }
265
+
266
+ # Context
267
+ @instance_context = nil
268
+ @params = {'sid' => sid || @properties['sid'], }
269
+ end
270
+
271
+ ##
272
+ # Generate an instance context for the instance, the context is capable of
273
+ # performing various actions. All instance actions are proxied to the context
274
+ # @return [ServiceContext] ServiceContext for this ServiceInstance
275
+ def context
276
+ unless @instance_context
277
+ @instance_context = ServiceContext.new(@version, @params['sid'], )
278
+ end
279
+ @instance_context
280
+ end
281
+
282
+ ##
283
+ # @return [String] A string that uniquely identifies this Service.
284
+ def sid
285
+ @properties['sid']
286
+ end
287
+
288
+ ##
289
+ # @return [String] A human readable description of this resource.
290
+ def friendly_name
291
+ @properties['friendly_name']
292
+ end
293
+
294
+ ##
295
+ # @return [String] Account Sid.
296
+ def account_sid
297
+ @properties['account_sid']
298
+ end
299
+
300
+ ##
301
+ # @return [Time] The date this Service was created
302
+ def date_created
303
+ @properties['date_created']
304
+ end
305
+
306
+ ##
307
+ # @return [Time] The date this Service was updated
308
+ def date_updated
309
+ @properties['date_updated']
310
+ end
311
+
312
+ ##
313
+ # @return [String] The URL of this resource.
314
+ def url
315
+ @properties['url']
316
+ end
317
+
318
+ ##
319
+ # @return [String] Nested resource URLs.
320
+ def links
321
+ @properties['links']
322
+ end
323
+
324
+ ##
325
+ # Fetch a ServiceInstance
326
+ # @return [ServiceInstance] Fetched ServiceInstance
327
+ def fetch
328
+ context.fetch
329
+ end
330
+
331
+ ##
332
+ # Update the ServiceInstance
333
+ # @param [String] friendly_name A human readable description of this resource, up
334
+ # to 64 characters.
335
+ # @return [ServiceInstance] Updated ServiceInstance
336
+ def update(friendly_name: :unset)
337
+ context.update(friendly_name: friendly_name, )
338
+ end
339
+
340
+ ##
341
+ # Access the entities
342
+ # @return [entities] entities
343
+ def entities
344
+ context.entities
345
+ end
346
+
347
+ ##
348
+ # Provide a user friendly representation
349
+ def to_s
350
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
351
+ "<Twilio.Preview.Authy.ServiceInstance #{values}>"
352
+ end
353
+
354
+ ##
355
+ # Provide a detailed, user friendly representation
356
+ def inspect
357
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
358
+ "<Twilio.Preview.Authy.ServiceInstance #{values}>"
359
+ end
360
+ end
361
+ end
362
+ end
363
+ end
364
+ end