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

  • account_sid (String)

    The SID of the Account that created this PhoneNumber resource.

  • sid (String)

    The SID of the Call resource to fetch.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 139

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 A JSON string with the results of the Add-ons you specified in the ‘add_ons` parameters. For the format of the object, see [Using Add-ons](www.twilio.com/docs/add-ons).

Returns:

  • (Hash)

    A JSON string with the results of the Add-ons you specified in the ‘add_ons` parameters. For the format of the object, see [Using Add-ons](www.twilio.com/docs/add-ons).



201
202
203
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 201

def add_ons
    @properties['add_ons']
end

#caller_nameHash

Returns The name of the phone number’s owner. If ‘null`, that information was not available.

Returns:

  • (Hash)

    The name of the phone number’s owner. If ‘null`, that information was not available.



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

def caller_name
    @properties['caller_name']
end

#carrierHash

Returns The telecom company that provides the phone number.

Returns:

  • (Hash)

    The telecom company that provides the phone number.



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

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:



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

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

#country_codeString

Returns The [ISO country code](en.wikipedia.org/wiki/ISO_3166-1_alpha-2) for the phone number.

Returns:



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

def country_code
    @properties['country_code']
end

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

Fetch the PhoneNumberInstance

Parameters:

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

    The [ISO country code](en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number to fetch. This is used to specify the country when the phone number is provided in a national format.

  • type (Array[String]) (defaults to: :unset)

    The type of information to return. Can be: ‘carrier` or `caller-name`. The default is null. Carrier information costs $0.005 per phone number looked up. Caller Name information is currently available only in the US and costs $0.01 per phone number looked up. To retrieve both types on information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value.

  • add_ons (Array[String]) (defaults to: :unset)

    The ‘unique_name` of an Add-on you would like to invoke. Can be the `unique_name` of an Add-on that is installed on your account. You can specify multiple instances of this parameter to invoke multiple Add-ons. For more information about Add-ons, see the [Add-ons documentation](www.twilio.com/docs/add-ons).

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

    Data specific to the add-on you would like to invoke. The content and format of this value depends on the add-on.

Returns:



218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 218

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



242
243
244
245
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 242

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

#national_formatString

Returns The phone number, in national format.

Returns:

  • (String)

    The phone number, in national format.



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

def national_format
    @properties['national_format']
end

#phone_numberString

Returns The phone number in [E.164](www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.

Returns:



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

def phone_number
    @properties['phone_number']
end

#to_sObject

Provide a user friendly representation



235
236
237
238
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 235

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

#urlString

Returns The absolute URL of the resource.

Returns:

  • (String)

    The absolute URL of the resource.



207
208
209
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 207

def url
    @properties['url']
end