enrich-api 1.1.5 → 1.2.0
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/enrich-api.gemspec +1 -1
- data/lib/enrich-api.rb +20 -55
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7009ec69ccc7069f43056d02cee15e1baf491df5
|
4
|
+
data.tar.gz: 6919a40f16fd82debdc098c9624b72ea26f8851b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 584e06d362af8955d3b26602a40a6e86619e6b85f907870d4ccdaadef228145b0ab282ef99a112260c300b66e99b1e6e392bd6a530439c8f981012c2db9d3059
|
7
|
+
data.tar.gz: dd5abf7971909e8418fb1f7ac62c5147fcfaeb33bc46f75e83636477b6c5af604058bb50317a1ad1c3f208f66bf10bf56734952bf5ba79906e94de1b405a68be
|
data/enrich-api.gemspec
CHANGED
data/lib/enrich-api.rb
CHANGED
@@ -19,10 +19,6 @@ module Enrich
|
|
19
19
|
attr_accessor :enrich
|
20
20
|
attr_accessor :verify
|
21
21
|
|
22
|
-
@@created_status_code = 201
|
23
|
-
@@not_found_status_code = 404
|
24
|
-
@@created_retry_count_max = 10
|
25
|
-
|
26
22
|
def initialize()
|
27
23
|
@auth = {}
|
28
24
|
|
@@ -46,64 +42,33 @@ module Enrich
|
|
46
42
|
end
|
47
43
|
|
48
44
|
def timeout
|
49
|
-
@timeout ||
|
45
|
+
@timeout || 40
|
50
46
|
end
|
51
47
|
|
52
48
|
def _get(resource, query)
|
53
|
-
self._do_get(resource, query
|
49
|
+
self._do_get(resource, query)
|
54
50
|
end
|
55
51
|
|
56
52
|
protected
|
57
53
|
|
58
|
-
def _do_get(resource, query
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
:user_agent => "enrich-api-ruby/1.1.5",
|
77
|
-
:accept => :json,
|
78
|
-
:content_type => :json,
|
79
|
-
:params => query
|
80
|
-
}
|
81
|
-
)
|
82
|
-
|
83
|
-
status = response.code
|
84
|
-
rescue RestClient::NotFound
|
85
|
-
status = @@not_found_status_code
|
86
|
-
end
|
87
|
-
|
88
|
-
# Re-schedule request? (created)
|
89
|
-
if status == @@created_status_code || (retry_count > 0 &&
|
90
|
-
status == @@not_found_status_code)
|
91
|
-
if response && response.headers[:retry_after]
|
92
|
-
hold_for_seconds = Integer(response.headers[:retry_after])
|
93
|
-
end
|
94
|
-
|
95
|
-
return self._do_get(
|
96
|
-
resource, query, retry_count + 1, hold_for_seconds
|
97
|
-
)
|
98
|
-
end
|
99
|
-
|
100
|
-
# Not found?
|
101
|
-
if status == @@not_found_status_code
|
102
|
-
raise RestClient::NotFound
|
103
|
-
end
|
104
|
-
|
105
|
-
return JSON.parse(response)
|
106
|
-
end
|
54
|
+
def _do_get(resource, query)
|
55
|
+
response = RestClient::Request.execute(
|
56
|
+
:url => self._prepare_rest_url(resource),
|
57
|
+
:method => :get,
|
58
|
+
:timeout => self.timeout,
|
59
|
+
|
60
|
+
:user => @auth["user_id"],
|
61
|
+
:password => @auth["secret_key"],
|
62
|
+
|
63
|
+
:headers => {
|
64
|
+
:user_agent => "enrich-api-ruby/1.2.0",
|
65
|
+
:accept => :json,
|
66
|
+
:content_type => :json,
|
67
|
+
:params => query
|
68
|
+
}
|
69
|
+
)
|
70
|
+
|
71
|
+
return JSON.parse(response)
|
107
72
|
end
|
108
73
|
|
109
74
|
def _prepare_rest_url(resource)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enrich-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valerian Saliou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|