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


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

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:


143
144
145
146
147
148
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 143

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


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

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


152
153
154
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 152

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:


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

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

#inbound_call_priceString

Returns The InboundCallPrice record.

Returns:

  • (String)

    The InboundCallPrice record


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

def inbound_call_price
  @properties['inbound_call_price']
end

#inspectObject

Provide a detailed, user friendly representation


218
219
220
221
# File 'lib/twilio-ruby/rest/pricing/v2/voice/number.rb', line 218

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


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

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


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

def origination_number
  @properties['origination_number']
end

#outbound_call_pricesArray[String]

Returns The list of OutboundCallPriceWithOrigin records.

Returns:

  • (Array[String])

    The list of OutboundCallPriceWithOrigin records


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

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)


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

def price_unit
  @properties['price_unit']
end

#to_sObject

Provide a user friendly representation


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

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


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

def url
  @properties['url']
end