Class: Twilio::REST::Trunking::V1::TrunkContext::PhoneNumberInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, trunk_sid: nil, sid: nil) ⇒ PhoneNumberInstance

Initialize the PhoneNumberInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • trunk_sid (String) (defaults to: nil)

    The SID of the Trunk that handles calls to the phone number. If a ‘trunk_sid` is present, we ignore all of the voice URLs and voice applications and use those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa.

  • sid (String) (defaults to: nil)

    The unique string that we created to identify the PhoneNumber resource to fetch.



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 233

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

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'address_requirements' => payload['address_requirements'],
      'api_version' => payload['api_version'],
      'beta' => payload['beta'],
      'capabilities' => payload['capabilities'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'friendly_name' => payload['friendly_name'],
      'links' => payload['links'],
      'phone_number' => payload['phone_number'],
      'sid' => payload['sid'],
      'sms_application_sid' => payload['sms_application_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'],
      'status_callback' => payload['status_callback'],
      'status_callback_method' => payload['status_callback_method'],
      'trunk_sid' => payload['trunk_sid'],
      'url' => payload['url'],
      'voice_application_sid' => payload['voice_application_sid'],
      'voice_caller_id_lookup' => payload['voice_caller_id_lookup'],
      'voice_fallback_method' => payload['voice_fallback_method'],
      'voice_fallback_url' => payload['voice_fallback_url'],
      'voice_method' => payload['voice_method'],
      'voice_url' => payload['voice_url'],
  }

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

Instance Method Details

#account_sidString

Returns The SID of the Account that created the resource.

Returns:

  • (String)

    The SID of the Account that created the resource



284
285
286
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 284

def 
  @properties['account_sid']
end

#address_requirementsphone_number.AddressRequirement

Returns Whether the phone number requires an Address registered with Twilio.

Returns:

  • (phone_number.AddressRequirement)

    Whether the phone number requires an Address registered with Twilio



290
291
292
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 290

def address_requirements
  @properties['address_requirements']
end

#api_versionString

Returns The API version used to start a new TwiML session.

Returns:

  • (String)

    The API version used to start a new TwiML session



296
297
298
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 296

def api_version
  @properties['api_version']
end

#betaBoolean

Returns Whether the phone number is new to the Twilio platform.

Returns:

  • (Boolean)

    Whether the phone number is new to the Twilio platform



302
303
304
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 302

def beta
  @properties['beta']
end

#capabilitiesHash

Returns Indicate if a phone can receive calls or messages.

Returns:

  • (Hash)

    Indicate if a phone can receive calls or messages



308
309
310
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 308

def capabilities
  @properties['capabilities']
end

#contextPhoneNumberContext

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

Returns:



275
276
277
278
279
280
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 275

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

#date_createdTime

Returns The RFC 2822 date and time in GMT when the resource was created.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the resource was created



314
315
316
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 314

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The RFC 2822 date and time in GMT when the resource was last updated.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the resource was last updated



320
321
322
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 320

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the PhoneNumberInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



448
449
450
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 448

def delete
  context.delete
end

#fetchPhoneNumberInstance

Fetch a PhoneNumberInstance

Returns:



441
442
443
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 441

def fetch
  context.fetch
end

#friendly_nameString

Returns The string that you assigned to describe the resource.

Returns:

  • (String)

    The string that you assigned to describe the resource



326
327
328
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 326

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



461
462
463
464
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 461

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

Returns The URLs of related resources.

Returns:

  • (String)

    The URLs of related resources



332
333
334
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 332

def links
  @properties['links']
end

#phone_numberString

Returns The phone number in E.164 format.

Returns:

  • (String)

    The phone number in E.164 format



338
339
340
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 338

def phone_number
  @properties['phone_number']
end

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource



344
345
346
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 344

def sid
  @properties['sid']
end

#sms_application_sidString

Returns The SID of the application that handles SMS messages sent to the phone number.

Returns:

  • (String)

    The SID of the application that handles SMS messages sent to the phone number



350
351
352
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 350

def sms_application_sid
  @properties['sms_application_sid']
end

#sms_fallback_methodString

Returns The HTTP method used with sms_fallback_url.

Returns:

  • (String)

    The HTTP method used with sms_fallback_url



356
357
358
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 356

def sms_fallback_method
  @properties['sms_fallback_method']
end

#sms_fallback_urlString

Returns The URL that we call when an error occurs while retrieving or executing the TwiML.

Returns:

  • (String)

    The URL that we call when an error occurs while retrieving or executing the TwiML



362
363
364
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 362

def sms_fallback_url
  @properties['sms_fallback_url']
end

#sms_methodString

Returns The HTTP method to use with sms_url.

Returns:

  • (String)

    The HTTP method to use with sms_url



368
369
370
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 368

def sms_method
  @properties['sms_method']
end

#sms_urlString

Returns The URL we call when the phone number receives an incoming SMS message.

Returns:

  • (String)

    The URL we call when the phone number receives an incoming SMS message



374
375
376
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 374

def sms_url
  @properties['sms_url']
end

#status_callbackString

Returns The URL to send status information to your application.

Returns:

  • (String)

    The URL to send status information to your application



380
381
382
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 380

def status_callback
  @properties['status_callback']
end

#status_callback_methodString

Returns The HTTP method we use to call status_callback.

Returns:

  • (String)

    The HTTP method we use to call status_callback



386
387
388
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 386

def status_callback_method
  @properties['status_callback_method']
end

#to_sObject

Provide a user friendly representation



454
455
456
457
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 454

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

#trunk_sidString

Returns The SID of the Trunk that handles calls to the phone number.

Returns:

  • (String)

    The SID of the Trunk that handles calls to the phone number



392
393
394
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 392

def trunk_sid
  @properties['trunk_sid']
end

#urlString

Returns The absolute URL of the resource.

Returns:

  • (String)

    The absolute URL of the resource



398
399
400
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 398

def url
  @properties['url']
end

#voice_application_sidString

Returns The SID of the application that handles calls to the phone number.

Returns:

  • (String)

    The SID of the application that handles calls to the phone number



404
405
406
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 404

def voice_application_sid
  @properties['voice_application_sid']
end

#voice_caller_id_lookupBoolean

Returns Whether to lookup the caller’s name.

Returns:

  • (Boolean)

    Whether to lookup the caller’s name



410
411
412
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 410

def voice_caller_id_lookup
  @properties['voice_caller_id_lookup']
end

#voice_fallback_methodString

Returns The HTTP method that we use to call voice_fallback_url.

Returns:

  • (String)

    The HTTP method that we use to call voice_fallback_url



416
417
418
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 416

def voice_fallback_method
  @properties['voice_fallback_method']
end

#voice_fallback_urlString

Returns The URL we call when an error occurs in TwiML.

Returns:

  • (String)

    The URL we call when an error occurs in TwiML



422
423
424
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 422

def voice_fallback_url
  @properties['voice_fallback_url']
end

#voice_methodString

Returns The HTTP method used with the voice_url.

Returns:

  • (String)

    The HTTP method used with the voice_url



428
429
430
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 428

def voice_method
  @properties['voice_method']
end

#voice_urlString

Returns The URL we call when the phone number receives a call.

Returns:

  • (String)

    The URL we call when the phone number receives a call



434
435
436
# File 'lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb', line 434

def voice_url
  @properties['voice_url']
end