ecoportal-api 0.10.14 → 0.10.16
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 +17 -1
- data/CLAUDE.md +71 -0
- data/lib/ecoportal/api/common/client.rb +18 -15
- data/lib/ecoportal/api/version.rb +1 -1
- metadata +4 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f6998cdda6bc8a40de4a368ab81d522cd9828cd8dbbb559a59948976e3f57dcb
|
|
4
|
+
data.tar.gz: ba86db2250fad20b429d1f5afa26a08b064e0eeb14ea90f096dceaf4973d362e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fb91f3d928853691c913efbd17f0db1bda9343c44b1449275864fc16e053ef0d3cd1f14fd64e90625fc3ea991a81494c2a7315d318666184c14dd3acd51344f4
|
|
7
|
+
data.tar.gz: 57f8fc55f1d55f1733fe98720477739d72b063bae1f4a16665132e20a5560192275b5815e25d99097400fd2f5de4c7914a35823a8e5168ea34187e4e5d9ae98c
|
data/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
-
## [0.10.
|
|
5
|
+
## [0.10.17] - 2026-06-xx
|
|
6
6
|
|
|
7
7
|
### Added
|
|
8
8
|
|
|
@@ -10,6 +10,22 @@ All notable changes to this project will be documented in this file.
|
|
|
10
10
|
|
|
11
11
|
### Fixed
|
|
12
12
|
|
|
13
|
+
## [0.10.16] - 2026-06-05
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- Non-applicable _Missing API key!_ message.
|
|
22
|
+
|
|
23
|
+
## [0.10.15] - 2026-05-26
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- `Client.new` keep `@version` var when parameter not specified.
|
|
28
|
+
|
|
13
29
|
## [0.10.14] - 2025-08-15
|
|
14
30
|
|
|
15
31
|
### Added
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# CLAUDE.md — ecoportal-api
|
|
2
|
+
|
|
3
|
+
AI agent instructions for this repository.
|
|
4
|
+
|
|
5
|
+
**Cross-cutting architecture context lives in `ecoportal-api-graphql` — see its `CLAUDE.md` and `.claude/` folder for the full dependency map, project history, and shared skills.**
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Repository Role
|
|
10
|
+
|
|
11
|
+
`ecoportal-api` is the **foundational REST API gem** in the EcoPortal Ruby stack. It provides authentication, HTTP client infrastructure, org context, and the `Ecoportal::API::Common` namespace that all downstream gems build on.
|
|
12
|
+
|
|
13
|
+
**Position in chain:**
|
|
14
|
+
```
|
|
15
|
+
ecoportal-api ← THIS REPO
|
|
16
|
+
↓
|
|
17
|
+
ecoportal-api-v2
|
|
18
|
+
↓
|
|
19
|
+
ecoportal-api-graphql
|
|
20
|
+
↓
|
|
21
|
+
eco-helpers
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Remote:** https://gitlab.ecoportal.co.nz/ecoportal/ecoportal-api.git
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Key Folder Layout
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
lib/ecoportal/api/
|
|
32
|
+
common/ Shared infrastructure (client, logging, response, batch, hash_diff)
|
|
33
|
+
client/ HTTP client — rate throttling, retries, timeouts, APM, error handling
|
|
34
|
+
errors/ Shared error classes
|
|
35
|
+
internal/ Internal API resources (people, permissions, schema, login providers)
|
|
36
|
+
v1/ REST API v1 resources (people, schema, jobs)
|
|
37
|
+
logger.rb Shared logger
|
|
38
|
+
version.rb Gem version
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Namespace
|
|
44
|
+
|
|
45
|
+
`Ecoportal::API` — specifically:
|
|
46
|
+
- `Ecoportal::API::Common` — shared base classes (consumed by `ecoportal-api-v2` and `ecoportal-api-graphql`)
|
|
47
|
+
- `Ecoportal::API::Internal` — internal API endpoints
|
|
48
|
+
- `Ecoportal::API::V1` — v1 REST endpoints
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Key Concerns
|
|
53
|
+
|
|
54
|
+
- `Common::Client` — base HTTP client with rate throttling, retry logic, timeouts, and APM integration. All downstream clients inherit or wrap this.
|
|
55
|
+
- `Common::BaseModel` / `Common::BaseClass` — base model classes. `ecoportal-api-v2` extends these heavily.
|
|
56
|
+
- Changes to `Common::` affect **all downstream gems** — treat as a public API.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Backwards Compatibility
|
|
61
|
+
|
|
62
|
+
Changes to `Ecoportal::API::Common::*` propagate to `ecoportal-api-v2`, `ecoportal-api-graphql`, and `eco-helpers`. Any breaking change must be coordinated across the chain.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Running Tests
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
bundle install
|
|
70
|
+
bundle exec rspec
|
|
71
|
+
```
|
|
@@ -31,7 +31,7 @@ module Ecoportal
|
|
|
31
31
|
MAIN_END_POINT = 'api'.freeze
|
|
32
32
|
|
|
33
33
|
attr_accessor :logger
|
|
34
|
-
attr_reader :host
|
|
34
|
+
attr_reader :host, :version
|
|
35
35
|
|
|
36
36
|
# @note the `api_key` will be automatically added as parameter `X-ApiKey` in the header of the http requests.
|
|
37
37
|
# @param api_key [String] the key version to stablish the api connection.
|
|
@@ -40,8 +40,9 @@ module Ecoportal
|
|
|
40
40
|
# @param logger [Logger] an object with `Logger` interface to generate logs.
|
|
41
41
|
# @param deep_logging [Boolean] whether or not batch responses should be logged
|
|
42
42
|
# @return [Client] an object that holds the configuration of the api connection.
|
|
43
|
-
def initialize(api_key:, version:
|
|
44
|
-
|
|
43
|
+
def initialize(api_key:, version: :unused, host: DEFAULT_HOST, logger: nil, deep_logging: false)
|
|
44
|
+
version = nil if version == :unused
|
|
45
|
+
@version = version unless version.nil?
|
|
45
46
|
@api_key = api_key
|
|
46
47
|
@logger = logger
|
|
47
48
|
@host = host
|
|
@@ -55,12 +56,14 @@ module Ecoportal
|
|
|
55
56
|
|
|
56
57
|
if deep_logging?
|
|
57
58
|
log(:debug) {
|
|
58
|
-
"#{version} client initialized pointing at #{host}"
|
|
59
|
+
"#{self.version} client initialized pointing at #{host}"
|
|
59
60
|
}
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
return unless api_key.nil? || api_key.match(/\A\W*\z/)
|
|
63
|
-
return unless version
|
|
64
|
+
return unless self.version
|
|
65
|
+
return if self.version == 'graphql'
|
|
66
|
+
return if self.version == 'http'
|
|
64
67
|
|
|
65
68
|
log(:error) { 'Api-key missing!' }
|
|
66
69
|
end
|
|
@@ -68,11 +71,11 @@ module Ecoportal
|
|
|
68
71
|
# Sends an http `GET` request against the api version using `path` to complete the base url,
|
|
69
72
|
# and adding the key_value pairs of `params` in the http _header_.
|
|
70
73
|
# @param path [String] the tail that completes the url of the request.
|
|
71
|
-
# @param params [Hash] the header
|
|
74
|
+
# @param params [Hash] the header parameters of the http request (not including the api key).
|
|
72
75
|
# @option params [String] :page the current page we are requesting with given the `:per_page` offset.
|
|
73
76
|
# @option params [String] :per_page the offset or the number of entries you get per request.
|
|
74
77
|
# @option params [String] :q some text to search. Omit this parameter to target all the entries.
|
|
75
|
-
# @return [Common::
|
|
78
|
+
# @return [Common::Response] the basic custom response object.
|
|
76
79
|
def get(path, params: {})
|
|
77
80
|
instrument('GET', path, params) do
|
|
78
81
|
request do |http|
|
|
@@ -86,9 +89,9 @@ module Ecoportal
|
|
|
86
89
|
# @note it automatically adds the http header param `Content-Type` as `application/json`
|
|
87
90
|
# @param path [String] the tail that completes the url of the request.
|
|
88
91
|
# @param data [String] the body of the query in json format.
|
|
89
|
-
# @param params [Hash] the header
|
|
92
|
+
# @param params [Hash] the header parameters of the http request (not including the api key).
|
|
90
93
|
# @option params [String] URL params; will depend on he API being used.
|
|
91
|
-
# @return [Common::
|
|
94
|
+
# @return [Common::Response] the basic custom response object.
|
|
92
95
|
def post(path, data:, params: {})
|
|
93
96
|
instrument('POST', path, params) do
|
|
94
97
|
request do |http|
|
|
@@ -106,7 +109,7 @@ module Ecoportal
|
|
|
106
109
|
# @note it automatically adds the http header param `Content-Type` as `application/json`
|
|
107
110
|
# @param path [String] the tail that completes the url of the request.
|
|
108
111
|
# @param data [String] the body of the query in json format.
|
|
109
|
-
# @return [Common::
|
|
112
|
+
# @return [Common::Response] the basic custom response object.
|
|
110
113
|
def patch(path, data:)
|
|
111
114
|
instrument('PATCH', path, data) do
|
|
112
115
|
request do |http|
|
|
@@ -117,7 +120,7 @@ module Ecoportal
|
|
|
117
120
|
|
|
118
121
|
# Sends an http `DELETE` request against the api version using `path` to complete the base url.
|
|
119
122
|
# @param path [String] the tail that completes the url of the request.
|
|
120
|
-
# @return [Common::
|
|
123
|
+
# @return [Common::Response] the basic custom response object.
|
|
121
124
|
def delete(path)
|
|
122
125
|
instrument('DELETE', path) do
|
|
123
126
|
request do |http|
|
|
@@ -131,14 +134,14 @@ module Ecoportal
|
|
|
131
134
|
# @yield [http] launch specific http request.
|
|
132
135
|
# @yieldparam http [HTTP] the http connection.
|
|
133
136
|
# @yieldreturn [Common::Response] the basic custom response object.
|
|
134
|
-
# @return [Common::
|
|
137
|
+
# @return [Common::Response] the basic custom response object.
|
|
135
138
|
def request
|
|
136
139
|
wrap_response yield(base_request)
|
|
137
140
|
end
|
|
138
141
|
|
|
139
142
|
# Wrap with basic custom object of the gem for responses.
|
|
140
143
|
# @param response [HTTP::Response]
|
|
141
|
-
# @return [Common::
|
|
144
|
+
# @return [Common::Response] the basic custom response object.
|
|
142
145
|
def wrap_response(response)
|
|
143
146
|
Ecoportal::API::Common::Response.new(response)
|
|
144
147
|
end
|
|
@@ -150,7 +153,7 @@ module Ecoportal
|
|
|
150
153
|
def base_request
|
|
151
154
|
@base_request ||=
|
|
152
155
|
case @version
|
|
153
|
-
when 'v2'
|
|
156
|
+
when 'v2', 'v3'
|
|
154
157
|
HTTP.headers('X-ECOPORTAL-API-KEY' => api_key).accept(:json)
|
|
155
158
|
else
|
|
156
159
|
HTTP.headers('X-ApiKey' => api_key).accept(:json)
|
|
@@ -204,7 +207,7 @@ module Ecoportal
|
|
|
204
207
|
# log(:info) {'General information on what's going on'}
|
|
205
208
|
# log(:warn) {'This is a warning that something is likely to have gone amiss'}
|
|
206
209
|
# log(:error) {'Something went wrong'}
|
|
207
|
-
# log(:fatal) {'An unrecoverable error has
|
|
210
|
+
# log(:fatal) {'An unrecoverable error has happened'}
|
|
208
211
|
# @param level [Symbol] the level that the message should be logged.
|
|
209
212
|
# @yield [] generates the message.
|
|
210
213
|
# @yieldreturn [String] the generated message.
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
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.16
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tapio Saarinen
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: pry
|
|
@@ -194,7 +193,6 @@ dependencies:
|
|
|
194
193
|
- - "~>"
|
|
195
194
|
- !ruby/object:Gem::Version
|
|
196
195
|
version: '0.1'
|
|
197
|
-
description:
|
|
198
196
|
email:
|
|
199
197
|
- tapio@ecoportal.co.nz
|
|
200
198
|
- oscar@ecoportal.co.nz
|
|
@@ -209,6 +207,7 @@ files:
|
|
|
209
207
|
- ".ruby-version"
|
|
210
208
|
- ".yardopts"
|
|
211
209
|
- CHANGELOG.md
|
|
210
|
+
- CLAUDE.md
|
|
212
211
|
- Gemfile
|
|
213
212
|
- LICENSE
|
|
214
213
|
- README.md
|
|
@@ -274,7 +273,6 @@ licenses:
|
|
|
274
273
|
- MIT
|
|
275
274
|
metadata:
|
|
276
275
|
rubygems_mfa_required: 'true'
|
|
277
|
-
post_install_message:
|
|
278
276
|
rdoc_options: []
|
|
279
277
|
require_paths:
|
|
280
278
|
- lib
|
|
@@ -289,8 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
289
287
|
- !ruby/object:Gem::Version
|
|
290
288
|
version: '0'
|
|
291
289
|
requirements: []
|
|
292
|
-
rubygems_version:
|
|
293
|
-
signing_key:
|
|
290
|
+
rubygems_version: 4.0.8
|
|
294
291
|
specification_version: 4
|
|
295
292
|
summary: A collection of helpers for interacting with the ecoPortal MS's various APIs
|
|
296
293
|
test_files: []
|