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



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 146

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



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

def add_ons
    @properties['add_ons']
end

#caller_nameHash



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

def caller_name
    @properties['caller_name']
end

#carrierHash



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

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



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

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

#country_codeString



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

def country_code
    @properties['country_code']
end

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

Fetch the PhoneNumberInstance



225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 225

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



249
250
251
252
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 249

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

#national_formatString



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

def national_format
    @properties['national_format']
end

#phone_numberString



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

def phone_number
    @properties['phone_number']
end

#to_sObject

Provide a user friendly representation



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

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

#urlString



214
215
216
# File 'lib/twilio-ruby/rest/lookups/v1/phone_number.rb', line 214

def url
    @properties['url']
end