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 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.



202
203
204
205
206
207
208
209
210
211
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 202

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



215
216
217
218
219
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 215

def delete

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

#dependent_phone_numbersDependentPhoneNumberList, DependentPhoneNumberContext

Access the dependent_phone_numbers

Returns:



286
287
288
289
290
291
292
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 286

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:



224
225
226
227
228
229
230
231
232
233
234
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 224

def fetch

    
    payload = @version.fetch('GET', @uri)
    AddressInstance.new(
        @version,
        payload,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



303
304
305
306
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 303

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

#to_sObject

Provide a user friendly representation



296
297
298
299
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 296

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 address. It can be up to 64 characters long.

  • 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:



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/twilio-ruby/rest/api/v2010/account/address.rb', line 248

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,
    })

    
    payload = @version.update('POST', @uri, data: data)
    AddressInstance.new(
        @version,
        payload,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
end