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

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/pricing/v2/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.



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

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'],
        'terminating_prefix_prices' => payload['terminating_prefix_prices'],
        'originating_call_price' => payload['originating_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:



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

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.



182
183
184
# File 'lib/twilio-ruby/rest/pricing/v2/number.rb', line 182

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:



170
171
172
# File 'lib/twilio-ruby/rest/pricing/v2/number.rb', line 170

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:



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

def fetch(
    origination_number: :unset
)

    context.fetch(
        origination_number: origination_number, 
    )
end

#inspectObject

Provide a detailed, user friendly representation



238
239
240
241
# File 'lib/twilio-ruby/rest/pricing/v2/number.rb', line 238

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:



188
189
190
# File 'lib/twilio-ruby/rest/pricing/v2/number.rb', line 188

def iso_country
    @properties['iso_country']
end

#originating_call_pricePricingV2TrunkingNumberOriginatingCallPrice

Returns:

  • (PricingV2TrunkingNumberOriginatingCallPrice)


200
201
202
# File 'lib/twilio-ruby/rest/pricing/v2/number.rb', line 200

def originating_call_price
    @properties['originating_call_price']
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:



176
177
178
# File 'lib/twilio-ruby/rest/pricing/v2/number.rb', line 176

def origination_number
    @properties['origination_number']
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:



206
207
208
# File 'lib/twilio-ruby/rest/pricing/v2/number.rb', line 206

def price_unit
    @properties['price_unit']
end

#terminating_prefix_pricesArray<PricingV2TrunkingCountryInstanceTerminatingPrefixPrices>

Returns:

  • (Array<PricingV2TrunkingCountryInstanceTerminatingPrefixPrices>)


194
195
196
# File 'lib/twilio-ruby/rest/pricing/v2/number.rb', line 194

def terminating_prefix_prices
    @properties['terminating_prefix_prices']
end

#to_sObject

Provide a user friendly representation



231
232
233
234
# File 'lib/twilio-ruby/rest/pricing/v2/number.rb', line 231

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.



212
213
214
# File 'lib/twilio-ruby/rest/pricing/v2/number.rb', line 212

def url
    @properties['url']
end