Class: Twilio::REST::Routes::V2::PhoneNumberContext
- Inherits:
-
InstanceContext
- Object
- InstanceContext
- Twilio::REST::Routes::V2::PhoneNumberContext
- Defined in:
- lib/twilio-ruby/rest/routes/v2/phone_number.rb
Instance Method Summary collapse
-
#fetch ⇒ PhoneNumberInstance
Fetch the PhoneNumberInstance.
-
#fetch_with_metadata ⇒ PhoneNumberInstance
Fetch the PhoneNumberInstanceMetadata.
-
#initialize(version, phone_number) ⇒ PhoneNumberContext
constructor
Initialize the PhoneNumberContext.
-
#inspect ⇒ Object
Provide a detailed, user friendly representation.
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#update(voice_region: :unset, friendly_name: :unset) ⇒ PhoneNumberInstance
Update the PhoneNumberInstance.
-
#update_with_metadata(voice_region: :unset, friendly_name: :unset) ⇒ PhoneNumberInstance
Update the PhoneNumberInstanceMetadata.
Constructor Details
#initialize(version, phone_number) ⇒ PhoneNumberContext
Initialize the PhoneNumberContext
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 50 def initialize(version, phone_number) super(version) # Path Solution @solution = { phone_number: phone_number, } @uri = "/PhoneNumbers/#{@solution[:phone_number]}" end |
Instance Method Details
#fetch ⇒ PhoneNumberInstance
Fetch the PhoneNumberInstance
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 63 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 |
#fetch_with_metadata ⇒ PhoneNumberInstance
Fetch the PhoneNumberInstanceMetadata
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 82 def headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) response = @version.('GET', @uri, headers: headers) phone_number_instance = PhoneNumberInstance.new( @version, response.body, phone_number: @solution[:phone_number], ) PhoneNumberInstanceMetadata.new( @version, phone_number_instance, response.headers, response.status_code ) end |
#inspect ⇒ Object
Provide a detailed, user friendly representation
178 179 180 181 |
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 178 def inspect context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Routes.V2.PhoneNumberContext #{context}>" end |
#to_s ⇒ Object
Provide a user friendly representation
171 172 173 174 |
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 171 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
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 109 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 |
#update_with_metadata(voice_region: :unset, friendly_name: :unset) ⇒ PhoneNumberInstance
Update the PhoneNumberInstanceMetadata
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 138 def ( 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', }) response = @version.('POST', @uri, data: data, headers: headers) phone_number_instance = PhoneNumberInstance.new( @version, response.body, phone_number: @solution[:phone_number], ) PhoneNumberInstanceMetadata.new( @version, phone_number_instance, response.headers, response.status_code ) end |