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 SID of the Account that created this ShortCode resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 494

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 SID of the [Account](www.twilio.com/docs/iam/api/account) that created this ShortCode resource.

Returns:



532
533
534
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 532

def 
    @properties['account_sid']
end

#api_versionString

Returns The API version used to start a new TwiML session when an SMS message is sent to this short code.

Returns:

  • (String)

    The API version used to start a new TwiML session when an SMS message is sent to this short code.



538
539
540
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 538

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:



523
524
525
526
527
528
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 523

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

#date_createdTime

Returns The date and time in GMT that this resource was created specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



544
545
546
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 544

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date and time in GMT that this resource was last updated, specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



550
551
552
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 550

def date_updated
    @properties['date_updated']
end

#fetchShortCodeInstance

Fetch the ShortCodeInstance

Returns:



605
606
607
608
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 605

def fetch

    context.fetch
end

#friendly_nameString

Returns A string that you assigned to describe this resource. By default, the ‘FriendlyName` is the short code.

Returns:

  • (String)

    A string that you assigned to describe this resource. By default, the ‘FriendlyName` is the short code.



556
557
558
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 556

def friendly_name
    @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



647
648
649
650
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 647

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.



562
563
564
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 562

def short_code
    @properties['short_code']
end

#sidString

Returns The unique string that that we created to identify this ShortCode resource.

Returns:

  • (String)

    The unique string that that we created to identify this ShortCode resource.



568
569
570
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 568

def sid
    @properties['sid']
end

#sms_fallback_methodString

Returns The HTTP method we use to call the ‘sms_fallback_url`. Can be: `GET` or `POST`.

Returns:

  • (String)

    The HTTP method we use to call the ‘sms_fallback_url`. Can be: `GET` or `POST`.



574
575
576
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 574

def sms_fallback_method
    @properties['sms_fallback_method']
end

#sms_fallback_urlString

Returns The URL that we call if an error occurs while retrieving or executing the TwiML from ‘sms_url`.

Returns:

  • (String)

    The URL that we call if an error occurs while retrieving or executing the TwiML from ‘sms_url`.



580
581
582
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 580

def sms_fallback_url
    @properties['sms_fallback_url']
end

#sms_methodString

Returns The HTTP method we use to call the ‘sms_url`. Can be: `GET` or `POST`.

Returns:

  • (String)

    The HTTP method we use to call the ‘sms_url`. Can be: `GET` or `POST`.



586
587
588
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 586

def sms_method
    @properties['sms_method']
end

#sms_urlString

Returns The URL we call when receiving an incoming SMS message to this short code.

Returns:

  • (String)

    The URL we call when receiving an incoming SMS message to this short code.



592
593
594
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 592

def sms_url
    @properties['sms_url']
end

#to_sObject

Provide a user friendly representation



640
641
642
643
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 640

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 descriptive string that you created to describe this resource. It can be up to 64 characters long. By default, the ‘FriendlyName` is the short code.

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

    The API version to use to start a new TwiML session. Can be: ‘2010-04-01` or `2008-08-01`.

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

    The URL we should call when receiving an incoming SMS message to this short code.

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

    The HTTP method we should use when calling the ‘sms_url`. Can be: `GET` or `POST`.

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

    The URL that we should call if an error occurs while retrieving or executing the TwiML from ‘sms_url`.

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

    The HTTP method that we should use to call the ‘sms_fallback_url`. Can be: `GET` or `POST`.

Returns:



619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 619

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 of this resource, relative to ‘api.twilio.com`.

Returns:

  • (String)

    The URI of this resource, relative to ‘api.twilio.com`.



598
599
600
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 598

def uri
    @properties['uri']
end