Class: Twilio::REST::Lookups::V1::PhoneNumberContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/lookups/v1/phone_number.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, phone_number) ⇒ PhoneNumberContext

Initialize the PhoneNumberContext

Parameters:

  • version (Version)

    Version that contains the resource

  • phone_number (String)

    The phone_number



68
69
70
71
72
73
74
75
76
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 68

def initialize(version, phone_number)
  super(version)

  # Path Solution
  @solution = {
      phone_number: phone_number,
  }
  @uri = "/PhoneNumbers/#{@solution[:phone_number]}"
end

Instance Method Details

#fetch(country_code: :unset, type: :unset, add_ons: :unset, add_ons_data: :unset) ⇒ PhoneNumberInstance

Fetch a PhoneNumberInstance

Parameters:

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

    The country_code

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

    The type

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

    The add_ons

  • add_ons_data (Hash) (defaults to: :unset)

    The add_ons_data

Returns:



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 85

def fetch(country_code: :unset, type: :unset, add_ons: :unset, add_ons_data: :unset)
  params = Twilio::Values.of({
      'CountryCode' => country_code,
      'Type' => type,
      'AddOns' => add_ons,
  })

  params.merge!(Twilio.prefixed_collapsible_map(add_ons_data, 'AddOns'))
  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  PhoneNumberInstance.new(
      @version,
      payload,
      phone_number: @solution[:phone_number],
  )
end

#to_sObject

Provide a user friendly representation



108
109
110
111
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 108

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Lookups.V1.PhoneNumberContext #{context}>"
end