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](www.twilio.com/docs/iam/api/account) that created the ShortCode resource(s) to update.

  • sid (String)

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



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

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:



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

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    ShortCodeInstance.new(
        @version,
        payload,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
end

#fetch_with_metadataShortCodeInstance

Fetch the ShortCodeInstanceMetadata

Returns:



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 219

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    short_code_instance = ShortCodeInstance.new(
        @version,
        response.body,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
    ShortCodeInstanceMetadata.new(
        @version,
        short_code_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#to_sObject

Provide a user friendly representation



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

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:



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/twilio-ruby/rest/api/v2010/account/short_code.rb', line 251

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,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    ShortCodeInstance.new(
        @version,
        payload,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
end

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

Update the ShortCodeInstanceMetadata

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:



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
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/api/v2010/account/short_code.rb', line 293

def (
  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,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    short_code_instance = ShortCodeInstance.new(
        @version,
        response.body,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
    ShortCodeInstanceMetadata.new(
        @version,
        short_code_instance,
        response.headers,
        response.status_code
    )
end