Class: Plivo::Resources::Identity

Inherits:
Base::Resource show all
Defined in:
lib/plivo/resources/identities.rb

Constant Summary

Constants included from Utils

Utils::TYPE_WHITELIST

Instance Attribute Summary

Attributes inherited from Base::Resource

#id

Instance Method Summary collapse

Methods included from Utils

GetSortedQueryParamString?, compute_signatureV3?, expected_type?, expected_value?, generate_url?, getMapFromQueryString?, is_one_among_string_url?, multi_valid_param?, raise_invalid_request, valid_account?, valid_date_format?, valid_mainaccount?, valid_multiple_destination_integers?, valid_multiple_destination_nos?, valid_param?, valid_range?, valid_signature?, valid_signatureV3?, valid_subaccount?, valid_url?

Constructor Details

#initialize(client, options = nil) ⇒ Identity

Returns a new instance of Identity.



6
7
8
9
10
# File 'lib/plivo/resources/identities.rb', line 6

def initialize(client, options = nil)
  @_name = 'Verification/Identity'
  @_identifier_string = 'id'
  super
end

Instance Method Details

#deleteObject



12
13
14
# File 'lib/plivo/resources/identities.rb', line 12

def delete
  perform_delete
end

#to_sObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# 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) ⇒ Identity

Update an identity

Parameters:

  • identity_id (String)
  • file_to_upload (String) (defaults to: nil)
  • options (Hash) (defaults to: nil)

Options Hash (options):

  • :salutation (String)
    • One of Mr or Ms

  • :first_name (String)
    • First name of the user for whom the identity is created

  • :last_name (String)
    • Last name of the user for whom the identity is created

  • :country_iso (String)
    • Country ISO 2 code

  • :birth_place (String)
    • Birthplace of the user for whom the identity is created

  • :birth_date (String)
    • Birth date in yyyy-mm-dd format of the user for whom the identity is created

  • :nationality (String)
    • Nationality of the user for whom the identity is created

  • :id_nationality (String)
    • Nationality mentioned in the identity proof

  • :id_issue_date (String)
    • Issue date in yyyy-mm-dd mentioned in the identity proof

  • :id_type (String)

    -

  • :id_number (String)
    • The unique number on the identifier

  • :address_line1 (String)
    • Building name/number

  • :address_line2 (String)
    • The street name/number of the address

  • :city (String)
    • The city of the address for which the address proof is created

  • :region (String)
    • The region of the address for which the address proof is created

  • :postal_code (String)
    • The postal code of the address that is being created

  • :alias (String)
    • Alias name of the identity

  • :business_name (String)
    • Business name of the user for whom the identity is created.

  • :auto_correct_address (String)
    • 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.

  • :fiscal_identification_code (String)
    • The code is valid for businesses alone

  • :street_code (String)
    • Street code of the address

  • :municipal_code (String)
    • Municipal code of the address

  • :callback_url (String)
    • The callback URL that gets the result of identity creation POSTed to.

  • :subaccount (String)
    • The link to the subaccount resource associated with the application. If the application belongs to the main account, this field will be null.

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# 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