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, DependentPhoneNumberListResponse, DependentPhoneNumberPage, DependentPhoneNumberPageMetadata

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid, sid) ⇒ AddressContext

Initialize the AddressContext

Parameters:

  • version (Version)

    Version that contains the resource

  • account_sid (String)

    The SID of the [Account](www.twilio.com/docs/iam/api/account) that is responsible for the Address resource to update.

  • sid (String)

    The Twilio-provided string that uniquely identifies the Address resource to update.



306
307
308
309
310
311
312
313
314
315
316
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 306

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

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



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

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the AddressInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 333

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      address_instance = AddressInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      AddressInstanceMetadata.new(@version, address_instance, response.headers, response.status_code)
end

#dependent_phone_numbersDependentPhoneNumberList, DependentPhoneNumberContext

Access the dependent_phone_numbers

Returns:



507
508
509
510
511
512
513
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 507

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

Returns:



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 352

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

#fetch_with_metadataAddressInstance

Fetch the AddressInstanceMetadata

Returns:



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 372

def 

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

#inspectObject

Provide a detailed, user friendly representation



524
525
526
527
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 524

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

#to_sObject

Provide a user friendly representation



517
518
519
520
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 517

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

Parameters:

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

    A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses.

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

    The name to associate with the address.

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

    The number and street address of the address.

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

    The city of the address.

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

    The state or region of the address.

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

    The postal code of the address.

  • emergency_enabled (Boolean) (defaults to: :unset)

    Whether to enable emergency calling on the address. Can be: true or false.

  • auto_correct_address (Boolean) (defaults to: :unset)

    Whether we should automatically correct the address. Can be: true or false and the default is true. If empty or true, we will correct the address you provide if necessary. If false, we won’t alter the address you provide.

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

    The additional number and street address of the address.

Returns:



407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 407

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

#update_with_metadata(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 AddressInstanceMetadata

Parameters:

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

    A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses.

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

    The name to associate with the address.

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

    The number and street address of the address.

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

    The city of the address.

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

    The state or region of the address.

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

    The postal code of the address.

  • emergency_enabled (Boolean) (defaults to: :unset)

    Whether to enable emergency calling on the address. Can be: true or false.

  • auto_correct_address (Boolean) (defaults to: :unset)

    Whether we should automatically correct the address. Can be: true or false and the default is true. If empty or true, we will correct the address you provide if necessary. If false, we won’t alter the address you provide.

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

    The additional number and street address of the address.

Returns:



458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 458

def (
  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', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    address_instance = AddressInstance.new(
        @version,
        response.body,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
    AddressInstanceMetadata.new(
        @version,
        address_instance,
        response.headers,
        response.status_code
    )
end