Class: Twilio::REST::Pricing::V2::NumberContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/pricing/v2/number.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, destination_number) ⇒ NumberContext

Initialize the NumberContext

Parameters:

  • version (Version)

    Version that contains the resource

  • destination_number (String)

    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.



49
50
51
52
53
54
55
56
57
# File 'lib/twilio-ruby/rest/pricing/v2/number.rb', line 49

def initialize(version, destination_number)
    super(version)

    # Path Solution
    @solution = { destination_number: destination_number,  }
    @uri = "/Trunking/Numbers/#{CGI.escape(@solution[:destination_number]).gsub("+", "%20")}"

    
end

Instance Method Details

#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:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/twilio-ruby/rest/pricing/v2/number.rb', line 62

def fetch(
    origination_number: :unset
)

    params = Twilio::Values.of({
        'OriginationNumber' => origination_number,
    })
    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, params: params, headers: headers)
    NumberInstance.new(
        @version,
        payload,
        destination_number: @solution[:destination_number],
    )
end

#inspectObject

Provide a detailed, user friendly representation



93
94
95
96
# File 'lib/twilio-ruby/rest/pricing/v2/number.rb', line 93

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Pricing.V2.NumberContext #{context}>"
end

#to_sObject

Provide a user friendly representation



86
87
88
89
# File 'lib/twilio-ruby/rest/pricing/v2/number.rb', line 86

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Pricing.V2.NumberContext #{context}>"
end