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 account_sid

  • sid (String)

    The short-code Sid that uniquely identifies this resource



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

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 a ShortCodeInstance

Returns:



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 197

def fetch
  params = Twilio::Values.of({})

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

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

#to_sObject

Provide a user friendly representation



256
257
258
259
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 256

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 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:



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 230

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