Class: Twilio::REST::Api::V2010::AccountContext::ShortCodeContext

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

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid, sid) ⇒ ShortCodeContext

Initialize the ShortCodeContext

Parameters:

  • version (Version)

    Version that contains the resource

  • account_sid (String)

    The SID of the Account that created the ShortCode resource(s) to fetch.

  • sid (String)

    The Twilio-provided string that uniquely identifies the ShortCode resource to fetch


182
183
184
185
186
187
188
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 182

def initialize(version, , sid)
  super(version)

  # Path Solution
  @solution = {account_sid: , sid: sid, }
  @uri = "/Accounts/#{@solution[:account_sid]}/SMS/ShortCodes/#{@solution[:sid]}.json"
end

Instance Method Details

#fetchShortCodeInstance

Fetch the ShortCodeInstance

Returns:


193
194
195
196
197
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 193

def fetch
  payload = @version.fetch('GET', @uri)

  ShortCodeInstance.new(@version, payload, account_sid: @solution[:account_sid], sid: @solution[:sid], )
end

#inspectObject

Provide a detailed, user friendly representation


239
240
241
242
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 239

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

#to_sObject

Provide a user friendly representation


232
233
234
235
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 232

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Api.V2010.ShortCodeContext #{context}>"
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:


215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 215

def update(friendly_name: :unset, api_version: :unset, sms_url: :unset, sms_method: :unset, sms_fallback_url: :unset, sms_fallback_method: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'ApiVersion' => api_version,
      'SmsUrl' => sms_url,
      'SmsMethod' => sms_method,
      'SmsFallbackUrl' => sms_fallback_url,
      'SmsFallbackMethod' => sms_fallback_method,
  })

  payload = @version.update('POST', @uri, data: data)

  ShortCodeInstance.new(@version, payload, account_sid: @solution[:account_sid], sid: @solution[:sid], )
end