Class: Twilio::REST::Pricing::V1::VoiceList::NumberInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/pricing/v1/voice/number.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, number: nil) ⇒ NumberInstance

Initialize the NumberInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • number (String) (defaults to: nil)

    The phone number to fetch.


107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 107

def initialize(version, payload, number: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'number' => payload['number'],
      'country' => payload['country'],
      'iso_country' => payload['iso_country'],
      'outbound_call_price' => payload['outbound_call_price'],
      'inbound_call_price' => payload['inbound_call_price'],
      'price_unit' => payload['price_unit'],
      'url' => payload['url'],
  }

  # Context
  @instance_context = nil
  @params = {'number' => number || @properties['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:


130
131
132
133
134
135
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 130

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

#countryString

Returns The name of the country.

Returns:

  • (String)

    The name of the country


145
146
147
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 145

def country
  @properties['country']
end

#fetchNumberInstance

Fetch the NumberInstance

Returns:


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

def fetch
  context.fetch
end

#inbound_call_priceString

Returns The InboundCallPrice record.

Returns:

  • (String)

    The InboundCallPrice record


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

def inbound_call_price
  @properties['inbound_call_price']
end

#inspectObject

Provide a detailed, user friendly representation


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

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

#iso_countryString

Returns The ISO country code.

Returns:

  • (String)

    The ISO country code


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

def iso_country
  @properties['iso_country']
end

#numberString

Returns The phone number.

Returns:

  • (String)

    The phone number


139
140
141
# File 'lib/twilio-ruby/rest/pricing/v1/voice/number.rb', line 139

def number
  @properties['number']
end

#outbound_call_priceString

Returns The OutboundCallPrice record.

Returns:

  • (String)

    The OutboundCallPrice record


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

def outbound_call_price
  @properties['outbound_call_price']
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)


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

def price_unit
  @properties['price_unit']
end

#to_sObject

Provide a user friendly representation


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

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

#urlString

Returns The absolute URL of the resource.

Returns:

  • (String)

    The absolute URL of the resource


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

def url
  @properties['url']
end