Class: Twilio::REST::Preview::Proxy::ServiceInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/preview/proxy/service.rb

Overview

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 [email protected].

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, sid: nil) ⇒ ServiceInstance

Initialize the ServiceInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • sid (String) (defaults to: nil)

    A 34 character string that uniquely identifies this Service.



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 311

def initialize(version, payload, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'friendly_name' => payload['friendly_name'],
      'account_sid' => payload['account_sid'],
      'auto_create' => payload['auto_create'],
      'callback_url' => payload['callback_url'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'url' => payload['url'],
      'links' => payload['links'],
  }

  # Context
  @instance_context = nil
  @params = {'sid' => sid || @properties['sid'], }
end

Instance Method Details

#account_sidString

Returns Account Sid.

Returns:

  • (String)

    Account Sid.



357
358
359
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 357

def 
  @properties['account_sid']
end

#auto_createBoolean

Returns Boolean flag specifying whether to auto-create threads.

Returns:

  • (Boolean)

    Boolean flag specifying whether to auto-create threads.



363
364
365
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 363

def auto_create
  @properties['auto_create']
end

#callback_urlString

Returns URL Twilio will request for callbacks.

Returns:

  • (String)

    URL Twilio will request for callbacks.



369
370
371
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 369

def callback_url
  @properties['callback_url']
end

#contextServiceContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



336
337
338
339
340
341
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 336

def context
  unless @instance_context
    @instance_context = ServiceContext.new(@version, @params['sid'], )
  end
  @instance_context
end

#date_createdTime

Returns The date this Service was created.

Returns:

  • (Time)

    The date this Service was created



375
376
377
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 375

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date this Service was updated.

Returns:

  • (Time)

    The date this Service was updated



381
382
383
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 381

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the ServiceInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



407
408
409
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 407

def delete
  context.delete
end

#fetchServiceInstance

Fetch a ServiceInstance

Returns:



400
401
402
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 400

def fetch
  context.fetch
end

#friendly_nameString

Returns A human readable description of this resource.

Returns:

  • (String)

    A human readable description of this resource



351
352
353
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 351

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



454
455
456
457
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 454

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Preview.Proxy.ServiceInstance #{values}>"
end

Returns Nested resource URLs.

Returns:

  • (String)

    Nested resource URLs.



393
394
395
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 393

def links
  @properties['links']
end

#phone_numbersphone_numbers

Access the phone_numbers

Returns:



434
435
436
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 434

def phone_numbers
  context.phone_numbers
end

#sessionssessions

Access the sessions

Returns:



427
428
429
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 427

def sessions
  context.sessions
end

#short_codesshort_codes

Access the short_codes

Returns:



441
442
443
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 441

def short_codes
  context.short_codes
end

#sidString

Returns A string that uniquely identifies this Service.

Returns:

  • (String)

    A string that uniquely identifies this Service.



345
346
347
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 345

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



447
448
449
450
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 447

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Preview.Proxy.ServiceInstance #{values}>"
end

#update(friendly_name: :unset, auto_create: :unset, callback_url: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

  • friendly_name (String) (defaults to: :unset)

    A human readable description of this resource, up to 64 characters.

  • auto_create (Boolean) (defaults to: :unset)

    Boolean flag specifying whether to create threads when a user communticates out of band.

  • callback_url (String) (defaults to: :unset)

    The URL Twilio will request for callback notifications.

Returns:



420
421
422
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 420

def update(friendly_name: :unset, auto_create: :unset, callback_url: :unset)
  context.update(friendly_name: friendly_name, auto_create: auto_create, callback_url: callback_url, )
end

#urlString

Returns The URL of this resource.

Returns:

  • (String)

    The URL of this resource.



387
388
389
# File 'lib/twilio-ruby/rest/preview/proxy/service.rb', line 387

def url
  @properties['url']
end