Class: Twilio::REST::Preview::Sync::ServiceContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/preview/sync/service.rb,
lib/twilio-ruby/rest/preview/sync/service/document.rb,
lib/twilio-ruby/rest/preview/sync/service/sync_map.rb,
lib/twilio-ruby/rest/preview/sync/service/sync_list.rb,
lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb,
lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb,
lib/twilio-ruby/rest/preview/sync/service/document/document_permission.rb,
lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_permission.rb,
lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_permission.rb

Defined Under Namespace

Classes: DocumentContext, DocumentInstance, DocumentList, DocumentPage, SyncListContext, SyncListInstance, SyncListList, SyncListPage, SyncMapContext, SyncMapInstance, SyncMapList, SyncMapPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ServiceContext

Initialize the ServiceContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)


170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/twilio-ruby/rest/preview/sync/service.rb', line 170

def initialize(version, sid)
    super(version)

    # Path Solution
    @solution = { sid: sid,  }
    @uri = "/Services/#{@solution[:sid]}"

    # Dependents
    @sync_maps = nil
    @documents = nil
    @sync_lists = nil
end

Instance Method Details

#deleteBoolean

Delete the ServiceInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



185
186
187
188
189
190
191
192
# File 'lib/twilio-ruby/rest/preview/sync/service.rb', line 185

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    @version.delete('DELETE', @uri, headers: headers)
end

#documents(sid = :unset) ⇒ DocumentList, DocumentContext

Access the documents

Returns:

Raises:

  • (ArgumentError)


271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/twilio-ruby/rest/preview/sync/service.rb', line 271

def documents(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return DocumentContext.new(@version, @solution[:sid],sid )
    end

    unless @documents
        @documents = DocumentList.new(
            @version, service_sid: @solution[:sid], )
    end

 @documents
end

#fetchServiceInstance

Fetch the ServiceInstance

Returns:



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/twilio-ruby/rest/preview/sync/service.rb', line 197

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    ServiceInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



315
316
317
318
# File 'lib/twilio-ruby/rest/preview/sync/service.rb', line 315

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Preview.Sync.ServiceContext #{context}>"
end

#sync_lists(sid = :unset) ⇒ SyncListList, SyncListContext

Access the sync_lists

Returns:

Raises:

  • (ArgumentError)


290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/twilio-ruby/rest/preview/sync/service.rb', line 290

def sync_lists(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return SyncListContext.new(@version, @solution[:sid],sid )
    end

    unless @sync_lists
        @sync_lists = SyncListList.new(
            @version, service_sid: @solution[:sid], )
    end

 @sync_lists
end

#sync_maps(sid = :unset) ⇒ SyncMapList, SyncMapContext

Access the sync_maps

Returns:

Raises:

  • (ArgumentError)


252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/twilio-ruby/rest/preview/sync/service.rb', line 252

def sync_maps(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return SyncMapContext.new(@version, @solution[:sid],sid )
    end

    unless @sync_maps
        @sync_maps = SyncMapList.new(
            @version, service_sid: @solution[:sid], )
    end

 @sync_maps
end

#to_sObject

Provide a user friendly representation



308
309
310
311
# File 'lib/twilio-ruby/rest/preview/sync/service.rb', line 308

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Preview.Sync.ServiceContext #{context}>"
end

#update(webhook_url: :unset, friendly_name: :unset, reachability_webhooks_enabled: :unset, acl_enabled: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

  • webhook_url (String) (defaults to: :unset)
  • friendly_name (String) (defaults to: :unset)
  • reachability_webhooks_enabled (Boolean) (defaults to: :unset)
  • acl_enabled (Boolean) (defaults to: :unset)

Returns:



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/twilio-ruby/rest/preview/sync/service.rb', line 220

def update(
    webhook_url: :unset, 
    friendly_name: :unset, 
    reachability_webhooks_enabled: :unset, 
    acl_enabled: :unset
)

    data = Twilio::Values.of({
        'WebhookUrl' => webhook_url,
        'FriendlyName' => friendly_name,
        'ReachabilityWebhooksEnabled' => reachability_webhooks_enabled,
        'AclEnabled' => acl_enabled,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    ServiceInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end