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

Parameters:

  • version (Version)

    Version that contains the resource

  • account_sid (String)

    The account_sid

  • sid (String)

    The sid



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

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

Deletes the AddressInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



242
243
244
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 242

def delete
  @version.delete('delete', @uri)
end

#dependent_phone_numbersDependentPhoneNumberList, DependentPhoneNumberContext

Access the dependent_phone_numbers

Returns:



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

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 a AddressInstance

Returns:



249
250
251
252
253
254
255
256
257
258
259
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 249

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  AddressInstance.new(@version, payload, account_sid: @solution[:account_sid], sid: @solution[:sid], )
end

#to_sObject

Provide a user friendly representation



319
320
321
322
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 319

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) ⇒ AddressInstance

Update the AddressInstance

Parameters:

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

    A human-readable description of the address. Maximum 64 characters.

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

    Your name or business name, or that of your customer.

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

    The number and street address where you or your customer is located.

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

    The city in which you or your customer is located.

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

    The state or region in which you or your customer is located.

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

    The postal code in which you or your customer is located.

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

    The emergency_enabled

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

    If you don’t set a value for this parameter, or if you set it to ‘true`, then the system will, if necessary, auto-correct the address you provide. If you don’t want the system to auto-correct the address, you will explicitly need to set this value to ‘false`.

Returns:



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 280

def update(friendly_name: :unset, customer_name: :unset, street: :unset, city: :unset, region: :unset, postal_code: :unset, emergency_enabled: :unset, auto_correct_address: :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,
  })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  AddressInstance.new(@version, payload, account_sid: @solution[:account_sid], sid: @solution[:sid], )
end