Class: Twilio::REST::Routes::V2::PhoneNumberContext

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

Instance Method Summary collapse

Constructor Details

#initialize(version, phone_number) ⇒ PhoneNumberContext

Initialize the PhoneNumberContext

Parameters:

  • version (Version)

    Version that contains the resource

  • phone_number (String)

    The phone number in E.164 format



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

def initialize(version, phone_number)
    super(version)

    # Path Solution
    @solution = { phone_number: phone_number,  }
    @uri = "/PhoneNumbers/#{@solution[:phone_number]}"

    
end

Instance Method Details

#fetchPhoneNumberInstance

Fetch the PhoneNumberInstance

Returns:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 61

def fetch

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

#inspectObject

Provide a detailed, user friendly representation



116
117
118
119
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 116

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

#to_sObject

Provide a user friendly representation



109
110
111
112
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 109

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

#update(voice_region: :unset, friendly_name: :unset) ⇒ PhoneNumberInstance

Update the PhoneNumberInstance

Parameters:

  • voice_region (String) (defaults to: :unset)

    The Inbound Processing Region used for this phone number for voice

  • friendly_name (String) (defaults to: :unset)

    A human readable description of this resource, up to 64 characters.

Returns:



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 82

def update(
    voice_region: :unset, 
    friendly_name: :unset
)

    data = Twilio::Values.of({
        'VoiceRegion' => voice_region,
        'FriendlyName' => friendly_name,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    PhoneNumberInstance.new(
        @version,
        payload,
        phone_number: @solution[:phone_number],
    )
end