ecoportal-api-oozes 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cdfc554887534bb009e625711354bbe3fd54f6f1b78df896a0d69a2b6d1f6de1
4
- data.tar.gz: 82b8f879b6b53e9e196aa3cf33b9db75332501662f2b97a84c0863222c8e5cbd
3
+ metadata.gz: a177d3aabd94973437f3e4e15e16ee48d3a460031b73329d732ad30e9736a2b4
4
+ data.tar.gz: 5cce90e07b02cfbb416cf710c2d7d345424c754c019d5d3f50bb4315cc0abf9a
5
5
  SHA512:
6
- metadata.gz: 486f69f48b5c8ad718c255d0c392ae73e4a61f35fca00b11adf661b4992e365ab96c724ee38523575f8440ba49411aaf26512578732852ddce7f2357b4689c8b
7
- data.tar.gz: 42371082bb5579ec9402641299ab87a3f0dc0dbe48f5867e8306c1b4911f5fee52349d83e33cabaf699539460a1990eeb42bb8e3610b9ca75d6e81dd9e65be7f
6
+ metadata.gz: 88a46f8426347ccc3b771694eeb489f0591f8a9023dcc08860f83683ad369eb8e636bab3324389ec888e8e2aca990fdee2185bb3e1ad5d99f738bf40600246c9
7
+ data.tar.gz: a3e0a5e6079e24fbe3773b88b4fc455e1f8a9d6db142689871dafe70277b1df92f1736a68e43203cb78abe399e4cc5284a7ade46bccfa8a95058310b5d63573a
@@ -1,6 +1,15 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.7.2] - 2020-10-07
5
+
6
+ ### Added
7
+ - automatic key builder
8
+ - helper: `Ecoportal::API::V2::v2key` method
9
+ - `user_key:` and `org_key:` as constructor methods for `Ecoportal::API::V2`
10
+ ### Changed
11
+ ### Fixed
12
+
4
13
  ## [0.7.1] - 2020-10-07
5
14
 
6
15
  ### Added
@@ -1,3 +1,5 @@
1
+ require 'base64'
2
+
1
3
  module Ecoportal
2
4
  module API
3
5
  # @attr_reader client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
@@ -8,19 +10,33 @@ module Ecoportal
8
10
 
9
11
  VERSION = "v2"
10
12
 
13
+ class << self
14
+ def v2key (ukey, gkey)
15
+ Base64.urlsafe_encode64({
16
+ organization: gkey,
17
+ user: ukey
18
+ }.to_json)
19
+ end
20
+ end
21
+
11
22
  class_resolver :registers_class, "Ecoportal::API::V2::Registers"
12
23
  class_resolver :pages_class, "Ecoportal::API::V2::Pages"
13
24
 
14
25
  attr_reader :client, :logger
15
26
 
16
27
  # Creates an `V2` object to scope version specific api requests.
28
+ # @note
29
+ # - you should use either `api_key` or `user_key` and `org_key`
17
30
  # @param api_key [String] the key version to stablish the api connection.
31
+ # @param user_key [String] the user key used for the api connection (requires `org_key`).
32
+ # @param org_key [String] the org key used for the api connection (requires `user_key`).
18
33
  # @param host [String] api server domain.
19
34
  # @param logger [Logger] an object with `Logger` interface to generate logs.
20
- def initialize(api_key, host: "live.ecoportal.com", logger: default_logger)
35
+ def initialize(api_key = nil, user_key: nil, org_key: nil, host: "live.ecoportal.com", logger: default_logger)
36
+ v2key = (user_key && org_key && self.class.v2key(user_key, org_key)) || api_key #|| ENV['X_ECOPORTAL_API_KEY']
21
37
  @logger = logger
22
38
  @client = Common::Content::Client.new(
23
- api_key: api_key,
39
+ api_key: v2key,
24
40
  host: host,
25
41
  version: self.class::VERSION,
26
42
  logger: @logger
@@ -1,7 +1,7 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  class V2
4
- GEM_VERSION = "0.7.1"
4
+ GEM_VERSION = "0.7.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecoportal-api-oozes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-06 00:00:00.000000000 Z
11
+ date: 2020-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler