class Plivo::Resources::Address

Public Class Methods

new(client, options = nil) click to toggle source
Calls superclass method Plivo::Base::Resource::new
# File lib/plivo/resources/addresses.rb, line 6
def initialize(client, options = nil)
  @_name = 'Verification/Address'
  @_identifier_string = 'id'
  super
end

Public Instance Methods

delete() click to toggle source
# File lib/plivo/resources/addresses.rb, line 12
def delete
  perform_delete
end
to_s() click to toggle source
# File lib/plivo/resources/addresses.rb, line 71
def to_s
  {
    account: @account,
    address_line1: @address_line1,
    address_line2: @address_line2,
    alias: @alias,
    api_id: @api_id,
    city: @city,
    country_iso: @country_iso,
    document_details: @document_details,
    first_name: @first_name,
    id: @id,
    last_name: @last_name,
    postal_code: @postal_code,
    region: @region,
    salutation: @salutation,
    subaccount: @subaccount,
    url: @url,
    validation_status: @validation_status,
    verification_status: @verification_status
  }.to_s
end
update(file_to_upload = nil, options = nil) click to toggle source

Update an address @param [String] file_to_upload @param [Hash] options @option options [String] :salutation - One of Mr or Ms @option options [String] :first_name - First name of the user for whom the address is created @option options [String] :last_name - Last name of the user for whom the address is created @option options [String] :country_iso - Country ISO 2 code @option options [String] :address_line1 - Building name/number @option options [String] :address_line2 - The street name/number of the address @option options [String] :city - The city of the address for which the address proof is created @option options [String] :region - The region of the address for which the address proof is created @option options [String] :postal_code - The postal code of the address that is being created @option options [String] :alias - Alias name of the address @option options [String] :auto_correct_address - If set to true, the address will be auto-corrected by the system if necessary. The param needs to be set to false explicitly so that it is not auto-corrected. @option options [String] :callback_url - The callback URL that gets the result of address creation POSTed to. @return [Address] Address

# File lib/plivo/resources/addresses.rb, line 33
def update(file_to_upload = nil, options = nil)
  params = {}

  unless options.nil?
    %i[salutation first_name last_name country_iso address_line1 address_line2 city region postal_code alias callback_url]
        .each do |param|
      if options.key?(param) &&
          valid_param?(param, options[param], [String, Symbol], true)
        params[param] = options[param]
      end
    end

    %i[auto_correct_address]
        .each do |param|
      if options.key?(param) &&
          valid_param?(param, options[param], nil, true, [true, false])
        params[param] = options[param]
      end
    end
  end

  unless file_to_upload.nil?
    file_extension = file_to_upload.split('.')[-1]

    content_type = case file_extension
                     when 'jpeg' then 'image/jpeg'
                     when 'jpg' then 'image/jpeg'
                     when 'png' then 'image/png'
                     when 'pdf' then 'application/pdf'
                     else raise_invalid_request("#{file_extension} is not yet supported for upload")
                   end

    params[:file] = Faraday::UploadIO.new(file_to_upload, content_type)
  end

  return perform_update(params, true)
end