Class: Twilio::REST::Pricing::V1::VoiceList::NumberInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/pricing/v1/voice/number.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, number: nil) ⇒ NumberInstance

Initialize the NumberInstance

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 Number resource.

  • sid (String) —

    The SID of the Call resource to fetch.



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 209

def initialize(version, payload , number: nil)
    super(version)
    
    
    # Marshaled Properties
    @properties = { 
        'number' => payload['number'],
        'country' => payload['country'],
        'iso_country' => payload['iso_country'],
        'outbound_call_price' => payload['outbound_call_price'],
        'inbound_call_price' => payload['inbound_call_price'],
        'price_unit' => payload['price_unit'],
        'url' => payload['url'],
    }

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

Instance Method Details

#context ⇒ NumberContext

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

Returns:



233
234
235
236
237
238
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 233

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

#country ⇒ String

Returns The name of the country.

Returns:

  • (String) —

    The name of the country.



248
249
250
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 248

def country
    @properties['country']
end

#fetch ⇒ NumberInstance

Fetch the NumberInstance

Returns:



285
286
287
288
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 285

def fetch

    context.fetch
end

#inbound_call_price ⇒ PricingV1VoiceVoiceNumberInboundCallPrice

Returns:

  • (PricingV1VoiceVoiceNumberInboundCallPrice)


266
267
268
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 266

def inbound_call_price
    @properties['inbound_call_price']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



299
300
301
302
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 299

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

#iso_country ⇒ String

Returns The ISO country code.

Returns:



254
255
256
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 254

def iso_country
    @properties['iso_country']
end

#number ⇒ String

Returns The phone number.

Returns:

  • (String) —

    The phone number.



242
243
244
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 242

def number
    @properties['number']
end

#outbound_call_price ⇒ PricingV1VoiceVoiceNumberOutboundCallPrice

Returns:

  • (PricingV1VoiceVoiceNumberOutboundCallPrice)


260
261
262
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 260

def outbound_call_price
    @properties['outbound_call_price']
end

#price_unit ⇒ String

Returns The currency in which prices are measured, specified in ISO 4127 format (e.g. usd, eur, jpy).

Returns:

  • (String) —

    The currency in which prices are measured, specified in ISO 4127 format (e.g. usd, eur, jpy).



272
273
274
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 272

def price_unit
    @properties['price_unit']
end

#to_s ⇒ Object

Provide a user friendly representation



292
293
294
295
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 292

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

#url ⇒ String

Returns The absolute URL of the resource.

Returns:

  • (String) —

    The absolute URL of the resource.



278
279
280
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 278

def url
    @properties['url']
end