ecoportal-api-graphql 0.3.18 → 0.4.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/.markdownlint.json +4 -0
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -0
- data/CHANGELOG.md +127 -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 +10 -4
- data/lib/ecoportal/api/common/graphql/http_client.rb +18 -7
- data/lib/ecoportal/api/graphql/fragment.rb +3 -1
- data/lib/ecoportal/api/graphql_version.rb +1 -1
- metadata +12 -35
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 927df3da8239c448be76b32066894a9bb2b8d0aa1f011033da69cf2b7878aa26
|
|
4
|
+
data.tar.gz: 15825f1ab4dc7a5a366d8e504d07a377650422cf8a1e49a5c21494089719ffae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2020d06df814fb28f2b1592d7107d2368ec23eed3731999964202259f7f486dabb7eff70e7105e5c688e02517e1f8784fc09d682a5c0a5f21234a372cd7e8171
|
|
7
|
+
data.tar.gz: d58a1c29ff883c7ea7c26fe931163f9ab4a7b7d81798d69648482bee8d2377fd5866a1b616f264aa530d9dd76c46a812cc51fb2acaaf2f9a61c3614388f3a4eb
|
data/.markdownlint.json
ADDED
data/.rubocop.yml
CHANGED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.2.2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,238 +1,286 @@
|
|
|
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.0] - 2024-08-01
|
|
12
13
|
|
|
13
14
|
### Added
|
|
15
|
+
|
|
14
16
|
### Changed
|
|
17
|
+
|
|
18
|
+
- require `ruby 3`
|
|
19
|
+
|
|
15
20
|
### Fixed
|
|
16
21
|
|
|
17
22
|
## [0.3.18] - 2024-05-16
|
|
18
23
|
|
|
19
24
|
### Fixed
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
|
|
26
|
+
- `Ecoportal::API::GraphQL::Payload::LocationStructure::CommandExecutionResult`
|
|
27
|
+
- Error is nullable
|
|
22
28
|
|
|
23
29
|
## [0.3.17] - 2024-05-14
|
|
24
30
|
|
|
25
31
|
### Fixed
|
|
26
|
-
|
|
32
|
+
|
|
33
|
+
- `field_name` should add up to the path
|
|
27
34
|
|
|
28
35
|
## [0.3.16] - 2024-04-29
|
|
29
36
|
|
|
30
37
|
### Added
|
|
31
|
-
|
|
38
|
+
|
|
39
|
+
- Exposed `graphql` `ContractorEntity` `destroy`
|
|
40
|
+
|
|
32
41
|
### Fixed
|
|
33
|
-
|
|
42
|
+
|
|
43
|
+
- incorrect loading
|
|
34
44
|
|
|
35
45
|
### Changed
|
|
36
|
-
|
|
46
|
+
|
|
47
|
+
- Input for ContractorEntity create moved as `update` (as it wasn't correct)
|
|
37
48
|
|
|
38
49
|
## [0.3.15] - 2024-04-13
|
|
39
50
|
|
|
40
51
|
### Added
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
-
|
|
52
|
+
|
|
53
|
+
- `Ecoportal::API::GraphQL::Logic::BaseQuery`
|
|
54
|
+
- `::base_path` class instance var.
|
|
55
|
+
- query to retrieve `currentOrganization.classifications`
|
|
44
56
|
|
|
45
57
|
### Fixed
|
|
46
|
-
|
|
58
|
+
|
|
59
|
+
- upgraded `ecoportal-api-v2` gem
|
|
47
60
|
|
|
48
61
|
## [0.3.14] - 2024-03-13
|
|
49
62
|
|
|
50
63
|
### Added
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
|
|
65
|
+
- some benchmarking on
|
|
66
|
+
1. core graphql base `query`
|
|
67
|
+
- `#parent_id` to location node model
|
|
54
68
|
|
|
55
69
|
### Changed
|
|
56
|
-
|
|
70
|
+
|
|
71
|
+
- upgraded `ecoportal-v2-api` gem
|
|
57
72
|
|
|
58
73
|
### Fixed
|
|
59
|
-
|
|
74
|
+
|
|
75
|
+
- Optimized `treeify` and locations structure class
|
|
60
76
|
|
|
61
77
|
## [0.3.13] - 2024-02-03
|
|
62
78
|
|
|
63
79
|
### Changed
|
|
64
|
-
|
|
80
|
+
|
|
81
|
+
- upgrade `ecoportal-api-v2`
|
|
65
82
|
|
|
66
83
|
## [0.3.12] - 2024-01-27
|
|
67
84
|
|
|
68
85
|
### Added
|
|
69
|
-
|
|
86
|
+
|
|
87
|
+
- Exposed `graphql` `Action` `update` and get a single `action`
|
|
70
88
|
|
|
71
89
|
## [0.3.11] - 2023-09-19
|
|
72
90
|
|
|
73
91
|
### Added
|
|
74
|
-
|
|
92
|
+
|
|
93
|
+
- Exposed `graphql` `ContractorEntity` `create` and `update`
|
|
75
94
|
|
|
76
95
|
## [0.3.10] - 2023-08-12
|
|
77
96
|
|
|
78
97
|
### Fixed
|
|
79
|
-
|
|
80
|
-
|
|
98
|
+
|
|
99
|
+
- `Ecopotal::API::GraphQL::Query::LocationStructure`
|
|
100
|
+
- `query` in basic_block missed an explicitly declared parameter.
|
|
81
101
|
|
|
82
102
|
## [0.3.9] - 2023-08-03
|
|
83
103
|
|
|
84
104
|
### Added
|
|
85
|
-
|
|
86
|
-
|
|
105
|
+
|
|
106
|
+
- `Ecoportal::API::GraphQL::Logic::BaseQuery`
|
|
107
|
+
- Added support for **default** values.
|
|
87
108
|
|
|
88
109
|
## [0.3.8] - 2023-07-18
|
|
89
110
|
|
|
90
111
|
### Added
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
112
|
+
|
|
113
|
+
- Integration for archiving actions.
|
|
114
|
+
- `LocationNodeInterface` -> support for `classifications`
|
|
115
|
+
- `Treeify` to dump more data per node (classifications)
|
|
94
116
|
|
|
95
117
|
### Fixed
|
|
96
|
-
|
|
118
|
+
|
|
119
|
+
- Silenced waning messages when redefining `Fragment`s
|
|
97
120
|
|
|
98
121
|
## [0.3.7] - 2023-05-23
|
|
99
122
|
|
|
100
123
|
### Fixed
|
|
101
|
-
|
|
124
|
+
|
|
125
|
+
- `Ecoportal::API::Common::GraphQL::Client` adjusted `read_timeout` and `write_timeout` to `90` seconds.
|
|
102
126
|
|
|
103
127
|
## [0.3.6] - 2023-04-17
|
|
104
128
|
|
|
105
129
|
### Changed
|
|
106
|
-
|
|
130
|
+
|
|
131
|
+
- Softened max version of **gem** dependencies
|
|
107
132
|
|
|
108
133
|
### Fixed
|
|
109
|
-
|
|
110
|
-
|
|
134
|
+
|
|
135
|
+
- `Ecoportal::API::GraphQL::Fragment#define` was not removing previous constants
|
|
136
|
+
- Changed check method to be `::const_defined?`
|
|
111
137
|
|
|
112
138
|
## [0.3.5] - 2023-04-03
|
|
113
139
|
|
|
114
140
|
### Fixed
|
|
115
|
-
|
|
116
|
-
|
|
141
|
+
|
|
142
|
+
- `Ecoportal::API::GraphQL::Helpers::LocationsTree#treeify`
|
|
143
|
+
- Make it real id-case-insensitive (parents in lower case were being missed due to this)
|
|
117
144
|
|
|
118
145
|
## [0.3.4] - 2023-04-03
|
|
119
146
|
|
|
120
147
|
### Added
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
148
|
+
|
|
149
|
+
- `Ecoportal::API::Common::GraphQL::AuthService`
|
|
150
|
+
- `#session_token` added **token auto-renew** functionality (when token expires in less than 90 minutes)
|
|
151
|
+
- `#session_token_renewed`
|
|
124
152
|
|
|
125
153
|
### Fixed
|
|
126
|
-
|
|
154
|
+
|
|
155
|
+
- Enabled to specify `host` (other than `live.ecoportal.com`) by the user
|
|
127
156
|
|
|
128
157
|
## [0.3.3] - 2023-04-02
|
|
129
158
|
|
|
130
159
|
### Fixed
|
|
131
|
-
|
|
160
|
+
|
|
161
|
+
- `Ecoportal::API::GraphQL::Base::LocationNode` **added** attribute `archivedToken`
|
|
132
162
|
|
|
133
163
|
## [0.3.2] - 2023-04-02
|
|
134
164
|
|
|
135
165
|
### Changed
|
|
136
|
-
|
|
166
|
+
|
|
167
|
+
- `Ecoportal::API::GraphQL::Helpers::LocationsTree#treeify` added support for `archived_token`
|
|
137
168
|
|
|
138
169
|
## [0.3.1] - 2023-03-09
|
|
139
170
|
|
|
140
|
-
### Added
|
|
141
171
|
### Changed
|
|
142
|
-
- Upgraded core gem dependency `ecoportal-api-v2`
|
|
143
172
|
|
|
173
|
+
- Upgraded core gem dependency `ecoportal-api-v2`
|
|
144
174
|
|
|
145
175
|
## [0.2.3] - 2023-02-27
|
|
146
176
|
|
|
147
177
|
### Fixed
|
|
148
|
-
|
|
178
|
+
|
|
179
|
+
- Typo in tests LocationsStructures... should read `locationStructures`
|
|
149
180
|
|
|
150
181
|
## [0.2.2] - 2023-02-24
|
|
151
182
|
|
|
152
183
|
### Fixed
|
|
153
|
-
|
|
184
|
+
|
|
185
|
+
- Build gem correctly
|
|
154
186
|
|
|
155
187
|
## [0.2.1] - 2023-02-24
|
|
156
188
|
|
|
157
189
|
### Changed
|
|
158
|
-
|
|
190
|
+
|
|
191
|
+
- Migrate from TagTrees to **reporting structures** (breaking change)
|
|
159
192
|
|
|
160
193
|
### Added
|
|
161
|
-
|
|
194
|
+
|
|
195
|
+
- Basics for reporting structure mutations
|
|
162
196
|
|
|
163
197
|
## [0.1.11] - 2022-11-29
|
|
164
198
|
|
|
165
199
|
### Added
|
|
166
|
-
|
|
167
|
-
|
|
200
|
+
|
|
201
|
+
- `Ecoportal::API::GraphQL::Base::Mutation`
|
|
202
|
+
- Added `createContractorEntity`
|
|
168
203
|
|
|
169
204
|
### Changed
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
-
|
|
173
|
-
|
|
205
|
+
|
|
206
|
+
- **upgraded** `graphlient` gem dependency (support for framents)
|
|
207
|
+
- removed patch in this gem
|
|
208
|
+
- Slight internal refactor of `Ecoportal::API::GraphQL::Base::Query`
|
|
209
|
+
- Upgraded `ecoportal-api-v2` **gem** dependency
|
|
174
210
|
|
|
175
211
|
## [0.1.10] - 2022-09-29
|
|
176
212
|
|
|
177
213
|
### Changed
|
|
178
|
-
|
|
214
|
+
|
|
215
|
+
- **upgraded** `ecoportal-api-v2` gem dependency
|
|
179
216
|
|
|
180
217
|
### Fixed
|
|
181
|
-
|
|
218
|
+
|
|
219
|
+
- Remove debugging message
|
|
182
220
|
|
|
183
221
|
## [0.1.9] - 2022-09-26
|
|
184
222
|
|
|
185
223
|
### Added
|
|
186
|
-
|
|
224
|
+
|
|
225
|
+
- `Ecoportal::API::GraphQL::Query::TagTree`
|
|
187
226
|
|
|
188
227
|
### Changed
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
-
|
|
228
|
+
|
|
229
|
+
- **upgraded** `ecoportal-api-v2` gem dependency
|
|
230
|
+
- added `Ecoportal::API::Common::GraphQL::QueryIntegration`
|
|
231
|
+
- restructured `Ecoportal::API::GraphQL::Model::Organization` class
|
|
232
|
+
- **Patch** on `Graphlient::Query` for fragments support (**pull request**: <https://github.com/ashkan18/graphlient/pull/94>)
|
|
193
233
|
|
|
194
234
|
## [0.1.8] - 2022-09-23
|
|
195
235
|
|
|
196
236
|
### Added
|
|
197
|
-
|
|
237
|
+
|
|
238
|
+
- `currentOrganization.tagTrees` query
|
|
198
239
|
|
|
199
240
|
### Changed
|
|
200
|
-
|
|
201
|
-
|
|
241
|
+
|
|
242
|
+
- **upgraded** `ecoportal-api-v2` gem dependency
|
|
243
|
+
- Restructured the `Query` inheritance chain to make things simpler
|
|
202
244
|
|
|
203
245
|
## [0.1.6] - 2022-09-19
|
|
204
246
|
|
|
205
247
|
### Fixed
|
|
206
|
-
|
|
248
|
+
|
|
249
|
+
- Call to **private** method `remove_const` in `Ecoportal::API::GraphQL::Fragment#define`
|
|
207
250
|
|
|
208
251
|
## [0.1.5] - 2022-09-19
|
|
209
252
|
|
|
210
253
|
### Added
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
-
|
|
214
|
-
|
|
215
|
-
|
|
254
|
+
|
|
255
|
+
- Patch `GraphQL::Query#append_node` so we can use Fragments in blocks using `___` as start of the constant, and `__` for namespace separator
|
|
256
|
+
- Issue/feature request: <https://github.com/ashkan18/graphlient/issues/93>
|
|
257
|
+
- `Ecoportal::API::GraphQL::Fragment#define` provided that client scripts can create their own fragments in their own namespace
|
|
258
|
+
- Exposed `Ecoportal::API::GraphQL#fragments`
|
|
259
|
+
- It will always (re)define in the `Fragment` root namespace
|
|
216
260
|
|
|
217
261
|
## [0.1.4] - 2022-09-16
|
|
218
262
|
|
|
219
263
|
### Fixed
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
264
|
+
|
|
265
|
+
- Able to inject connection block to `each`
|
|
266
|
+
- Error handling delegated to parent class (`QueryConnection`)
|
|
267
|
+
- Retrieve `id` on elements of `Array`
|
|
223
268
|
|
|
224
269
|
## [0.1.3] - 2022-09-15
|
|
225
270
|
|
|
226
271
|
### Fixed
|
|
227
|
-
|
|
272
|
+
|
|
273
|
+
- Fixed circular reference to `org_id` in `Ecoportal::API::Common::GraphQL::Client`
|
|
228
274
|
|
|
229
275
|
## [0.1.2] - 2022-09-15
|
|
230
276
|
|
|
231
277
|
### Changed
|
|
232
|
-
|
|
233
|
-
|
|
278
|
+
|
|
279
|
+
- `Ecoportal::API::GraphQL` addded `email` and `pass` parameters on initialization
|
|
280
|
+
- This allows for integration in some client lib
|
|
234
281
|
|
|
235
282
|
## [0.1.0] - 2022-09-15
|
|
236
283
|
|
|
237
284
|
### Added
|
|
238
|
-
|
|
285
|
+
|
|
286
|
+
- 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'
|
|
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
|
|
@@ -21,7 +27,7 @@ module Ecoportal
|
|
|
21
27
|
|
|
22
28
|
puts "Configuring GraphQL Client onto '#{url}'"
|
|
23
29
|
super(url,
|
|
24
|
-
headers:
|
|
30
|
+
headers: {
|
|
25
31
|
'Authorization' => "Bearer #{session_token(host: host)}"
|
|
26
32
|
},
|
|
27
33
|
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!"
|
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.0
|
|
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-01 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,16 @@ 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
|
-
- - "<"
|
|
135
|
-
- !ruby/object:Gem::Version
|
|
136
|
-
version: '1.2'
|
|
113
|
+
version: '2.0'
|
|
137
114
|
type: :runtime
|
|
138
115
|
prerelease: false
|
|
139
116
|
version_requirements: !ruby/object:Gem::Requirement
|
|
140
117
|
requirements:
|
|
141
|
-
- - "
|
|
142
|
-
- !ruby/object:Gem::Version
|
|
143
|
-
version: 1.1.8
|
|
144
|
-
- - "<"
|
|
118
|
+
- - "~>"
|
|
145
119
|
- !ruby/object:Gem::Version
|
|
146
|
-
version: '
|
|
120
|
+
version: '2.0'
|
|
147
121
|
- !ruby/object:Gem::Dependency
|
|
148
122
|
name: graphlient
|
|
149
123
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -172,8 +146,10 @@ extensions: []
|
|
|
172
146
|
extra_rdoc_files: []
|
|
173
147
|
files:
|
|
174
148
|
- ".gitignore"
|
|
149
|
+
- ".markdownlint.json"
|
|
175
150
|
- ".rspec"
|
|
176
151
|
- ".rubocop.yml"
|
|
152
|
+
- ".ruby-version"
|
|
177
153
|
- ".yardopts"
|
|
178
154
|
- CHANGELOG.md
|
|
179
155
|
- Gemfile
|
|
@@ -317,7 +293,8 @@ files:
|
|
|
317
293
|
homepage: https://www.ecoportal.com
|
|
318
294
|
licenses:
|
|
319
295
|
- MIT
|
|
320
|
-
metadata:
|
|
296
|
+
metadata:
|
|
297
|
+
rubygems_mfa_required: 'true'
|
|
321
298
|
post_install_message:
|
|
322
299
|
rdoc_options: []
|
|
323
300
|
require_paths:
|
|
@@ -326,14 +303,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
326
303
|
requirements:
|
|
327
304
|
- - ">="
|
|
328
305
|
- !ruby/object:Gem::Version
|
|
329
|
-
version: 2.
|
|
306
|
+
version: 3.2.2
|
|
330
307
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
331
308
|
requirements:
|
|
332
309
|
- - ">="
|
|
333
310
|
- !ruby/object:Gem::Version
|
|
334
311
|
version: '0'
|
|
335
312
|
requirements: []
|
|
336
|
-
rubygems_version: 3.
|
|
313
|
+
rubygems_version: 3.5.6
|
|
337
314
|
signing_key:
|
|
338
315
|
specification_version: 4
|
|
339
316
|
summary: A collection of helpers for interacting with the ecoPortal GraphQL API
|