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

  • destination_number (String) (defaults to: nil)

    The destination phone number, in [E.164](www.twilio.com/docs/glossary/what-e164) 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.



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 123

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

#contextNumberContext

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

Returns:



147
148
149
150
151
152
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 147

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

#countryString

Returns The name of the country.

Returns:

  • (String)

    The name of the country



168
169
170
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 168

def country
  @properties['country']
end

#destination_numberString

Returns The destination phone number, in E.164 format.

Returns:

  • (String)

    The destination phone number, in E.164 format



156
157
158
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 156

def destination_number
  @properties['destination_number']
end

#fetch(origination_number: :unset) ⇒ NumberInstance

Fetch a NumberInstance

Parameters:

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

    The origination phone number, in [E.164](www.twilio.com/docs/glossary/what-e164) 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:



209
210
211
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 209

def fetch(origination_number: :unset)
  context.fetch(origination_number: origination_number, )
end

#inbound_call_priceString

Returns The InboundCallPrice record.

Returns:

  • (String)

    The InboundCallPrice record



186
187
188
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 186

def inbound_call_price
  @properties['inbound_call_price']
end

#inspectObject

Provide a detailed, user friendly representation



222
223
224
225
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 222

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

#iso_countryString

Returns The ISO country code.

Returns:

  • (String)

    The ISO country code



174
175
176
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 174

def iso_country
  @properties['iso_country']
end

#origination_numberString

Returns The origination phone number, in E.164 format.

Returns:

  • (String)

    The origination phone number, in E.164 format



162
163
164
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 162

def origination_number
  @properties['origination_number']
end

#outbound_call_pricesString

Returns The list of OutboundCallPriceWithOrigin records.

Returns:

  • (String)

    The list of OutboundCallPriceWithOrigin records



180
181
182
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 180

def outbound_call_prices
  @properties['outbound_call_prices']
end

#price_unitString

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

Returns:

  • (String)

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



192
193
194
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 192

def price_unit
  @properties['price_unit']
end

#to_sObject

Provide a user friendly representation



215
216
217
218
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 215

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

#urlString

Returns The absolute URL of the resource.

Returns:

  • (String)

    The absolute URL of the resource



198
199
200
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 198

def url
  @properties['url']
end