Class: Xhash::OCR
Constant Summary
collapse
- IDENTIFICATION_TYPES =
['INE', 'CARTILLA MILITAR', 'PASAPORTE']
Class Method Summary
collapse
Methods inherited from ApiClient
api_base, api_base=, api_key, api_key=, config, timeout, timeout=
Methods included from JsonApi
included
Class Method Details
.generic(document_url: nil, document_file: nil) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/xhash/ocr.rb', line 5
def self.generic(document_url: nil, document_file: nil)
url = 'ocr'
if document_url.nil? and document_file.nil?
raise Xhash::MissingRequiredFieldError.new(
{ message: Xhash::ErrorMessage::MISSING_FILE }
)
end
payload =
request_by_file_or_url(
url: url, document_url: document_url, document_file: document_file
)
is_identification = IDENTIFICATION_TYPES.include? payload[:type]
document =
if is_identification
Xhash::Identification.new(
*payload.values_at(*Xhash::Identification.members)
)
else
Xhash::ProofOfAddress.new(
*payload.values_at(*Xhash::ProofOfAddress.members)
)
end
document
end
|
.identification(document_url: nil, document_file: nil) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/xhash/ocr.rb', line 35
def self.identification(document_url: nil, document_file: nil)
url = 'ocr/identification'
if document_url.nil? and document_file.nil?
raise Xhash::MissingRequiredFieldError.new(
{ message: Xhash::ErrorMessage::MISSING_FILE }
)
end
payload =
request_by_file_or_url(
url: url, document_url: document_url, document_file: document_file
)
Xhash::Identification.new(
*payload.values_at(*Xhash::Identification.members)
)
end
|
.ine_reverse(document_url: nil, document_file: nil) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/xhash/ocr.rb', line 73
def self.ine_reverse(document_url: nil, document_file: nil)
url = 'ocr/ine-reverse'
if document_url.nil? and document_file.nil?
raise Xhash::MissingRequiredFieldError.new(
{ message: Xhash::ErrorMessage::MISSING_FILE }
)
end
payload =
request_by_file_or_url(
url: url, document_url: document_url, document_file: document_file
)
Xhash::Identification.new(
*payload.values_at(*Xhash::Identification.members)
)
end
|
.proof_of_address(document_url: nil, document_file: nil) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/xhash/ocr.rb', line 54
def self.proof_of_address(document_url: nil, document_file: nil)
url = 'ocr/proof-of-address'
if document_url.nil? and document_file.nil?
raise Xhash::MissingRequiredFieldError.new(
{ message: Xhash::ErrorMessage::MISSING_FILE }
)
end
payload =
request_by_file_or_url(
url: url, document_url: document_url, document_file: document_file
)
Xhash::ProofOfAddress.new(
*payload.values_at(*Xhash::ProofOfAddress.members)
)
end
|