xhash_client 0.3.3 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21dcbe25c117136469c5d4771d19702d88bd72d53049facee20ed68af710c4d9
4
- data.tar.gz: ef284cac9fc9d8abde1732204705c0c56887cc2124ad4ed85fef5ae895a10a6a
3
+ metadata.gz: e463ff9cc2dcf110036533294d279b2ce03de7417b7a2a76328331087bef42c2
4
+ data.tar.gz: 9c4584a3533818d5bebdac8698b93f0f48e7cb2261d7f7531a58b984ea722cf7
5
5
  SHA512:
6
- metadata.gz: b8864b24dc5d915a72d7a55deb07950f431e7a748286b3a0fcb6bf53b44282902a3db215ab501eb9e61de3d2626dfbfd20a809544f4cddfb21180506ac83ed9e
7
- data.tar.gz: cd939aed1627caf3be233bd18ae3e5db0ed53c25ddf8e19a05fb3183aec2a37d24c22dbf01b78c14542976857ae4c8010b97f622013a478437bbbab5a92730ae
6
+ metadata.gz: 8d9c54d87b369ea6a32fde2b6754e81da935e9e8d9faeeaeeb27f6bdd7316a59821356bbfa45f3930f78cdd23c6533f506b5d523a85ea1c11432e837507b3784
7
+ data.tar.gz: 8319362003a5fe439fbbf35f036513a4f5b7168e11ebf35884de56c8555a3063ece3c9b286cc773aba85b13cba2ad4975db26a46ea50e6583583f7f523216ab3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xhash_client (0.3.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.2019.1009)
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)
@@ -40,4 +40,12 @@ module Xhash
40
40
  def self.api_key=(api_key)
41
41
  @api_key = api_key
42
42
  end
43
+
44
+ def self.timeout
45
+ @timeout
46
+ end
47
+
48
+ def self.timeout=(timeout)
49
+ @timeout = timeout
50
+ end
43
51
  end
@@ -23,5 +23,13 @@ module Xhash
23
23
  def self.api_key=(api_key)
24
24
  @api_key = api_key
25
25
  end
26
+
27
+ def self.timeout
28
+ @timeout
29
+ end
30
+
31
+ def self.timeout=(timeout)
32
+ @timeout = timeout
33
+ end
26
34
  end
27
35
  end
@@ -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)
@@ -3,8 +3,14 @@ module Xhash
3
3
  attr_reader :message, :response
4
4
 
5
5
  def initialize(options = {})
6
- @message = options[:message]
7
- @response = options[:response]
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
@@ -96,7 +96,7 @@ module Xhash
96
96
  )
97
97
  body = {
98
98
  'document_url' => document_url, 'document_file' => document_file
99
- }
99
+ }.compact
100
100
 
101
101
  response =
102
102
  if document_file.nil?
@@ -1,3 +1,3 @@
1
1
  module Xhash
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.8'
3
3
  end
@@ -6,4 +6,7 @@ require 'xhash'
6
6
 
7
7
  SimpleCov.start { add_filter '/spec/' }
8
8
 
9
- RSpec.configure { |config| config.before(:all) { Xhash.api_key = 'api_key' } }
9
+ RSpec.configure { |config| config.before(:all) {
10
+ Xhash.api_key = 'api_key'
11
+ Xhash.timeout = 10
12
+ } }
@@ -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.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.0.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: