ecoportal-api-graphql 0.3.18 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.markdownlint.json +4 -0
- data/.rubocop.yml +4 -1
- data/.ruby-version +1 -0
- data/CHANGELOG.md +135 -79
- data/ecoportal-api-graphql.gemspec +7 -7
- data/lib/ecoportal/api/common/graphql/auth_service.rb +40 -30
- data/lib/ecoportal/api/common/graphql/client.rb +11 -4
- data/lib/ecoportal/api/common/graphql/http_client.rb +18 -7
- data/lib/ecoportal/api/graphql/base/contractor_entity.rb +1 -0
- data/lib/ecoportal/api/graphql/fragment/contractor_entity.rb +1 -0
- data/lib/ecoportal/api/graphql/fragment.rb +3 -1
- data/lib/ecoportal/api/graphql/query/contractor_entities.rb +11 -5
- data/lib/ecoportal/api/graphql_version.rb +1 -1
- metadata +16 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b010f2e79334e228ef058acb2c53aa92e894907a0a13557188227bb36f5c022
|
4
|
+
data.tar.gz: fdf9ca5d6486f68be8655a064a5293f1e92cf9d69bb831705ac9916fca60d836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c63be5db720017916fc426ec1cc7d4d1cfd4c510834b10ec5addd401abe48f19e5973395165fee8106ac3e8b400b1ae588e7e1a49a7165bf16028f2441f0e17d
|
7
|
+
data.tar.gz: 2827e76c1c03965d032a6812ad61f3dcf92940b9baf162ac144fe06102d91cbe53caabf34e477a3862ccd58a419b7ab62bae694d019a7bbe7179b519f576da25
|
data/.markdownlint.json
ADDED
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 3.2.2
|
3
3
|
Exclude:
|
4
4
|
- 'config/routes.rb'
|
5
5
|
NewCops: enable
|
@@ -29,6 +29,9 @@ Style/BlockDelimiters:
|
|
29
29
|
BracesRequiredMethods: ['log']
|
30
30
|
AllowedMethods: ['proc', 'new']
|
31
31
|
Enabled: false
|
32
|
+
Style/HashSyntax:
|
33
|
+
EnforcedShorthandSyntax: either
|
34
|
+
EnforcedStyle: no_mixed_keys
|
32
35
|
Style/ClassAndModuleChildren:
|
33
36
|
Enabled: false
|
34
37
|
Style/FrozenStringLiteralComment:
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.2
|
data/CHANGELOG.md
CHANGED
@@ -1,238 +1,294 @@
|
|
1
1
|
# Change Log
|
2
|
+
|
2
3
|
All notable changes to this project will be documented in this file.
|
3
4
|
|
5
|
+
## ToDo
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
-
|
8
|
-
-
|
9
|
-
- review `path` tracking
|
7
|
+
- Add update operation for `ContractorEntity`
|
8
|
+
- Add currentOrganization.action
|
9
|
+
- Analyse how to "DSL" currentOrganization.action.activities
|
10
|
+
- review `path` tracking
|
10
11
|
|
11
|
-
## [0.
|
12
|
+
## [0.4.1] - 2024-08-xx
|
12
13
|
|
13
14
|
### Added
|
15
|
+
|
16
|
+
- `ContractorEntity` added field `externalId`
|
17
|
+
|
14
18
|
### Changed
|
19
|
+
|
20
|
+
- gem upgrade `ecoportal-api-v2`
|
21
|
+
|
15
22
|
### Fixed
|
16
23
|
|
24
|
+
## [0.4.0] - 2024-08-01
|
25
|
+
|
26
|
+
### Changed
|
27
|
+
|
28
|
+
- require `ruby 3`
|
29
|
+
|
17
30
|
## [0.3.18] - 2024-05-16
|
18
31
|
|
19
32
|
### Fixed
|
20
|
-
|
21
|
-
|
33
|
+
|
34
|
+
- `Ecoportal::API::GraphQL::Payload::LocationStructure::CommandExecutionResult`
|
35
|
+
- Error is nullable
|
22
36
|
|
23
37
|
## [0.3.17] - 2024-05-14
|
24
38
|
|
25
39
|
### Fixed
|
26
|
-
|
40
|
+
|
41
|
+
- `field_name` should add up to the path
|
27
42
|
|
28
43
|
## [0.3.16] - 2024-04-29
|
29
44
|
|
30
45
|
### Added
|
31
|
-
|
46
|
+
|
47
|
+
- Exposed `graphql` `ContractorEntity` `destroy`
|
48
|
+
|
32
49
|
### Fixed
|
33
|
-
|
50
|
+
|
51
|
+
- incorrect loading
|
34
52
|
|
35
53
|
### Changed
|
36
|
-
|
54
|
+
|
55
|
+
- Input for ContractorEntity create moved as `update` (as it wasn't correct)
|
37
56
|
|
38
57
|
## [0.3.15] - 2024-04-13
|
39
58
|
|
40
59
|
### Added
|
41
|
-
|
42
|
-
|
43
|
-
-
|
60
|
+
|
61
|
+
- `Ecoportal::API::GraphQL::Logic::BaseQuery`
|
62
|
+
- `::base_path` class instance var.
|
63
|
+
- query to retrieve `currentOrganization.classifications`
|
44
64
|
|
45
65
|
### Fixed
|
46
|
-
|
66
|
+
|
67
|
+
- upgraded `ecoportal-api-v2` gem
|
47
68
|
|
48
69
|
## [0.3.14] - 2024-03-13
|
49
70
|
|
50
71
|
### Added
|
51
|
-
|
52
|
-
|
53
|
-
|
72
|
+
|
73
|
+
- some benchmarking on
|
74
|
+
1. core graphql base `query`
|
75
|
+
- `#parent_id` to location node model
|
54
76
|
|
55
77
|
### Changed
|
56
|
-
|
78
|
+
|
79
|
+
- upgraded `ecoportal-v2-api` gem
|
57
80
|
|
58
81
|
### Fixed
|
59
|
-
|
82
|
+
|
83
|
+
- Optimized `treeify` and locations structure class
|
60
84
|
|
61
85
|
## [0.3.13] - 2024-02-03
|
62
86
|
|
63
87
|
### Changed
|
64
|
-
|
88
|
+
|
89
|
+
- upgrade `ecoportal-api-v2`
|
65
90
|
|
66
91
|
## [0.3.12] - 2024-01-27
|
67
92
|
|
68
93
|
### Added
|
69
|
-
|
94
|
+
|
95
|
+
- Exposed `graphql` `Action` `update` and get a single `action`
|
70
96
|
|
71
97
|
## [0.3.11] - 2023-09-19
|
72
98
|
|
73
99
|
### Added
|
74
|
-
|
100
|
+
|
101
|
+
- Exposed `graphql` `ContractorEntity` `create` and `update`
|
75
102
|
|
76
103
|
## [0.3.10] - 2023-08-12
|
77
104
|
|
78
105
|
### Fixed
|
79
|
-
|
80
|
-
|
106
|
+
|
107
|
+
- `Ecopotal::API::GraphQL::Query::LocationStructure`
|
108
|
+
- `query` in basic_block missed an explicitly declared parameter.
|
81
109
|
|
82
110
|
## [0.3.9] - 2023-08-03
|
83
111
|
|
84
112
|
### Added
|
85
|
-
|
86
|
-
|
113
|
+
|
114
|
+
- `Ecoportal::API::GraphQL::Logic::BaseQuery`
|
115
|
+
- Added support for **default** values.
|
87
116
|
|
88
117
|
## [0.3.8] - 2023-07-18
|
89
118
|
|
90
119
|
### Added
|
91
|
-
|
92
|
-
|
93
|
-
|
120
|
+
|
121
|
+
- Integration for archiving actions.
|
122
|
+
- `LocationNodeInterface` -> support for `classifications`
|
123
|
+
- `Treeify` to dump more data per node (classifications)
|
94
124
|
|
95
125
|
### Fixed
|
96
|
-
|
126
|
+
|
127
|
+
- Silenced waning messages when redefining `Fragment`s
|
97
128
|
|
98
129
|
## [0.3.7] - 2023-05-23
|
99
130
|
|
100
131
|
### Fixed
|
101
|
-
|
132
|
+
|
133
|
+
- `Ecoportal::API::Common::GraphQL::Client` adjusted `read_timeout` and `write_timeout` to `90` seconds.
|
102
134
|
|
103
135
|
## [0.3.6] - 2023-04-17
|
104
136
|
|
105
137
|
### Changed
|
106
|
-
|
138
|
+
|
139
|
+
- Softened max version of **gem** dependencies
|
107
140
|
|
108
141
|
### Fixed
|
109
|
-
|
110
|
-
|
142
|
+
|
143
|
+
- `Ecoportal::API::GraphQL::Fragment#define` was not removing previous constants
|
144
|
+
- Changed check method to be `::const_defined?`
|
111
145
|
|
112
146
|
## [0.3.5] - 2023-04-03
|
113
147
|
|
114
148
|
### Fixed
|
115
|
-
|
116
|
-
|
149
|
+
|
150
|
+
- `Ecoportal::API::GraphQL::Helpers::LocationsTree#treeify`
|
151
|
+
- Make it real id-case-insensitive (parents in lower case were being missed due to this)
|
117
152
|
|
118
153
|
## [0.3.4] - 2023-04-03
|
119
154
|
|
120
155
|
### Added
|
121
|
-
|
122
|
-
|
123
|
-
|
156
|
+
|
157
|
+
- `Ecoportal::API::Common::GraphQL::AuthService`
|
158
|
+
- `#session_token` added **token auto-renew** functionality (when token expires in less than 90 minutes)
|
159
|
+
- `#session_token_renewed`
|
124
160
|
|
125
161
|
### Fixed
|
126
|
-
|
162
|
+
|
163
|
+
- Enabled to specify `host` (other than `live.ecoportal.com`) by the user
|
127
164
|
|
128
165
|
## [0.3.3] - 2023-04-02
|
129
166
|
|
130
167
|
### Fixed
|
131
|
-
|
168
|
+
|
169
|
+
- `Ecoportal::API::GraphQL::Base::LocationNode` **added** attribute `archivedToken`
|
132
170
|
|
133
171
|
## [0.3.2] - 2023-04-02
|
134
172
|
|
135
173
|
### Changed
|
136
|
-
|
174
|
+
|
175
|
+
- `Ecoportal::API::GraphQL::Helpers::LocationsTree#treeify` added support for `archived_token`
|
137
176
|
|
138
177
|
## [0.3.1] - 2023-03-09
|
139
178
|
|
140
|
-
### Added
|
141
179
|
### Changed
|
142
|
-
- Upgraded core gem dependency `ecoportal-api-v2`
|
143
180
|
|
181
|
+
- Upgraded core gem dependency `ecoportal-api-v2`
|
144
182
|
|
145
183
|
## [0.2.3] - 2023-02-27
|
146
184
|
|
147
185
|
### Fixed
|
148
|
-
|
186
|
+
|
187
|
+
- Typo in tests LocationsStructures... should read `locationStructures`
|
149
188
|
|
150
189
|
## [0.2.2] - 2023-02-24
|
151
190
|
|
152
191
|
### Fixed
|
153
|
-
|
192
|
+
|
193
|
+
- Build gem correctly
|
154
194
|
|
155
195
|
## [0.2.1] - 2023-02-24
|
156
196
|
|
157
197
|
### Changed
|
158
|
-
|
198
|
+
|
199
|
+
- Migrate from TagTrees to **reporting structures** (breaking change)
|
159
200
|
|
160
201
|
### Added
|
161
|
-
|
202
|
+
|
203
|
+
- Basics for reporting structure mutations
|
162
204
|
|
163
205
|
## [0.1.11] - 2022-11-29
|
164
206
|
|
165
207
|
### Added
|
166
|
-
|
167
|
-
|
208
|
+
|
209
|
+
- `Ecoportal::API::GraphQL::Base::Mutation`
|
210
|
+
- Added `createContractorEntity`
|
168
211
|
|
169
212
|
### Changed
|
170
|
-
|
171
|
-
|
172
|
-
-
|
173
|
-
|
213
|
+
|
214
|
+
- **upgraded** `graphlient` gem dependency (support for framents)
|
215
|
+
- removed patch in this gem
|
216
|
+
- Slight internal refactor of `Ecoportal::API::GraphQL::Base::Query`
|
217
|
+
- Upgraded `ecoportal-api-v2` **gem** dependency
|
174
218
|
|
175
219
|
## [0.1.10] - 2022-09-29
|
176
220
|
|
177
221
|
### Changed
|
178
|
-
|
222
|
+
|
223
|
+
- **upgraded** `ecoportal-api-v2` gem dependency
|
179
224
|
|
180
225
|
### Fixed
|
181
|
-
|
226
|
+
|
227
|
+
- Remove debugging message
|
182
228
|
|
183
229
|
## [0.1.9] - 2022-09-26
|
184
230
|
|
185
231
|
### Added
|
186
|
-
|
232
|
+
|
233
|
+
- `Ecoportal::API::GraphQL::Query::TagTree`
|
187
234
|
|
188
235
|
### Changed
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
-
|
236
|
+
|
237
|
+
- **upgraded** `ecoportal-api-v2` gem dependency
|
238
|
+
- added `Ecoportal::API::Common::GraphQL::QueryIntegration`
|
239
|
+
- restructured `Ecoportal::API::GraphQL::Model::Organization` class
|
240
|
+
- **Patch** on `Graphlient::Query` for fragments support (**pull request**: <https://github.com/ashkan18/graphlient/pull/94>)
|
193
241
|
|
194
242
|
## [0.1.8] - 2022-09-23
|
195
243
|
|
196
244
|
### Added
|
197
|
-
|
245
|
+
|
246
|
+
- `currentOrganization.tagTrees` query
|
198
247
|
|
199
248
|
### Changed
|
200
|
-
|
201
|
-
|
249
|
+
|
250
|
+
- **upgraded** `ecoportal-api-v2` gem dependency
|
251
|
+
- Restructured the `Query` inheritance chain to make things simpler
|
202
252
|
|
203
253
|
## [0.1.6] - 2022-09-19
|
204
254
|
|
205
255
|
### Fixed
|
206
|
-
|
256
|
+
|
257
|
+
- Call to **private** method `remove_const` in `Ecoportal::API::GraphQL::Fragment#define`
|
207
258
|
|
208
259
|
## [0.1.5] - 2022-09-19
|
209
260
|
|
210
261
|
### Added
|
211
|
-
|
212
|
-
|
213
|
-
-
|
214
|
-
|
215
|
-
|
262
|
+
|
263
|
+
- Patch `GraphQL::Query#append_node` so we can use Fragments in blocks using `___` as start of the constant, and `__` for namespace separator
|
264
|
+
- Issue/feature request: <https://github.com/ashkan18/graphlient/issues/93>
|
265
|
+
- `Ecoportal::API::GraphQL::Fragment#define` provided that client scripts can create their own fragments in their own namespace
|
266
|
+
- Exposed `Ecoportal::API::GraphQL#fragments`
|
267
|
+
- It will always (re)define in the `Fragment` root namespace
|
216
268
|
|
217
269
|
## [0.1.4] - 2022-09-16
|
218
270
|
|
219
271
|
### Fixed
|
220
|
-
|
221
|
-
|
222
|
-
|
272
|
+
|
273
|
+
- Able to inject connection block to `each`
|
274
|
+
- Error handling delegated to parent class (`QueryConnection`)
|
275
|
+
- Retrieve `id` on elements of `Array`
|
223
276
|
|
224
277
|
## [0.1.3] - 2022-09-15
|
225
278
|
|
226
279
|
### Fixed
|
227
|
-
|
280
|
+
|
281
|
+
- Fixed circular reference to `org_id` in `Ecoportal::API::Common::GraphQL::Client`
|
228
282
|
|
229
283
|
## [0.1.2] - 2022-09-15
|
230
284
|
|
231
285
|
### Changed
|
232
|
-
|
233
|
-
|
286
|
+
|
287
|
+
- `Ecoportal::API::GraphQL` addded `email` and `pass` parameters on initialization
|
288
|
+
- This allows for integration in some client lib
|
234
289
|
|
235
290
|
## [0.1.0] - 2022-09-15
|
236
291
|
|
237
292
|
### Added
|
238
|
-
|
293
|
+
|
294
|
+
- First commit with some basic structure
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require "ecoportal/api/graphql_version"
|
5
4
|
|
@@ -9,26 +8,27 @@ Gem::Specification.new do |spec|
|
|
9
8
|
spec.authors = ["Oscar Segura"]
|
10
9
|
spec.email = ["oscar@ecoportal.co.nz"]
|
11
10
|
|
12
|
-
spec.summary =
|
11
|
+
spec.summary = "A collection of helpers for interacting with the ecoPortal GraphQL API"
|
13
12
|
spec.homepage = "https://www.ecoportal.com"
|
14
13
|
spec.licenses = %w[MIT]
|
15
14
|
|
16
|
-
spec.
|
15
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
16
|
+
|
17
|
+
spec.required_ruby_version = '>= 3.2.2'
|
17
18
|
|
18
|
-
spec.files
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
20
|
f.match(%r{^(test|spec|features)/})
|
20
21
|
end
|
21
22
|
spec.bindir = "exe"
|
22
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
24
|
spec.require_paths = ["lib"]
|
24
25
|
|
25
|
-
spec.add_development_dependency "bundler", ">= 2.4.12", "< 3"
|
26
26
|
spec.add_development_dependency "rspec", ">= 3.12.0", "< 4"
|
27
27
|
spec.add_development_dependency "rake", ">= 13.0.3", "< 14"
|
28
28
|
spec.add_development_dependency "yard", ">= 0.9.34", "< 1"
|
29
29
|
spec.add_development_dependency "redcarpet", ">= 3.6.0", "< 4"
|
30
30
|
spec.add_development_dependency "pry" , ">= 0.14"
|
31
31
|
|
32
|
-
spec.add_dependency 'ecoportal-api-v2', '
|
32
|
+
spec.add_dependency 'ecoportal-api-v2', '~> 2.0', '>= 2.0.8'
|
33
33
|
spec.add_dependency 'graphlient', '>= 0.8.0', '< 0.9'
|
34
34
|
end
|
@@ -3,15 +3,20 @@ module Ecoportal
|
|
3
3
|
module Common
|
4
4
|
module GraphQL
|
5
5
|
module AuthService
|
6
|
-
DEFAULT_SERVER = "live.ecoportal.com"
|
6
|
+
DEFAULT_SERVER = "live.ecoportal.com".freeze
|
7
7
|
TOKEN_AUTORENEW = 90 # minutes
|
8
8
|
|
9
9
|
module InstanceMethods
|
10
10
|
def session_token(host: server, version: nil, auto_renew: true)
|
11
|
-
session_token_data(host: host, version: version).
|
12
|
-
|
11
|
+
session_token_data(host: host, version: version).then do |body|
|
12
|
+
next unless body
|
13
|
+
|
13
14
|
if auto_renew && token_renew?(body["expires_in"])
|
14
|
-
session_token_renewed(
|
15
|
+
session_token_renewed(
|
16
|
+
host: host,
|
17
|
+
version: version,
|
18
|
+
refresh_token: body["refresh_token"]
|
19
|
+
)
|
15
20
|
else
|
16
21
|
body["access_token"]
|
17
22
|
end
|
@@ -20,41 +25,43 @@ module Ecoportal
|
|
20
25
|
|
21
26
|
def session_token_renewed(host: server, version: nil, refresh_token: nil)
|
22
27
|
unless refresh_token
|
23
|
-
return
|
24
|
-
return
|
28
|
+
return unless (body = session_token_data(host: host, version: version))
|
29
|
+
return unless (refresh_token = body["resfresh_token"])
|
25
30
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
31
|
+
|
32
|
+
session_refresh_token_data(
|
33
|
+
host: host,
|
34
|
+
version: version,
|
35
|
+
refresh_token: refresh_token
|
36
|
+
).then do |bdy|
|
37
|
+
bdy["access_token"] if bdy
|
29
38
|
end
|
30
39
|
end
|
31
40
|
|
32
41
|
private
|
33
42
|
|
34
43
|
def session_token_data(host: server, version: nil)
|
35
|
-
http_client(host: host, version: version).post(
|
36
|
-
"
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
44
|
+
http_client(host: host, version: version).post(
|
45
|
+
"/oauth/token",
|
46
|
+
data: {
|
47
|
+
"grant_type" => "password",
|
48
|
+
"email" => user_email,
|
49
|
+
"password" => user_pass
|
50
|
+
}
|
51
|
+
).then do |response|
|
52
|
+
next response.body if response.success?
|
45
53
|
end
|
46
54
|
end
|
47
55
|
|
48
|
-
def session_refresh_token_data(host: server, version: nil
|
49
|
-
http_client(host: host, version: version).post(
|
50
|
-
"
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
56
|
+
def session_refresh_token_data(refresh_token:, host: server, version: nil)
|
57
|
+
http_client(host: host, version: version).post(
|
58
|
+
"/oauth/token",
|
59
|
+
data: {
|
60
|
+
"grant_type" => "refresh_token",
|
61
|
+
"refresh_token" => refresh_token
|
62
|
+
}
|
63
|
+
).then do |response|
|
64
|
+
next response.body if response.success?
|
58
65
|
end
|
59
66
|
end
|
60
67
|
|
@@ -63,7 +70,10 @@ module Ecoportal
|
|
63
70
|
end
|
64
71
|
|
65
72
|
def http_client(host: server, version: nil)
|
66
|
-
@http_client ||= Ecoportal::API::Common::GraphQL::HttpClient.new(
|
73
|
+
@http_client ||= Ecoportal::API::Common::GraphQL::HttpClient.new(
|
74
|
+
host: host,
|
75
|
+
version: version
|
76
|
+
)
|
67
77
|
end
|
68
78
|
|
69
79
|
def user_email
|
@@ -4,15 +4,21 @@ module Ecoportal
|
|
4
4
|
module Common
|
5
5
|
module GraphQL
|
6
6
|
class Client < ::Graphlient::Client
|
7
|
-
attr_accessor :
|
7
|
+
attr_accessor :host
|
8
8
|
|
9
9
|
READ_TIMEOUT = 90
|
10
10
|
WRITE_TIMEOUT = 90
|
11
11
|
|
12
12
|
include Ecoportal::API::Common::GraphQL::AuthService
|
13
13
|
|
14
|
-
def initialize(
|
15
|
-
|
14
|
+
def initialize(
|
15
|
+
email: nil,
|
16
|
+
pass: nil,
|
17
|
+
org_id: self.org_id,
|
18
|
+
host: server,
|
19
|
+
schema_path: host,
|
20
|
+
no_schema: false
|
21
|
+
)
|
16
22
|
@org_id = org_id
|
17
23
|
@host = host
|
18
24
|
@no_schema = no_schema
|
@@ -20,8 +26,9 @@ module Ecoportal
|
|
20
26
|
@user_pass = pass
|
21
27
|
|
22
28
|
puts "Configuring GraphQL Client onto '#{url}'"
|
29
|
+
|
23
30
|
super(url,
|
24
|
-
headers:
|
31
|
+
headers: {
|
25
32
|
'Authorization' => "Bearer #{session_token(host: host)}"
|
26
33
|
},
|
27
34
|
http_options: {
|
@@ -5,7 +5,7 @@ module Ecoportal
|
|
5
5
|
class HttpClient < Common::Client
|
6
6
|
class << self
|
7
7
|
def base_url(host)
|
8
|
-
|
8
|
+
"#{protocol(host)}://#{host}"
|
9
9
|
end
|
10
10
|
|
11
11
|
def protocol(host)
|
@@ -15,8 +15,20 @@ module Ecoportal
|
|
15
15
|
|
16
16
|
attr_reader :host, :version
|
17
17
|
|
18
|
-
def initialize(
|
19
|
-
|
18
|
+
def initialize(
|
19
|
+
api_key: nil,
|
20
|
+
version: "v1",
|
21
|
+
host: "live.ecoportal.com",
|
22
|
+
logger: ::Logger.new(IO::NULL),
|
23
|
+
response_logging: false
|
24
|
+
)
|
25
|
+
super(
|
26
|
+
api_key: api_key,
|
27
|
+
version: version,
|
28
|
+
host: host,
|
29
|
+
logger: logger,
|
30
|
+
response_logging: response_logging
|
31
|
+
)
|
20
32
|
end
|
21
33
|
|
22
34
|
def refresh_key(value)
|
@@ -27,7 +39,7 @@ module Ecoportal
|
|
27
39
|
# @note It configures HTTP so it only allows body data in json format.
|
28
40
|
# @return [HTTP] HTTP object.
|
29
41
|
def base_request
|
30
|
-
@base_request ||=
|
42
|
+
@base_request ||=
|
31
43
|
case @version
|
32
44
|
when NilClass
|
33
45
|
HTTP.accept(:json)
|
@@ -38,7 +50,6 @@ module Ecoportal
|
|
38
50
|
else
|
39
51
|
HTTP.headers("X-ApiKey" => key_token).accept(:json)
|
40
52
|
end
|
41
|
-
end
|
42
53
|
end
|
43
54
|
|
44
55
|
# Full URl builder of the request
|
@@ -63,12 +74,12 @@ module Ecoportal
|
|
63
74
|
end
|
64
75
|
|
65
76
|
def base_url_api
|
66
|
-
@
|
77
|
+
@base_url_api ||= "#{base_url}/api/#{version}"
|
67
78
|
end
|
68
79
|
|
69
80
|
def key_token
|
70
81
|
if @api_key.nil? || @api_key.match(/\A\W*\z/)
|
71
|
-
if (version == "v0") && key = ENV['ORG_INT_KEY']
|
82
|
+
if (version == "v0") && (key = ENV['ORG_INT_KEY'])
|
72
83
|
key
|
73
84
|
else
|
74
85
|
puts "Api-key missing!"
|
@@ -13,14 +13,20 @@ module Ecoportal
|
|
13
13
|
def basic_block(&block)
|
14
14
|
connection_block = block || default_connection_block
|
15
15
|
proc {
|
16
|
-
query(
|
16
|
+
query(
|
17
|
+
searchConf: :Search,
|
18
|
+
after: :string,
|
19
|
+
before: :string,
|
20
|
+
first: :int,
|
21
|
+
last: :int
|
22
|
+
) {
|
17
23
|
currentOrganization {
|
18
24
|
contractorEntities(
|
19
25
|
searchConf: :searchConf,
|
20
|
-
after:
|
21
|
-
before:
|
22
|
-
first:
|
23
|
-
last:
|
26
|
+
after: :after,
|
27
|
+
before: :before,
|
28
|
+
first: :first,
|
29
|
+
last: :last,
|
24
30
|
&connection_block
|
25
31
|
)
|
26
32
|
}
|
metadata
CHANGED
@@ -1,35 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecoportal-api-graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 2.4.12
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '3'
|
23
|
-
type: :development
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 2.4.12
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '3'
|
33
13
|
- !ruby/object:Gem::Dependency
|
34
14
|
name: rspec
|
35
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,22 +108,22 @@ dependencies:
|
|
128
108
|
name: ecoportal-api-v2
|
129
109
|
requirement: !ruby/object:Gem::Requirement
|
130
110
|
requirements:
|
131
|
-
- - "
|
111
|
+
- - "~>"
|
132
112
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
134
|
-
- - "
|
113
|
+
version: '2.0'
|
114
|
+
- - ">="
|
135
115
|
- !ruby/object:Gem::Version
|
136
|
-
version:
|
116
|
+
version: 2.0.8
|
137
117
|
type: :runtime
|
138
118
|
prerelease: false
|
139
119
|
version_requirements: !ruby/object:Gem::Requirement
|
140
120
|
requirements:
|
141
|
-
- - "
|
121
|
+
- - "~>"
|
142
122
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
144
|
-
- - "
|
123
|
+
version: '2.0'
|
124
|
+
- - ">="
|
145
125
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
126
|
+
version: 2.0.8
|
147
127
|
- !ruby/object:Gem::Dependency
|
148
128
|
name: graphlient
|
149
129
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,8 +152,10 @@ extensions: []
|
|
172
152
|
extra_rdoc_files: []
|
173
153
|
files:
|
174
154
|
- ".gitignore"
|
155
|
+
- ".markdownlint.json"
|
175
156
|
- ".rspec"
|
176
157
|
- ".rubocop.yml"
|
158
|
+
- ".ruby-version"
|
177
159
|
- ".yardopts"
|
178
160
|
- CHANGELOG.md
|
179
161
|
- Gemfile
|
@@ -317,7 +299,8 @@ files:
|
|
317
299
|
homepage: https://www.ecoportal.com
|
318
300
|
licenses:
|
319
301
|
- MIT
|
320
|
-
metadata:
|
302
|
+
metadata:
|
303
|
+
rubygems_mfa_required: 'true'
|
321
304
|
post_install_message:
|
322
305
|
rdoc_options: []
|
323
306
|
require_paths:
|
@@ -326,14 +309,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
326
309
|
requirements:
|
327
310
|
- - ">="
|
328
311
|
- !ruby/object:Gem::Version
|
329
|
-
version: 2.
|
312
|
+
version: 3.2.2
|
330
313
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
331
314
|
requirements:
|
332
315
|
- - ">="
|
333
316
|
- !ruby/object:Gem::Version
|
334
317
|
version: '0'
|
335
318
|
requirements: []
|
336
|
-
rubygems_version: 3.
|
319
|
+
rubygems_version: 3.5.6
|
337
320
|
signing_key:
|
338
321
|
specification_version: 4
|
339
322
|
summary: A collection of helpers for interacting with the ecoPortal GraphQL API
|