Class: Twilio::REST::Pricing::V2::VoiceList::NumberContext

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

Instance Method Summary collapse

Constructor Details

#initialize(version, destination_number) ⇒ NumberContext

Initialize the NumberContext

Parameters:

  • version (Version)

    Version that contains the resource

  • destination_number (String)

    The destination 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.


71
72
73
74
75
76
77
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 71

def initialize(version, destination_number)
  super(version)

  # Path Solution
  @solution = {destination_number: destination_number, }
  @uri = "/Voice/Numbers/#{CGI.escape(@solution[:destination_number]).gsub("+", "%20")}"
end

Instance Method Details

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


86
87
88
89
90
91
92
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 86

def fetch(origination_number: :unset)
  params = Twilio::Values.of({'OriginationNumber' => origination_number, })

  payload = @version.fetch('GET', @uri, params: params)

  NumberInstance.new(@version, payload, destination_number: @solution[:destination_number], )
end

#inspectObject

Provide a detailed, user friendly representation


103
104
105
106
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 103

def inspect
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Pricing.V2.NumberContext #{context}>"
end

#to_sObject

Provide a user friendly representation


96
97
98
99
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 96

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Pricing.V2.NumberContext #{context}>"
end