class Plivo::Resources::Identity

Public Class Methods

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

Public Instance Methods

delete() click to toggle source
# File lib/plivo/resources/identities.rb, line 12
def delete
  perform_delete
end
to_s() click to toggle source
# File lib/plivo/resources/identities.rb, line 86
def to_s
  {
    account: @account,
    alias: @alias,
    api_id: @api_id,
    country_iso: @country_iso,
    document_details: @document_details,
    first_name: @first_name,
    id: @id,
    id_number: @id_number,
    id_type: @id_type,
    last_name: @last_name,
    nationality: @nationality,
    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 identity @param [String] identity_id @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 identity is created @option options [String] :last_name - Last name of the user for whom the identity is created @option options [String] :country_iso - Country ISO 2 code @option options [String] :birth_place - Birthplace of the user for whom the identity is created @option options [String] :birth_date - Birth date in yyyy-mm-dd format of the user for whom the identity is created @option options [String] :nationality - Nationality of the user for whom the identity is created @option options [String] :id_nationality - Nationality mentioned in the identity proof @option options [String] :id_issue_date - Issue date in yyyy-mm-dd mentioned in the identity proof @option options [String] :id_type - @option options [String] :id_number - The unique number on the identifier @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 identity @option options [String] :business_name - Business name of the user for whom the identity is created. @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] :fiscal_identification_code - The code is valid for businesses alone @option options [String] :street_code - Street code of the address @option options [String] :municipal_code - Municipal code of the address @option options [String] :callback_url - The callback URL that gets the result of identity creation POSTed to. @option options [String] :subaccount - The link to the subaccount resource associated with the application. If the application belongs to the main account, this field will be null. @return [Identity] Identity

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

  unless options.nil?
    %i[salutation first_name last_name country_iso birth_place birth_date nationality id_nationality id_issue_date
       id_type id_number address_line1 address_line2 city region postal_code alias business_name
       fiscal_identification_code street_code municipal_code callback_url subaccount
      ]
        .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