Class: Onfido::Document

Inherits:
Resource show all
Defined in:
lib/onfido/resources/document.rb

Constant Summary

Constants inherited from Resource

Resource::ADDITIONAL_HEADERS, Resource::REQUEST_TIMEOUT_HTTP_CODE, Resource::VALID_HTTP_METHODS

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Onfido::Resource

Instance Method Details

#all(applicant_id) ⇒ Object



24
25
26
# File 'lib/onfido/resources/document.rb', line 24

def all(applicant_id)
  get(path: "documents?applicant_id=#{applicant_id}")
end

#create(applicant_id:, file:, type:, **payload) ⇒ Object

with open-uri the file can be a link or an actual file



7
8
9
10
11
12
13
14
# File 'lib/onfido/resources/document.rb', line 7

def create(applicant_id:, file:, type:, **payload)
  validate_file!(file)
  payload[:applicant_id] = applicant_id
  payload[:file] = file
  payload[:type] = type

  post(path: 'documents', payload: payload, send_json: false)
end

#download(document_id) ⇒ Object



20
21
22
# File 'lib/onfido/resources/document.rb', line 20

def download(document_id)
  get(path: "documents/#{document_id}/download")
end

#find(document_id) ⇒ Object



16
17
18
# File 'lib/onfido/resources/document.rb', line 16

def find(document_id)
  get(path: "documents/#{document_id}")
end