ecoportal-api-graphql 0.4.2 → 0.4.3

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: e5cc7a322eed9a692a7a7ec622a38909b66f0653b37f62743ce9edbc89010fc5
4
- data.tar.gz: c04a73b90dbec766e8be560880cb997415445da8bb5ae5a97185235951763637
3
+ metadata.gz: 9179222ef94ebb52697888787734813f4aacf5e8267dea6b54c82862087779e0
4
+ data.tar.gz: 495f596b1aef1e11c1fb2bd102bfbdd073325c64f81b608d4d53230ac5037d82
5
5
  SHA512:
6
- metadata.gz: 70d02bea3953e7a1aac6691fcda1c85cec8bcbd70e4254761d5dc5f99189712e05efedf7e63e4726cf1ac5732d68c3cc2168f932ca6584fca06304fe052d9a13
7
- data.tar.gz: 9c415037ed41fdae532fa3c53fdce546099479c4e70e4ae3ab81bfe5868e5afaa2e778eb57fc059be814f7c2fce18e7940ea7ab72eb7b74ca76cc6f10b091e6c
6
+ metadata.gz: 92e8cbd28c4b3d38fcbecf2284c6a6ff268641417009515cd62964eb7a539b2bbdf75fbcd9423e1616c943f49c1ba722c69bb845a0b8870dfa091f25b429a8e3
7
+ data.tar.gz: d5812a7922aa767e912ae4385b3b6117d63e9fbafbf2a4cc404ae274982b2fa0ca95ec6e632544a1d16decde89adb4a8503c253ae0a74a8fb599a7f53d0e6b1d
data/CHANGELOG.md CHANGED
@@ -15,13 +15,18 @@ All notable changes to this project will be documented in this file.
15
15
 
16
16
  ### Changed
17
17
 
18
+ - upgrade core gem
19
+ - `Ecoportal::API::Common::GraphQL::HttpClient.new` ceased to default `version` to `v1` (now it defaults to `nil`)
20
+
18
21
  ### Fixed
19
22
 
20
23
  ## [0.4.2] - 2024-10-01
21
24
 
22
25
  ### Changed
23
26
 
24
- - upgrade `ecoportal-api-v2` gem
27
+ - upgrade gems
28
+ - `ecoportal-api`
29
+ - `ecoportal-api-v2`
25
30
  - add explicit dependency onto `ecoportal-api` gem (client)
26
31
 
27
32
  ## [0.4.1] - 2024-08-09
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "rubocop-rake", "~> 0"
32
32
  spec.add_development_dependency "pry" , ">= 0.14"
33
33
 
34
- spec.add_dependency 'ecoportal-api', '~> 0.10', '>= 0.10.3'
35
- spec.add_dependency 'ecoportal-api-v2', '~> 2.0', '>= 2.0.10'
34
+ spec.add_dependency 'ecoportal-api', '~> 0.10', '>= 0.10.7'
35
+ spec.add_dependency 'ecoportal-api-v2', '~> 2.0', '>= 2.0.12'
36
36
  spec.add_dependency 'graphlient', '>= 0.8.0', '< 0.9'
37
37
  end
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  module Common
4
4
  module GraphQL
5
5
  module AuthService
6
- DEFAULT_SERVER = "live.ecoportal.com".freeze
6
+ DEFAULT_SERVER = 'live.ecoportal.com'.freeze
7
7
  TOKEN_AUTORENEW = 90 # minutes
8
8
 
9
9
  module InstanceMethods
@@ -11,14 +11,14 @@ module Ecoportal
11
11
  session_token_data(host: host, version: version).then do |body|
12
12
  next unless body
13
13
 
14
- if auto_renew && token_renew?(body["expires_in"])
14
+ if auto_renew && token_renew?(body['expires_in'])
15
15
  session_token_renewed(
16
16
  host: host,
17
17
  version: version,
18
- refresh_token: body["refresh_token"]
18
+ refresh_token: body['refresh_token']
19
19
  )
20
20
  else
21
- body["access_token"]
21
+ body['access_token']
22
22
  end
23
23
  end
24
24
  end
@@ -26,7 +26,7 @@ module Ecoportal
26
26
  def session_token_renewed(host: server, version: nil, refresh_token: nil)
27
27
  unless refresh_token
28
28
  return unless (body = session_token_data(host: host, version: version))
29
- return unless (refresh_token = body["resfresh_token"])
29
+ return unless (refresh_token = body['resfresh_token'])
30
30
  end
31
31
 
32
32
  session_refresh_token_data(
@@ -34,7 +34,7 @@ module Ecoportal
34
34
  version: version,
35
35
  refresh_token: refresh_token
36
36
  ).then do |bdy|
37
- bdy["access_token"] if bdy
37
+ bdy['access_token'] if bdy
38
38
  end
39
39
  end
40
40
 
@@ -42,11 +42,11 @@ module Ecoportal
42
42
 
43
43
  def session_token_data(host: server, version: nil)
44
44
  http_client(host: host, version: version).post(
45
- "/oauth/token",
45
+ '/oauth/token',
46
46
  data: {
47
- "grant_type" => "password",
48
- "email" => user_email,
49
- "password" => user_pass
47
+ 'grant_type' => 'password',
48
+ 'email' => user_email,
49
+ 'password' => user_pass
50
50
  }
51
51
  ).then do |response|
52
52
  next response.body if response.success?
@@ -55,10 +55,10 @@ module Ecoportal
55
55
 
56
56
  def session_refresh_token_data(refresh_token:, host: server, version: nil)
57
57
  http_client(host: host, version: version).post(
58
- "/oauth/token",
58
+ '/oauth/token',
59
59
  data: {
60
- "grant_type" => "refresh_token",
61
- "refresh_token" => refresh_token
60
+ 'grant_type' => 'refresh_token',
61
+ 'refresh_token' => refresh_token
62
62
  }
63
63
  ).then do |response|
64
64
  next response.body if response.success?
@@ -77,11 +77,11 @@ module Ecoportal
77
77
  end
78
78
 
79
79
  def user_email
80
- @user_email || fetch_env_required("USER_EMAIL")
80
+ @user_email || fetch_env_required('USER_EMAIL')
81
81
  end
82
82
 
83
83
  def user_pass
84
- @user_pass || fetch_env_required("USER_PASS")
84
+ @user_pass || fetch_env_required('USER_PASS')
85
85
  end
86
86
 
87
87
  def server(default = DEFAULT_SERVER)
@@ -45,7 +45,7 @@ module Ecoportal
45
45
  end
46
46
 
47
47
  def org_id
48
- @org_id || fetch_env_required("ORGANIZATION_ID")
48
+ @org_id || fetch_env_required('ORGANIZATION_ID')
49
49
  end
50
50
 
51
51
  private
@@ -9,7 +9,7 @@ module Ecoportal
9
9
  end
10
10
 
11
11
  def protocol(host)
12
- host.match(/^localhost|^127\.0\.0\.1/)? "http" : "https"
12
+ host.match(/^localhost|^127\.0\.0\.1/)? 'http' : 'https'
13
13
  end
14
14
  end
15
15
 
@@ -17,8 +17,8 @@ module Ecoportal
17
17
 
18
18
  def initialize(
19
19
  api_key: nil,
20
- version: "v1",
21
- host: "live.ecoportal.com",
20
+ version: nil,
21
+ host: 'live.ecoportal.com',
22
22
  logger: ::Logger.new(IO::NULL),
23
23
  deep_logging: false
24
24
  )
@@ -43,12 +43,12 @@ module Ecoportal
43
43
  case @version
44
44
  when NilClass
45
45
  HTTP.accept(:json)
46
- when "v2"
47
- HTTP.headers("X-ECOPORTAL-API-KEY" => key_token).accept(:json)
48
- when "graphql"
49
- HTTP.headers("Authorization" => "Bearer #{key_token}").accept(:json)
46
+ when 'v2'
47
+ HTTP.headers('X-ECOPORTAL-API-KEY' => key_token).accept(:json)
48
+ when 'graphql'
49
+ HTTP.headers('Authorization' => "Bearer #{key_token}").accept(:json)
50
50
  else
51
- HTTP.headers("X-ApiKey" => key_token).accept(:json)
51
+ HTTP.headers('X-ApiKey' => key_token).accept(:json)
52
52
  end
53
53
  end
54
54
 
@@ -79,10 +79,10 @@ module Ecoportal
79
79
 
80
80
  def key_token
81
81
  if @api_key.nil? || @api_key.match(/\A\W*\z/)
82
- if (version == "v0") && (key = ENV['ORG_INT_KEY'])
82
+ if (version == 'v0') && (key = ENV['ORG_INT_KEY'])
83
83
  key
84
- else
85
- puts "Api-key missing!"
84
+ elsif !version.nil?
85
+ puts 'Api-key missing!'
86
86
  end
87
87
  else
88
88
  @api_key
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- GRAPQL_VERSION = '0.4.2'.freeze
3
+ GRAPQL_VERSION = '0.4.3'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecoportal-api-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
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-10-01 00:00:00.000000000 Z
11
+ date: 2024-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -141,7 +141,7 @@ dependencies:
141
141
  version: '0.10'
142
142
  - - ">="
143
143
  - !ruby/object:Gem::Version
144
- version: 0.10.3
144
+ version: 0.10.7
145
145
  type: :runtime
146
146
  prerelease: false
147
147
  version_requirements: !ruby/object:Gem::Requirement
@@ -151,7 +151,7 @@ dependencies:
151
151
  version: '0.10'
152
152
  - - ">="
153
153
  - !ruby/object:Gem::Version
154
- version: 0.10.3
154
+ version: 0.10.7
155
155
  - !ruby/object:Gem::Dependency
156
156
  name: ecoportal-api-v2
157
157
  requirement: !ruby/object:Gem::Requirement
@@ -161,7 +161,7 @@ dependencies:
161
161
  version: '2.0'
162
162
  - - ">="
163
163
  - !ruby/object:Gem::Version
164
- version: 2.0.10
164
+ version: 2.0.12
165
165
  type: :runtime
166
166
  prerelease: false
167
167
  version_requirements: !ruby/object:Gem::Requirement
@@ -171,7 +171,7 @@ dependencies:
171
171
  version: '2.0'
172
172
  - - ">="
173
173
  - !ruby/object:Gem::Version
174
- version: 2.0.10
174
+ version: 2.0.12
175
175
  - !ruby/object:Gem::Dependency
176
176
  name: graphlient
177
177
  requirement: !ruby/object:Gem::Requirement
@@ -364,7 +364,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
364
364
  - !ruby/object:Gem::Version
365
365
  version: '0'
366
366
  requirements: []
367
- rubygems_version: 3.5.18
367
+ rubygems_version: 3.5.23
368
368
  signing_key:
369
369
  specification_version: 4
370
370
  summary: A collection of helpers for interacting with the ecoPortal GraphQL API