ecoportal-api-graphql 0.3.18 → 0.4.1

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: 53a6919bd12fe2569c78660a80f9ee90b8d23832b2dcb4d4d1cb1daeaf64c085
4
- data.tar.gz: 812287102b4972106660f7983ca9bc1c803dcfef4c152b5fd3890b326954226d
3
+ metadata.gz: 9b010f2e79334e228ef058acb2c53aa92e894907a0a13557188227bb36f5c022
4
+ data.tar.gz: fdf9ca5d6486f68be8655a064a5293f1e92cf9d69bb831705ac9916fca60d836
5
5
  SHA512:
6
- metadata.gz: 845f6fc09d069ea63cdf465583b07fcb8ebfad0a8426059a0917a085809a08cda0ed35e5b4d0338fb917a330ba209af4039178dc823d7d686e106cb19aaf646f
7
- data.tar.gz: f9699d1df470991e24fc9b262a711dea88986ece3fd5eab8cc2176e57b4637b236f7f9aac705768b49dbd398881d034904c5d2e247427c5356b196a65ca15a53
6
+ metadata.gz: c63be5db720017916fc426ec1cc7d4d1cfd4c510834b10ec5addd401abe48f19e5973395165fee8106ac3e8b400b1ae588e7e1a49a7165bf16028f2441f0e17d
7
+ data.tar.gz: 2827e76c1c03965d032a6812ad61f3dcf92940b9baf162ac144fe06102d91cbe53caabf34e477a3862ccd58a419b7ab62bae694d019a7bbe7179b519f576da25
@@ -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
@@ -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
- ### 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.19] - 2024-05-xx
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
- - `Ecoportal::API::GraphQL::Payload::LocationStructure::CommandExecutionResult`
21
- - Error is nullable
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
- - `field_name` should add up to the path
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
- - Exposed `graphql` `ContractorEntity` `destroy`
46
+
47
+ - Exposed `graphql` `ContractorEntity` `destroy`
48
+
32
49
  ### Fixed
33
- - incorrect loading
50
+
51
+ - incorrect loading
34
52
 
35
53
  ### Changed
36
- - Input for ContractorEntity create moved as `update` (as it wasn't correct)
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
- - `Ecoportal::API::GraphQL::Logic::BaseQuery`
42
- - `::base_path` class instance var.
43
- - query to retrieve `currentOrganization.classifications`
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
- - upgraded `ecoportal-api-v2` gem
66
+
67
+ - upgraded `ecoportal-api-v2` gem
47
68
 
48
69
  ## [0.3.14] - 2024-03-13
49
70
 
50
71
  ### Added
51
- - some benchmarking on
52
- 1. core graphql base `query`
53
- - `#parent_id` to location node model
72
+
73
+ - some benchmarking on
74
+ 1. core graphql base `query`
75
+ - `#parent_id` to location node model
54
76
 
55
77
  ### Changed
56
- - upgraded `ecoportal-v2-api` gem
78
+
79
+ - upgraded `ecoportal-v2-api` gem
57
80
 
58
81
  ### Fixed
59
- - Optimized `treeify` and locations structure class
82
+
83
+ - Optimized `treeify` and locations structure class
60
84
 
61
85
  ## [0.3.13] - 2024-02-03
62
86
 
63
87
  ### Changed
64
- - upgrade `ecoportal-api-v2`
88
+
89
+ - upgrade `ecoportal-api-v2`
65
90
 
66
91
  ## [0.3.12] - 2024-01-27
67
92
 
68
93
  ### Added
69
- - Exposed `graphql` `Action` `update` and get a single `action`
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
- - Exposed `graphql` `ContractorEntity` `create` and `update`
100
+
101
+ - Exposed `graphql` `ContractorEntity` `create` and `update`
75
102
 
76
103
  ## [0.3.10] - 2023-08-12
77
104
 
78
105
  ### Fixed
79
- - `Ecopotal::API::GraphQL::Query::LocationStructure`
80
- - `query` in basic_block missed an explicitly declared parameter.
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
- - `Ecoportal::API::GraphQL::Logic::BaseQuery`
86
- - Added support for **default** values.
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
- - Integration for archiving actions.
92
- - `LocationNodeInterface` -> support for `classifications`
93
- - `Treeify` to dump more data per node (classifications)
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
- - Silenced waning messages when redefining `Fragment`s
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
- - `Ecoportal::API::Common::GraphQL::Client` adjusted `read_timeout` and `write_timeout` to `90` seconds.
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
- - Softened max version of **gem** dependencies
138
+
139
+ - Softened max version of **gem** dependencies
107
140
 
108
141
  ### Fixed
109
- - `Ecoportal::API::GraphQL::Fragment#define` was not removing previous constants
110
- - Changed check method to be `::const_defined?`
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
- - `Ecoportal::API::GraphQL::Helpers::LocationsTree#treeify`
116
- - Make it real id-case-insensitive (parents in lower case were being missed due to this)
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
- - `Ecoportal::API::Common::GraphQL::AuthService`
122
- - `#session_token` added **token auto-renew** functionality (when token expires in less than 90 minutes)
123
- - `#session_token_renewed`
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
- - Enabled to specify `host` (other than `live.ecoportal.com`) by the user
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
- - `Ecoportal::API::GraphQL::Base::LocationNode` **added** attribute `archivedToken`
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
- - `Ecoportal::API::GraphQL::Helpers::LocationsTree#treeify` added support for `archived_token`
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
- - Typo in tests LocationsStructures... should read `locationStructures`
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
- - Build gem correctly
192
+
193
+ - Build gem correctly
154
194
 
155
195
  ## [0.2.1] - 2023-02-24
156
196
 
157
197
  ### Changed
158
- - Migrate from TagTrees to **reporting structures** (breaking change)
198
+
199
+ - Migrate from TagTrees to **reporting structures** (breaking change)
159
200
 
160
201
  ### Added
161
- - Basics for reporting structure mutations
202
+
203
+ - Basics for reporting structure mutations
162
204
 
163
205
  ## [0.1.11] - 2022-11-29
164
206
 
165
207
  ### Added
166
- - `Ecoportal::API::GraphQL::Base::Mutation`
167
- - Added `createContractorEntity`
208
+
209
+ - `Ecoportal::API::GraphQL::Base::Mutation`
210
+ - Added `createContractorEntity`
168
211
 
169
212
  ### Changed
170
- - **upgraded** `graphlient` gem dependency (support for framents)
171
- - removed patch in this gem
172
- - Slight internal refactor of `Ecoportal::API::GraphQL::Base::Query`
173
- - Upgraded `ecoportal-api-v2` **gem** dependency
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
- - **upgraded** `ecoportal-api-v2` gem dependency
222
+
223
+ - **upgraded** `ecoportal-api-v2` gem dependency
179
224
 
180
225
  ### Fixed
181
- - Remove debugging message
226
+
227
+ - Remove debugging message
182
228
 
183
229
  ## [0.1.9] - 2022-09-26
184
230
 
185
231
  ### Added
186
- - `Ecoportal::API::GraphQL::Query::TagTree`
232
+
233
+ - `Ecoportal::API::GraphQL::Query::TagTree`
187
234
 
188
235
  ### Changed
189
- - **upgraded** `ecoportal-api-v2` gem dependency
190
- - added `Ecoportal::API::Common::GraphQL::QueryIntegration`
191
- - restructured `Ecoportal::API::GraphQL::Model::Organization` class
192
- - **Patch** on `Graphlient::Query` for fragments support (**pull request**: https://github.com/ashkan18/graphlient/pull/94)
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
- - `currentOrganization.tagTrees` query
245
+
246
+ - `currentOrganization.tagTrees` query
198
247
 
199
248
  ### Changed
200
- - **upgraded** `ecoportal-api-v2` gem dependency
201
- - Restructured the `Query` inheritance chain to make things simpler
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
- - Call to **private** method `remove_const` in `Ecoportal::API::GraphQL::Fragment#define`
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
- - Patch `GraphQL::Query#append_node` so we can use Fragments in blocks using `___` as start of the constant, and `__` for namespace separator
212
- - Issue/feature request: https://github.com/ashkan18/graphlient/issues/93
213
- - `Ecoportal::API::GraphQL::Fragment#define` provided that client scripts can create their own fragments in their own namespace
214
- - Exposed `Ecoportal::API::GraphQL#fragments`
215
- - It will always (re)define in the `Fragment` root namespace
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
- - Able to inject connection block to `each`
221
- - Error handling delegated to parent class (`QueryConnection`)
222
- - Retrieve `id` on elements of `Array`
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
- - Fixed circular reference to `org_id` in `Ecoportal::API::Common::GraphQL::Client`
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
- - `Ecoportal::API::GraphQL` addded `email` and `pass` parameters on initialization
233
- - This allows for integration in some client lib
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
- - First commit with some basic structure
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 = %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', '>= 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).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
@@ -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
- "#{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!"
@@ -4,6 +4,7 @@ module Ecoportal
4
4
  module Base
5
5
  class ContractorEntity < Ecoportal::API::GraphQL::Base::Model
6
6
  passkey :id
7
+ passthrough :externalId
7
8
  passthrough :name
8
9
  passboolean :active, :approved
9
10
  passthrough :schemaId
@@ -5,6 +5,7 @@ module Ecoportal
5
5
  fragment :ContractorEntity, <<~GRAPHQL
6
6
  fragment on ContractorEntity {
7
7
  id
8
+ externalId
8
9
  name
9
10
  schemaId
10
11
  active
@@ -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
@@ -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(searchConf: :Search, after: :string, before: :string, first: :int, last: :int) {
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: :after,
21
- before: :before,
22
- first: :first,
23
- last: :last,
26
+ after: :after,
27
+ before: :before,
28
+ first: :first,
29
+ last: :last,
24
30
  &connection_block
25
31
  )
26
32
  }
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- GRAPQL_VERSION = '0.3.18'.freeze
3
+ GRAPQL_VERSION = '0.4.1'.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.18
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-05-16 00:00:00.000000000 Z
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: 1.1.8
134
- - - "<"
113
+ version: '2.0'
114
+ - - ">="
135
115
  - !ruby/object:Gem::Version
136
- version: '1.2'
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: 1.1.8
144
- - - "<"
123
+ version: '2.0'
124
+ - - ">="
145
125
  - !ruby/object:Gem::Version
146
- version: '1.2'
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.7.0
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.4.12
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