xhash_client 0.3.3 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/xhash.rb +8 -0
- data/lib/xhash/client/api_client.rb +8 -0
- data/lib/xhash/client/json_api.rb +3 -3
- data/lib/xhash/error.rb +8 -2
- data/lib/xhash/ocr.rb +1 -1
- data/lib/xhash/version.rb +1 -1
- data/spec/spec_helper.rb +4 -1
- data/spec/xhash/ocr_spec.rb +30 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e463ff9cc2dcf110036533294d279b2ce03de7417b7a2a76328331087bef42c2
|
4
|
+
data.tar.gz: 9c4584a3533818d5bebdac8698b93f0f48e7cb2261d7f7531a58b984ea722cf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d9c54d87b369ea6a32fde2b6754e81da935e9e8d9faeeaeeb27f6bdd7316a59821356bbfa45f3930f78cdd23c6533f506b5d523a85ea1c11432e837507b3784
|
7
|
+
data.tar.gz: 8319362003a5fe439fbbf35f036513a4f5b7168e11ebf35884de56c8555a3063ece3c9b286cc773aba85b13cba2ad4975db26a46ea50e6583583f7f523216ab3
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
xhash_client (0.3.
|
4
|
+
xhash_client (0.3.7)
|
5
5
|
httparty (~> 0.16.0)
|
6
6
|
json (~> 2.0)
|
7
7
|
|
@@ -21,7 +21,7 @@ GEM
|
|
21
21
|
json (2.2.0)
|
22
22
|
mime-types (3.3.1)
|
23
23
|
mime-types-data (~> 3.2015)
|
24
|
-
mime-types-data (3.
|
24
|
+
mime-types-data (3.2020.0512)
|
25
25
|
multi_xml (0.6.0)
|
26
26
|
public_suffix (4.0.1)
|
27
27
|
rspec (3.8.0)
|
data/lib/xhash.rb
CHANGED
@@ -11,7 +11,7 @@ module Xhash
|
|
11
11
|
|
12
12
|
def api_get(url:, headers: {})
|
13
13
|
custom_headers = headers.merge(default_headers)
|
14
|
-
response = HTTParty.get(Xhash.api_base + url, headers: custom_headers)
|
14
|
+
response = HTTParty.get(Xhash.api_base + url, headers: custom_headers, timeout: Xhash.timeout)
|
15
15
|
|
16
16
|
raise Xhash::Error.new(response) unless response_ok?(response)
|
17
17
|
|
@@ -28,7 +28,7 @@ module Xhash
|
|
28
28
|
response =
|
29
29
|
HTTParty.post(
|
30
30
|
Xhash.api_base + url,
|
31
|
-
body: body.to_json, headers: custom_headers
|
31
|
+
body: body.to_json, headers: custom_headers, timeout: Xhash.timeout
|
32
32
|
)
|
33
33
|
|
34
34
|
raise Xhash::Error.new(response) unless response_ok?(response)
|
@@ -46,7 +46,7 @@ module Xhash
|
|
46
46
|
response =
|
47
47
|
HTTParty.post(
|
48
48
|
Xhash.api_base + url,
|
49
|
-
multipart: true, body: body, headers: custom_headers
|
49
|
+
multipart: true, body: body, headers: custom_headers, timeout: Xhash.timeout
|
50
50
|
)
|
51
51
|
|
52
52
|
raise Xhash::Error.new(response) unless response_ok?(response)
|
data/lib/xhash/error.rb
CHANGED
@@ -3,8 +3,14 @@ module Xhash
|
|
3
3
|
attr_reader :message, :response
|
4
4
|
|
5
5
|
def initialize(options = {})
|
6
|
-
|
7
|
-
|
6
|
+
if options.is_a? Hash
|
7
|
+
@message = options[:message]
|
8
|
+
@response = options[:response]
|
9
|
+
else
|
10
|
+
@message = "Server error"
|
11
|
+
@response = options
|
12
|
+
end
|
13
|
+
|
8
14
|
super
|
9
15
|
end
|
10
16
|
end
|
data/lib/xhash/ocr.rb
CHANGED
data/lib/xhash/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/xhash/ocr_spec.rb
CHANGED
@@ -7,6 +7,8 @@ describe Xhash::OCR do
|
|
7
7
|
body:
|
8
8
|
JSON.dump(
|
9
9
|
{
|
10
|
+
result: true,
|
11
|
+
execution_time: 2.7695868015289307,
|
10
12
|
payload: {
|
11
13
|
name: 'MARGARITA',
|
12
14
|
last_name: 'GOMEZ',
|
@@ -16,7 +18,8 @@ describe Xhash::OCR do
|
|
16
18
|
neighborhood: 'NACIO PITAGORAS 1253',
|
17
19
|
zip_code: 'INT 4',
|
18
20
|
city: 'COL. MORELOS 04800',
|
19
|
-
type: 'INE'
|
21
|
+
type: 'INE',
|
22
|
+
control: "2"
|
20
23
|
}
|
21
24
|
}
|
22
25
|
),
|
@@ -46,6 +49,8 @@ describe Xhash::OCR do
|
|
46
49
|
body:
|
47
50
|
JSON.dump(
|
48
51
|
{
|
52
|
+
result: true,
|
53
|
+
execution_time: 2.7695868015289307,
|
49
54
|
payload: {
|
50
55
|
name: 'MARGARITA',
|
51
56
|
last_name: 'GOMEZ',
|
@@ -55,7 +60,8 @@ describe Xhash::OCR do
|
|
55
60
|
neighborhood: 'NACIO PITAGORAS 1253',
|
56
61
|
zip_code: 'INT 4',
|
57
62
|
city: 'COL. MORELOS 04800',
|
58
|
-
type: 'INE'
|
63
|
+
type: 'INE',
|
64
|
+
control: "2"
|
59
65
|
}
|
60
66
|
}
|
61
67
|
),
|
@@ -181,6 +187,8 @@ describe Xhash::OCR do
|
|
181
187
|
body:
|
182
188
|
JSON.dump(
|
183
189
|
{
|
190
|
+
result: true,
|
191
|
+
execution_time: 2.7695868015289307,
|
184
192
|
payload: {
|
185
193
|
name: 'MARGARITA',
|
186
194
|
last_name: 'GOMEZ',
|
@@ -190,7 +198,8 @@ describe Xhash::OCR do
|
|
190
198
|
neighborhood: 'NACIO PITAGORAS 1253',
|
191
199
|
zip_code: 'INT 4',
|
192
200
|
city: 'COL. MORELOS 04800',
|
193
|
-
type: 'INE'
|
201
|
+
type: 'INE',
|
202
|
+
control: "2"
|
194
203
|
}
|
195
204
|
}
|
196
205
|
),
|
@@ -295,6 +304,24 @@ describe Xhash::OCR do
|
|
295
304
|
expect(exception).to be_a(Xhash::InvalidFieldError)
|
296
305
|
end
|
297
306
|
end
|
307
|
+
|
308
|
+
it 'fails to serialize to document with html error' do
|
309
|
+
stub_request(:post, 'https://xhash.dev/api/ocr/proof-of-address').to_return(
|
310
|
+
body: '<p>error</p>',
|
311
|
+
status: 500,
|
312
|
+
headers: { 'Content-Type' => 'text/html; charset=UTF-8' }
|
313
|
+
)
|
314
|
+
|
315
|
+
begin
|
316
|
+
ine =
|
317
|
+
Xhash::OCR.proof_of_address(
|
318
|
+
document_url:
|
319
|
+
'https://kyc-xhash.s3-us-west-2.amazonaws.com/documents/7cd6994d9ad52e8943be1ae00bac60c461430cdf2af6159afa4b9be749706472.png'
|
320
|
+
)
|
321
|
+
rescue => exception
|
322
|
+
expect(exception).to be_a(Xhash::Error)
|
323
|
+
end
|
324
|
+
end
|
298
325
|
end
|
299
326
|
|
300
327
|
describe '.ine_reverse' do
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xhash_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yellowme
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2019-10-10 00:00:00.000000000 Z
|
@@ -123,7 +123,7 @@ homepage: https://rubygems.org/gems/xhash-ruby
|
|
123
123
|
licenses:
|
124
124
|
- MIT
|
125
125
|
metadata: {}
|
126
|
-
post_install_message:
|
126
|
+
post_install_message:
|
127
127
|
rdoc_options: []
|
128
128
|
require_paths:
|
129
129
|
- lib
|
@@ -138,8 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
140
|
requirements: []
|
141
|
-
rubygems_version: 3.
|
142
|
-
signing_key:
|
141
|
+
rubygems_version: 3.1.2
|
142
|
+
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Ruby library built for Xhash API
|
145
145
|
test_files:
|