Class: Twilio::REST::Pricing::V2::VoiceList::NumberInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, destination_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.



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 221

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

    # Context
    @instance_context = nil
    @params = { 'destination_number' => destination_number  || @properties['destination_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:



246
247
248
249
250
251
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 246

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

#country ⇒ String

Returns The name of the country.

Returns:

  • (String) —

    The name of the country.



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

def country
    @properties['country']
end

#destination_number ⇒ String

Returns The destination phone number in E.164 format, which consists of a + followed by the country code and subscriber number.

Returns:

  • (String) —

    The destination phone number in E.164 format, which consists of a + followed by the country code and subscriber number.



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

def destination_number
    @properties['destination_number']
end

#fetch(origination_number: :unset) ⇒ NumberInstance

Fetch the NumberInstance

Parameters:

  • origination_number (String) (defaults to: :unset) —

    The origination phone number, in E.164 format, for which to fetch the origin-based voice pricing information. E.164 format consists of a + followed by the country code and subscriber number.

Returns:



305
306
307
308
309
310
311
312
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 305

def fetch(
  origination_number: :unset
)

    context.fetch(
        origination_number: origination_number, 
    )
end

#inbound_call_price ⇒ PricingV2VoiceVoiceNumberInboundCallPrice

Returns:

  • (PricingV2VoiceVoiceNumberInboundCallPrice)


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

def inbound_call_price
    @properties['inbound_call_price']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



323
324
325
326
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 323

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

#iso_country ⇒ String

Returns The ISO country code.

Returns:



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

def iso_country
    @properties['iso_country']
end

#origination_number ⇒ String

Returns The origination phone number in [E.164 format, which consists of a + followed by the country code and subscriber number.

Returns:

  • (String) —

    The origination phone number in [E.164 format, which consists of a + followed by the country code and subscriber number.



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

def origination_number
    @properties['origination_number']
end

#outbound_call_prices ⇒ Array<PricingV2VoiceVoiceNumberOutboundCallPrices>

Returns The list of OutboundCallPriceWithOrigin records.

Returns:



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

def outbound_call_prices
    @properties['outbound_call_prices']
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).



291
292
293
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 291

def price_unit
    @properties['price_unit']
end

#to_s ⇒ Object

Provide a user friendly representation



316
317
318
319
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 316

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

#url ⇒ String

Returns The absolute URL of the resource.

Returns:

  • (String) —

    The absolute URL of the resource.



297
298
299
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 297

def url
    @properties['url']
end