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.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 139

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:



163
164
165
166
167
168
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 163

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.



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

def country
    @properties['country']
end

#destination_numberString

Returns The destination phone number in [E.164](www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.

Returns:



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

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](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:



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

def fetch(
    origination_number: :unset
)

    context.fetch(
        origination_number: origination_number, 
    )
end

#inbound_call_pricePricingV2VoiceVoiceNumberInboundCallPrice

Returns:

  • (PricingV2VoiceVoiceNumberInboundCallPrice)


202
203
204
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 202

def inbound_call_price
    @properties['inbound_call_price']
end

#inspectObject

Provide a detailed, user friendly representation



240
241
242
243
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 240

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

#iso_countryString

Returns The [ISO country code](en.wikipedia.org/wiki/ISO_3166-1_alpha-2).

Returns:



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

def iso_country
    @properties['iso_country']
end

#origination_numberString

Returns The origination phone number in [[E.164](www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.

Returns:



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

def origination_number
    @properties['origination_number']
end

#outbound_call_pricesArray<PricingV2VoiceVoiceNumberOutboundCallPrices>

Returns The list of [OutboundCallPriceWithOrigin](www.twilio.com/docs/voice/pricing#outbound-call-price-with-origin) records.

Returns:



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

def outbound_call_prices
    @properties['outbound_call_prices']
end

#price_unitString

Returns The currency in which prices are measured, specified in [ISO 4127](www.iso.org/iso/home/standards/currency_codes.htm) format (e.g. ‘usd`, `eur`, `jpy`).

Returns:



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

def price_unit
    @properties['price_unit']
end

#to_sObject

Provide a user friendly representation



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

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.



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

def url
    @properties['url']
end