Class: Twilio::REST::Api::V2010::AccountContext::ShortCodeInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/short_code.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, account_sid: nil, sid: nil) ⇒ ShortCodeInstance

Initialize the ShortCodeInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String) (defaults to: nil)

    The unique id of the Account that owns this short code.

  • sid (String) (defaults to: nil)

    The short-code Sid that uniquely identifies this resource



250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 250

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

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'api_version' => payload['api_version'],
      'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
      'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
      'friendly_name' => payload['friendly_name'],
      'short_code' => payload['short_code'],
      'sid' => payload['sid'],
      'sms_fallback_method' => payload['sms_fallback_method'],
      'sms_fallback_url' => payload['sms_fallback_url'],
      'sms_method' => payload['sms_method'],
      'sms_url' => payload['sms_url'],
      'uri' => payload['uri'],
  }

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

Instance Method Details

#account_sidString

Returns The unique sid that identifies this account.

Returns:

  • (String)

    The unique sid that identifies this account



287
288
289
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 287

def 
  @properties['account_sid']
end

#api_versionString

Returns The API version to use.

Returns:

  • (String)

    The API version to use



293
294
295
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 293

def api_version
  @properties['api_version']
end

#contextShortCodeContext

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

Returns:



278
279
280
281
282
283
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 278

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

#date_createdTime

Returns The date this resource was created.

Returns:

  • (Time)

    The date this resource was created



299
300
301
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 299

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date this resource was last updated.

Returns:

  • (Time)

    The date this resource was last updated



305
306
307
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 305

def date_updated
  @properties['date_updated']
end

#fetchShortCodeInstance

Fetch a ShortCodeInstance

Returns:



360
361
362
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 360

def fetch
  context.fetch
end

#friendly_nameString

Returns A human readable description of this resource.

Returns:

  • (String)

    A human readable description of this resource



311
312
313
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 311

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



400
401
402
403
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 400

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

#short_codeString

Returns The short code. e.g., 894546.

Returns:

  • (String)

    The short code. e.g., 894546.



317
318
319
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 317

def short_code
  @properties['short_code']
end

#sidString

Returns A string that uniquely identifies this short-codes.

Returns:

  • (String)

    A string that uniquely identifies this short-codes



323
324
325
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 323

def sid
  @properties['sid']
end

#sms_fallback_methodString

Returns HTTP method Twilio will use with sms fallback url.

Returns:

  • (String)

    HTTP method Twilio will use with sms fallback url



329
330
331
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 329

def sms_fallback_method
  @properties['sms_fallback_method']
end

#sms_fallback_urlString

Returns URL Twilio will request if an error occurs in executing TwiML.

Returns:

  • (String)

    URL Twilio will request if an error occurs in executing TwiML



335
336
337
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 335

def sms_fallback_url
  @properties['sms_fallback_url']
end

#sms_methodString

Returns HTTP method to use when requesting the sms url.

Returns:

  • (String)

    HTTP method to use when requesting the sms url



341
342
343
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 341

def sms_method
  @properties['sms_method']
end

#sms_urlString

Returns URL Twilio will request when receiving an SMS.

Returns:

  • (String)

    URL Twilio will request when receiving an SMS



347
348
349
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 347

def sms_url
  @properties['sms_url']
end

#to_sObject

Provide a user friendly representation



393
394
395
396
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 393

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

#update(friendly_name: :unset, api_version: :unset, sms_url: :unset, sms_method: :unset, sms_fallback_url: :unset, sms_fallback_method: :unset) ⇒ ShortCodeInstance

Update the ShortCodeInstance

Parameters:

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

    A human readable descriptive text for this resource, up to 64 characters long. By default, the ‘FriendlyName` is just the short code.

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

    SMSs to this short code will start a new TwiML session with this API version.

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

    The URL Twilio will request when receiving an incoming SMS message to this short code.

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

    The HTTP method Twilio will use when making requests to the ‘SmsUrl`. Either `GET` or `POST`.

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

    The URL that Twilio will request if an error occurs retrieving or executing the TwiML from ‘SmsUrl`.

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

    The HTTP method Twilio will use when requesting the above URL. Either ‘GET` or `POST`.

Returns:



380
381
382
383
384
385
386
387
388
389
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 380

def update(friendly_name: :unset, api_version: :unset, sms_url: :unset, sms_method: :unset, sms_fallback_url: :unset, sms_fallback_method: :unset)
  context.update(
      friendly_name: friendly_name,
      api_version: api_version,
      sms_url: sms_url,
      sms_method: sms_method,
      sms_fallback_url: sms_fallback_url,
      sms_fallback_method: sms_fallback_method,
  )
end

#uriString

Returns The URI for this resource.

Returns:

  • (String)

    The URI for this resource



353
354
355
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 353

def uri
  @properties['uri']
end