ecoportal-api-graphql 0.3.17 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22fc169e27555e55157e336492851a42ff0e924bedd9a91efdd7b1b8f02fc9a5
4
- data.tar.gz: '045038332d30bb9377cd6d2be4c06f25c1ef3ab2b725272f9dc3d98bb408246e'
3
+ metadata.gz: 927df3da8239c448be76b32066894a9bb2b8d0aa1f011033da69cf2b7878aa26
4
+ data.tar.gz: 15825f1ab4dc7a5a366d8e504d07a377650422cf8a1e49a5c21494089719ffae
5
5
  SHA512:
6
- metadata.gz: 220537461d551cdb364521804d4bdf50a12e49596398dd400f8afdabec84aa91839805e632184da60d3b837276fbd373ce943512bd4ce20aecfbfe6d2f822adb
7
- data.tar.gz: 477d15cd024fbe35279b0aa35377bc92e95615317a5aef537afa039f46b1e0b8b88766baebb6676195dd73bf2278c69c3592bd5ceb92bd82c5794def56ddfddc
6
+ metadata.gz: 2020d06df814fb28f2b1592d7107d2368ec23eed3731999964202259f7f486dabb7eff70e7105e5c688e02517e1f8784fc09d682a5c0a5f21234a372cd7e8171
7
+ data.tar.gz: d58a1c29ff883c7ea7c26fe931163f9ab4a7b7d81798d69648482bee8d2377fd5866a1b616f264aa530d9dd76c46a812cc51fb2acaaf2f9a61c3614388f3a4eb
@@ -0,0 +1,4 @@
1
+ {
2
+ "MD013": false,
3
+ "MD024": false
4
+ }
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.7.8
2
+ TargetRubyVersion: 3.2.2
3
3
  Exclude:
4
4
  - 'config/routes.rb'
5
5
  NewCops: enable
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -1,234 +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
- ### ToDo
6
- - Add update operation for `ContractorEntity`
7
- - Add currentOrganization.action
8
- - Analyse how to "DSL" currentOrganization.action.activities
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.3.18] - 2024-05-xx
12
+ ## [0.4.0] - 2024-08-01
12
13
 
13
14
  ### Added
15
+
14
16
  ### Changed
17
+
18
+ - require `ruby 3`
19
+
20
+ ### Fixed
21
+
22
+ ## [0.3.18] - 2024-05-16
23
+
15
24
  ### Fixed
16
25
 
26
+ - `Ecoportal::API::GraphQL::Payload::LocationStructure::CommandExecutionResult`
27
+ - Error is nullable
28
+
17
29
  ## [0.3.17] - 2024-05-14
18
30
 
19
- ### Added
20
- ### Changed
21
31
  ### Fixed
22
- - `field_name` should add up to the path
32
+
33
+ - `field_name` should add up to the path
23
34
 
24
35
  ## [0.3.16] - 2024-04-29
25
36
 
26
37
  ### Added
27
- - Exposed `graphql` `ContractorEntity` `destroy`
38
+
39
+ - Exposed `graphql` `ContractorEntity` `destroy`
40
+
28
41
  ### Fixed
29
- - incorrect loading
42
+
43
+ - incorrect loading
30
44
 
31
45
  ### Changed
32
- - Input for ContractorEntity create moved as `update` (as it wasn't correct)
46
+
47
+ - Input for ContractorEntity create moved as `update` (as it wasn't correct)
33
48
 
34
49
  ## [0.3.15] - 2024-04-13
35
50
 
36
51
  ### Added
37
- - `Ecoportal::API::GraphQL::Logic::BaseQuery`
38
- - `::base_path` class instance var.
39
- - query to retrieve `currentOrganization.classifications`
52
+
53
+ - `Ecoportal::API::GraphQL::Logic::BaseQuery`
54
+ - `::base_path` class instance var.
55
+ - query to retrieve `currentOrganization.classifications`
40
56
 
41
57
  ### Fixed
42
- - upgraded `ecoportal-api-v2` gem
58
+
59
+ - upgraded `ecoportal-api-v2` gem
43
60
 
44
61
  ## [0.3.14] - 2024-03-13
45
62
 
46
63
  ### Added
47
- - some benchmarking on
48
- 1. core graphql base `query`
49
- - `#parent_id` to location node model
64
+
65
+ - some benchmarking on
66
+ 1. core graphql base `query`
67
+ - `#parent_id` to location node model
50
68
 
51
69
  ### Changed
52
- - upgraded `ecoportal-v2-api` gem
70
+
71
+ - upgraded `ecoportal-v2-api` gem
53
72
 
54
73
  ### Fixed
55
- - Optimized `treeify` and locations structure class
74
+
75
+ - Optimized `treeify` and locations structure class
56
76
 
57
77
  ## [0.3.13] - 2024-02-03
58
78
 
59
79
  ### Changed
60
- - upgrade `ecoportal-api-v2`
80
+
81
+ - upgrade `ecoportal-api-v2`
61
82
 
62
83
  ## [0.3.12] - 2024-01-27
63
84
 
64
85
  ### Added
65
- - Exposed `graphql` `Action` `update` and get a single `action`
86
+
87
+ - Exposed `graphql` `Action` `update` and get a single `action`
66
88
 
67
89
  ## [0.3.11] - 2023-09-19
68
90
 
69
91
  ### Added
70
- - Exposed `graphql` `ContractorEntity` `create` and `update`
92
+
93
+ - Exposed `graphql` `ContractorEntity` `create` and `update`
71
94
 
72
95
  ## [0.3.10] - 2023-08-12
73
96
 
74
97
  ### Fixed
75
- - `Ecopotal::API::GraphQL::Query::LocationStructure`
76
- - `query` in basic_block missed an explicitly declared parameter.
98
+
99
+ - `Ecopotal::API::GraphQL::Query::LocationStructure`
100
+ - `query` in basic_block missed an explicitly declared parameter.
77
101
 
78
102
  ## [0.3.9] - 2023-08-03
79
103
 
80
104
  ### Added
81
- - `Ecoportal::API::GraphQL::Logic::BaseQuery`
82
- - Added support for **default** values.
105
+
106
+ - `Ecoportal::API::GraphQL::Logic::BaseQuery`
107
+ - Added support for **default** values.
83
108
 
84
109
  ## [0.3.8] - 2023-07-18
85
110
 
86
111
  ### Added
87
- - Integration for archiving actions.
88
- - `LocationNodeInterface` -> support for `classifications`
89
- - `Treeify` to dump more data per node (classifications)
112
+
113
+ - Integration for archiving actions.
114
+ - `LocationNodeInterface` -> support for `classifications`
115
+ - `Treeify` to dump more data per node (classifications)
90
116
 
91
117
  ### Fixed
92
- - Silenced waning messages when redefining `Fragment`s
118
+
119
+ - Silenced waning messages when redefining `Fragment`s
93
120
 
94
121
  ## [0.3.7] - 2023-05-23
95
122
 
96
123
  ### Fixed
97
- - `Ecoportal::API::Common::GraphQL::Client` adjusted `read_timeout` and `write_timeout` to `90` seconds.
124
+
125
+ - `Ecoportal::API::Common::GraphQL::Client` adjusted `read_timeout` and `write_timeout` to `90` seconds.
98
126
 
99
127
  ## [0.3.6] - 2023-04-17
100
128
 
101
129
  ### Changed
102
- - Softened max version of **gem** dependencies
130
+
131
+ - Softened max version of **gem** dependencies
103
132
 
104
133
  ### Fixed
105
- - `Ecoportal::API::GraphQL::Fragment#define` was not removing previous constants
106
- - Changed check method to be `::const_defined?`
134
+
135
+ - `Ecoportal::API::GraphQL::Fragment#define` was not removing previous constants
136
+ - Changed check method to be `::const_defined?`
107
137
 
108
138
  ## [0.3.5] - 2023-04-03
109
139
 
110
140
  ### Fixed
111
- - `Ecoportal::API::GraphQL::Helpers::LocationsTree#treeify`
112
- - Make it real id-case-insensitive (parents in lower case were being missed due to this)
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)
113
144
 
114
145
  ## [0.3.4] - 2023-04-03
115
146
 
116
147
  ### Added
117
- - `Ecoportal::API::Common::GraphQL::AuthService`
118
- - `#session_token` added **token auto-renew** functionality (when token expires in less than 90 minutes)
119
- - `#session_token_renewed`
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`
120
152
 
121
153
  ### Fixed
122
- - Enabled to specify `host` (other than `live.ecoportal.com`) by the user
154
+
155
+ - Enabled to specify `host` (other than `live.ecoportal.com`) by the user
123
156
 
124
157
  ## [0.3.3] - 2023-04-02
125
158
 
126
159
  ### Fixed
127
- - `Ecoportal::API::GraphQL::Base::LocationNode` **added** attribute `archivedToken`
160
+
161
+ - `Ecoportal::API::GraphQL::Base::LocationNode` **added** attribute `archivedToken`
128
162
 
129
163
  ## [0.3.2] - 2023-04-02
130
164
 
131
165
  ### Changed
132
- - `Ecoportal::API::GraphQL::Helpers::LocationsTree#treeify` added support for `archived_token`
166
+
167
+ - `Ecoportal::API::GraphQL::Helpers::LocationsTree#treeify` added support for `archived_token`
133
168
 
134
169
  ## [0.3.1] - 2023-03-09
135
170
 
136
- ### Added
137
171
  ### Changed
138
- - Upgraded core gem dependency `ecoportal-api-v2`
139
172
 
173
+ - Upgraded core gem dependency `ecoportal-api-v2`
140
174
 
141
175
  ## [0.2.3] - 2023-02-27
142
176
 
143
177
  ### Fixed
144
- - Typo in tests LocationsStructures... should read `locationStructures`
178
+
179
+ - Typo in tests LocationsStructures... should read `locationStructures`
145
180
 
146
181
  ## [0.2.2] - 2023-02-24
147
182
 
148
183
  ### Fixed
149
- - Build gem correctly
184
+
185
+ - Build gem correctly
150
186
 
151
187
  ## [0.2.1] - 2023-02-24
152
188
 
153
189
  ### Changed
154
- - Migrate from TagTrees to **reporting structures** (breaking change)
190
+
191
+ - Migrate from TagTrees to **reporting structures** (breaking change)
155
192
 
156
193
  ### Added
157
- - Basics for reporting structure mutations
194
+
195
+ - Basics for reporting structure mutations
158
196
 
159
197
  ## [0.1.11] - 2022-11-29
160
198
 
161
199
  ### Added
162
- - `Ecoportal::API::GraphQL::Base::Mutation`
163
- - Added `createContractorEntity`
200
+
201
+ - `Ecoportal::API::GraphQL::Base::Mutation`
202
+ - Added `createContractorEntity`
164
203
 
165
204
  ### Changed
166
- - **upgraded** `graphlient` gem dependency (support for framents)
167
- - removed patch in this gem
168
- - Slight internal refactor of `Ecoportal::API::GraphQL::Base::Query`
169
- - Upgraded `ecoportal-api-v2` **gem** dependency
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
170
210
 
171
211
  ## [0.1.10] - 2022-09-29
172
212
 
173
213
  ### Changed
174
- - **upgraded** `ecoportal-api-v2` gem dependency
214
+
215
+ - **upgraded** `ecoportal-api-v2` gem dependency
175
216
 
176
217
  ### Fixed
177
- - Remove debugging message
218
+
219
+ - Remove debugging message
178
220
 
179
221
  ## [0.1.9] - 2022-09-26
180
222
 
181
223
  ### Added
182
- - `Ecoportal::API::GraphQL::Query::TagTree`
224
+
225
+ - `Ecoportal::API::GraphQL::Query::TagTree`
183
226
 
184
227
  ### Changed
185
- - **upgraded** `ecoportal-api-v2` gem dependency
186
- - added `Ecoportal::API::Common::GraphQL::QueryIntegration`
187
- - restructured `Ecoportal::API::GraphQL::Model::Organization` class
188
- - **Patch** on `Graphlient::Query` for fragments support (**pull request**: https://github.com/ashkan18/graphlient/pull/94)
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>)
189
233
 
190
234
  ## [0.1.8] - 2022-09-23
191
235
 
192
236
  ### Added
193
- - `currentOrganization.tagTrees` query
237
+
238
+ - `currentOrganization.tagTrees` query
194
239
 
195
240
  ### Changed
196
- - **upgraded** `ecoportal-api-v2` gem dependency
197
- - Restructured the `Query` inheritance chain to make things simpler
241
+
242
+ - **upgraded** `ecoportal-api-v2` gem dependency
243
+ - Restructured the `Query` inheritance chain to make things simpler
198
244
 
199
245
  ## [0.1.6] - 2022-09-19
200
246
 
201
247
  ### Fixed
202
- - Call to **private** method `remove_const` in `Ecoportal::API::GraphQL::Fragment#define`
248
+
249
+ - Call to **private** method `remove_const` in `Ecoportal::API::GraphQL::Fragment#define`
203
250
 
204
251
  ## [0.1.5] - 2022-09-19
205
252
 
206
253
  ### Added
207
- - Patch `GraphQL::Query#append_node` so we can use Fragments in blocks using `___` as start of the constant, and `__` for namespace separator
208
- - Issue/feature request: https://github.com/ashkan18/graphlient/issues/93
209
- - `Ecoportal::API::GraphQL::Fragment#define` provided that client scripts can create their own fragments in their own namespace
210
- - Exposed `Ecoportal::API::GraphQL#fragments`
211
- - It will always (re)define in the `Fragment` root namespace
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
212
260
 
213
261
  ## [0.1.4] - 2022-09-16
214
262
 
215
263
  ### Fixed
216
- - Able to inject connection block to `each`
217
- - Error handling delegated to parent class (`QueryConnection`)
218
- - Retrieve `id` on elements of `Array`
264
+
265
+ - Able to inject connection block to `each`
266
+ - Error handling delegated to parent class (`QueryConnection`)
267
+ - Retrieve `id` on elements of `Array`
219
268
 
220
269
  ## [0.1.3] - 2022-09-15
221
270
 
222
271
  ### Fixed
223
- - Fixed circular reference to `org_id` in `Ecoportal::API::Common::GraphQL::Client`
272
+
273
+ - Fixed circular reference to `org_id` in `Ecoportal::API::Common::GraphQL::Client`
224
274
 
225
275
  ## [0.1.2] - 2022-09-15
226
276
 
227
277
  ### Changed
228
- - `Ecoportal::API::GraphQL` addded `email` and `pass` parameters on initialization
229
- - This allows for integration in some client lib
278
+
279
+ - `Ecoportal::API::GraphQL` addded `email` and `pass` parameters on initialization
280
+ - This allows for integration in some client lib
230
281
 
231
282
  ## [0.1.0] - 2022-09-15
232
283
 
233
284
  ### Added
234
- - First commit with some basic structure
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 = %q{A collection of helpers for interacting with the ecoPortal GraphQL API}
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.required_ruby_version = '>= 2.7.0'
15
+ spec.metadata['rubygems_mfa_required'] = 'true'
16
+
17
+ spec.required_ruby_version = '>= 3.2.2'
17
18
 
18
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
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', '>= 1.1.8', '< 1.2'
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).yield_self do |body|
12
- return nil unless body
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(host: host, version: version, refresh_token: body["refresh_token"])
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 nil unless body = session_token_data(host: host, version: version)
24
- return nil unless refresh_token = body["resfresh_token"]
28
+ return unless (body = session_token_data(host: host, version: version))
29
+ return unless (refresh_token = body["resfresh_token"])
25
30
  end
26
- session_refresh_token_data(host: host, version: version, refresh_token: refresh_token).yield_self do |body|
27
- return nil unless body
28
- body["access_token"] if body
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("/oauth/token", data: {
36
- "grant_type" => "password",
37
- "email" => user_email,
38
- "password" => user_pass
39
- }).yield_self do |response|
40
- if response.success?
41
- response.body
42
- else
43
- nil
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, refresh_token:)
49
- http_client(host: host, version: version).post("/oauth/token", data: {
50
- "grant_type" => "refresh_token",
51
- "refresh_token" => refresh_token
52
- }).yield_self do |response|
53
- if response.success?
54
- response.body
55
- else
56
- nil
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(host: host, version: version)
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 :org_id, :host
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(email: nil, pass: nil, org_id: self.org_id,
15
- host: server, schema_path: host, no_schema: false)
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
- "#{protocol(host)}://#{host}"
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(api_key: nil, version: "v1", host: "live.ecoportal.com", logger: ::Logger.new(IO::NULL), response_logging: false)
19
- super(api_key: api_key, version: version, host: host, logger: logger, response_logging: false)
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 ||= begin
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
- @base_uri_api ||= "#{base_url}/api/#{version}"
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!"
@@ -39,7 +39,9 @@ module Ecoportal
39
39
  private
40
40
 
41
41
  def without_warnings
42
- original_verbose, $VERBOSE = $VERBOSE, nil
42
+ original_verbose = $VERBOSE
43
+ $VERBOSE = nil
44
+
43
45
  yield if block_given?
44
46
  ensure
45
47
  $VERBOSE = original_verbose
@@ -5,7 +5,7 @@ module Ecoportal
5
5
  module LocationStructure
6
6
  class CommandExecutionResult < Ecoportal::API::GraphQL::Base::Model
7
7
  embeds_one :command, klass: Ecoportal::API::GraphQL::Payload::LocationStructure::CommandInterface
8
- embeds_one :error, klass: Ecoportal::API::GraphQL::Error::LocationsError
8
+ embeds_one :error, nullable: true, klass: Ecoportal::API::GraphQL::Error::LocationsError
9
9
  passboolean :ok
10
10
  end
11
11
  end
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- GRAPQL_VERSION = '0.3.17'.freeze
3
+ GRAPQL_VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
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.3.17
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-05-14 00:00:00.000000000 Z
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: 1.1.8
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: '1.2'
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.7.0
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.4.12
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