ecoportal-api 0.10.11 → 0.10.12
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/CHANGELOG.md +9 -1
- data/lib/ecoportal/api/common/client.rb +22 -9
- data/lib/ecoportal/api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c2232426e0251d1242aba6d7a0aa65c545b1bf07f273d23403b0daab0ae57d1
|
4
|
+
data.tar.gz: e155ec14f82fa569df5eeb4adcb89eb3848b21c902f01009ab4d5644b42b73c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41297931b543449d223f06cb64f46108d96d16141ab8b2a54f10a5bf782d241e8c37060a43807dd4e63d34288f1919c0a716db4a554e5ef4f3da54e42a574561
|
7
|
+
data.tar.gz: d0d7c16a92811f06df6611ae85fe0e93a62abd950ac478a8be0a6dca7c59fe4e064ca06849d974b913c370c65d79a68593c194324984f7cb3045fe0d5476be62
|
data/CHANGELOG.md
CHANGED
@@ -2,10 +2,18 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
## [0.10.
|
5
|
+
## [0.10.12] - 2025-05-xx
|
6
6
|
|
7
7
|
### Added
|
8
8
|
|
9
|
+
- `Client#post` **added** named argument `params` (for the **url** arguments)
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
## [0.10.11] - 2025-05-15
|
16
|
+
|
9
17
|
### Changed
|
10
18
|
|
11
19
|
- `MAX_START_DELAY` to be `120` (it was `60`).
|
@@ -27,7 +27,8 @@ module Ecoportal
|
|
27
27
|
include WithRetry
|
28
28
|
include RateThrottling
|
29
29
|
|
30
|
-
DEFAULT_HOST
|
30
|
+
DEFAULT_HOST = 'live.ecoportal.com'.freeze
|
31
|
+
MAIN_END_POINT = 'api'.freeze
|
31
32
|
|
32
33
|
attr_accessor :logger
|
33
34
|
attr_reader :host
|
@@ -47,9 +48,9 @@ module Ecoportal
|
|
47
48
|
@deep_logging = deep_logging
|
48
49
|
|
49
50
|
if host.match(/^localhost|^127\.0\.0\.1/)
|
50
|
-
@base_uri = "http://#{host}/
|
51
|
+
@base_uri = "http://#{host}/#{main_end_point}/"
|
51
52
|
else
|
52
|
-
@base_uri = "https://#{host}/
|
53
|
+
@base_uri = "https://#{host}/#{main_end_point}/"
|
53
54
|
end
|
54
55
|
|
55
56
|
if deep_logging?
|
@@ -58,7 +59,7 @@ module Ecoportal
|
|
58
59
|
}
|
59
60
|
end
|
60
61
|
|
61
|
-
return unless
|
62
|
+
return unless api_key.nil? || api_key.match(/\A\W*\z/)
|
62
63
|
return unless version
|
63
64
|
|
64
65
|
log(:error) { 'Api-key missing!' }
|
@@ -85,11 +86,17 @@ module Ecoportal
|
|
85
86
|
# @note it automatically adds the http header param `Content-Type` as `application/json`
|
86
87
|
# @param path [String] the tail that completes the url of the request.
|
87
88
|
# @param data [String] the body of the query in json format.
|
89
|
+
# @param params [Hash] the header paramters of the http request (not including the api key).
|
90
|
+
# @option params [String] URL params; will depend on he API being used.
|
88
91
|
# @return [Common::Reponse] the basic custom response object.
|
89
|
-
def post(path, data:)
|
90
|
-
instrument('POST', path,
|
92
|
+
def post(path, data:, params: {})
|
93
|
+
instrument('POST', path, params) do
|
91
94
|
request do |http|
|
92
|
-
http.post(
|
95
|
+
http.post(
|
96
|
+
url_for(path),
|
97
|
+
json: data,
|
98
|
+
params: params
|
99
|
+
)
|
93
100
|
end
|
94
101
|
end
|
95
102
|
end
|
@@ -144,9 +151,9 @@ module Ecoportal
|
|
144
151
|
@base_request ||=
|
145
152
|
case @version
|
146
153
|
when 'v2'
|
147
|
-
HTTP.headers('X-ECOPORTAL-API-KEY' =>
|
154
|
+
HTTP.headers('X-ECOPORTAL-API-KEY' => api_key).accept(:json)
|
148
155
|
else
|
149
|
-
HTTP.headers('X-ApiKey' =>
|
156
|
+
HTTP.headers('X-ApiKey' => api_key).accept(:json)
|
150
157
|
end
|
151
158
|
end
|
152
159
|
|
@@ -159,6 +166,8 @@ module Ecoportal
|
|
159
166
|
|
160
167
|
private
|
161
168
|
|
169
|
+
attr_reader :api_key
|
170
|
+
|
162
171
|
def instrument(method, path, data = nil, &block)
|
163
172
|
raise 'Expected block' unless block_given?
|
164
173
|
|
@@ -203,6 +212,10 @@ module Ecoportal
|
|
203
212
|
puts "(#{level}) #{yield}"
|
204
213
|
logger&.send(level, &block)
|
205
214
|
end
|
215
|
+
|
216
|
+
def main_end_point
|
217
|
+
self.class::MAIN_END_POINT
|
218
|
+
end
|
206
219
|
end
|
207
220
|
end
|
208
221
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecoportal-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tapio Saarinen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-05-
|
11
|
+
date: 2025-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|