Class: Twilio::REST::Lookups::V1::PhoneNumberInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, phone_number: nil) ⇒ PhoneNumberInstance

Initialize the PhoneNumberInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • phone_number (String) (defaults to: nil)

    The phone_number



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 121

def initialize(version, payload, phone_number: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'caller_name' => payload['caller_name'],
      'country_code' => payload['country_code'],
      'phone_number' => payload['phone_number'],
      'national_format' => payload['national_format'],
      'carrier' => payload['carrier'],
      'add_ons' => payload['add_ons'],
      'url' => payload['url'],
  }

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

Instance Method Details

#add_onsHash

Returns The add_ons.

Returns:

  • (Hash)

    The add_ons



188
189
190
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 188

def add_ons
  @properties['add_ons']
end

#caller_nameString

Returns The caller_name.

Returns:

  • (String)

    The caller_name



158
159
160
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 158

def caller_name
  @properties['caller_name']
end

#carrierString

Returns The carrier.

Returns:

  • (String)

    The carrier



182
183
184
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 182

def carrier
  @properties['carrier']
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:



146
147
148
149
150
151
152
153
154
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 146

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

#country_codeString

Returns The country_code.

Returns:

  • (String)

    The country_code



164
165
166
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 164

def country_code
  @properties['country_code']
end

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



205
206
207
208
209
210
211
212
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 205

def fetch(country_code: :unset, type: :unset, add_ons: :unset, add_ons_data: :unset)
  context.fetch(
      country_code: country_code,
      type: type,
      add_ons: add_ons,
      add_ons_data: add_ons_data,
  )
end

#inspectObject

Provide a detailed, user friendly representation



223
224
225
226
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 223

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

#national_formatString

Returns The national_format.

Returns:

  • (String)

    The national_format



176
177
178
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 176

def national_format
  @properties['national_format']
end

#phone_numberString

Returns The phone_number.

Returns:

  • (String)

    The phone_number



170
171
172
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 170

def phone_number
  @properties['phone_number']
end

#to_sObject

Provide a user friendly representation



216
217
218
219
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 216

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

#urlString

Returns The url.

Returns:

  • (String)

    The url



194
195
196
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 194

def url
  @properties['url']
end