Class: Twilio::REST::Api::V2010::AccountContext::AddressContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/address.rb,
lib/twilio-ruby/rest/api/v2010/account/address/dependent_phone_number.rb

Defined Under Namespace

Classes: DependentPhoneNumberInstance, DependentPhoneNumberList, DependentPhoneNumberPage

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid, sid) ⇒ AddressContext

Initialize the AddressContext



216
217
218
219
220
221
222
223
224
225
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 216

def initialize(version, , sid)
    super(version)

    # Path Solution
    @solution = { account_sid: , sid: sid,  }
    @uri = "/Accounts/#{@solution[:account_sid]}/Addresses/#{@solution[:sid]}.json"

    # Dependents
    @dependent_phone_numbers = nil
end

Instance Method Details

#deleteBoolean

Delete the AddressInstance



229
230
231
232
233
234
235
236
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 229

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    @version.delete('DELETE', @uri, headers: headers)
end

#dependent_phone_numbersDependentPhoneNumberList, DependentPhoneNumberContext

Access the dependent_phone_numbers



313
314
315
316
317
318
319
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 313

def dependent_phone_numbers
  unless @dependent_phone_numbers
    @dependent_phone_numbers = DependentPhoneNumberList.new(
            @version, account_sid: @solution[:account_sid], address_sid: @solution[:sid], )
  end
  @dependent_phone_numbers
end

#fetchAddressInstance

Fetch the AddressInstance



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 241

def fetch

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

#inspectObject

Provide a detailed, user friendly representation



330
331
332
333
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 330

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

#to_sObject

Provide a user friendly representation



323
324
325
326
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 323

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

#update(friendly_name: :unset, customer_name: :unset, street: :unset, city: :unset, region: :unset, postal_code: :unset, emergency_enabled: :unset, auto_correct_address: :unset, street_secondary: :unset) ⇒ AddressInstance

Update the AddressInstance



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 270

def update(
    friendly_name: :unset, 
    customer_name: :unset, 
    street: :unset, 
    city: :unset, 
    region: :unset, 
    postal_code: :unset, 
    emergency_enabled: :unset, 
    auto_correct_address: :unset, 
    street_secondary: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'CustomerName' => customer_name,
        'Street' => street,
        'City' => city,
        'Region' => region,
        'PostalCode' => postal_code,
        'EmergencyEnabled' => emergency_enabled,
        'AutoCorrectAddress' => auto_correct_address,
        'StreetSecondary' => street_secondary,
    })

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