eco-helpers 1.2.1 → 1.2.2
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/lib/eco/api/common/version_patches/ecoportal_api.rb +1 -0
- data/lib/eco/api/common/version_patches/ecoportal_api/external_people.rb +38 -0
- data/lib/eco/api/session/batch.rb +1 -1
- data/lib/eco/api/usecases/base_io.rb +4 -4
- data/lib/eco/cli/config/use_cases.rb +5 -7
- data/lib/eco/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3ad84afe4b64a3fc6285227c511f07973bad7a2fa30563bba3c961607f06882
|
4
|
+
data.tar.gz: 6b5b3b281cb22bf03f344647dbd887263544b77de4bd7b5f0a9e724fa3e74291
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35b1e316a53705127ae555572f1186b037862067387b14482285a46fbf76a2402e43d9ea761712c52f7be39c0a281288c63ecd0672baee605d8cd6b2dcee2d58
|
7
|
+
data.tar.gz: 7a28bbd1d45d39ad090812496efe5fc26ee916e5db3a28d27ef1582bce8f48e44e2d4ee900143aa172f9603e893a1a09591b4c3e6991e6cfd731c315e352bb55
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'ecoportal/api'
|
2
2
|
require_relative 'ecoportal_api/base_model'
|
3
|
+
require_relative 'ecoportal_api/external_people'
|
3
4
|
require_relative 'ecoportal_api/external_person'
|
4
5
|
require_relative 'ecoportal_api/internal_person'
|
5
6
|
require_relative 'ecoportal_api/account_preferences'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V1
|
4
|
+
class People
|
5
|
+
|
6
|
+
def job
|
7
|
+
operation = Common::BatchOperation.new("/people", person_class, logger: client.logger)
|
8
|
+
yield operation
|
9
|
+
# The batch operation is responsible for logging the output
|
10
|
+
job_id = create_job(operation)
|
11
|
+
status = wait_for_job_completion(job_id)
|
12
|
+
|
13
|
+
if status&.complete?
|
14
|
+
operation.process_response job_result(job_id, operation)
|
15
|
+
else
|
16
|
+
raise "Job `#{job_id}` not complete. Probably timeout after #{JOB_TIMEOUT + 60} seconds. Current status: #{status}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def wait_for_job_completion(job_id)
|
23
|
+
# timeout library is evil. So we make poor-man timeout.
|
24
|
+
# https://jvns.ca/blog/2015/11/27/why-rubys-timeout-is-dangerous-and-thread-dot-raise-is-terrifying/
|
25
|
+
before = Time.now
|
26
|
+
while true
|
27
|
+
status = job_status(job_id)
|
28
|
+
break status if status.complete?
|
29
|
+
break status if Time.now >= before + (JOB_TIMEOUT + 60)
|
30
|
+
sleep(DELAY_STATUS_CHECK)
|
31
|
+
status
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -25,11 +25,11 @@ module Eco
|
|
25
25
|
# @param people [Eco::API::Organization::People] people object.
|
26
26
|
# @param session [Eco::API:Session]
|
27
27
|
# @param options [Hash] hash with symbol keys (i.e. behaviour modifiers, cli trackers, filters, etc.)
|
28
|
-
def initialize(type: nil, input: nil, people: nil, session:, options: {})
|
28
|
+
def initialize(type: nil, input: nil, people: nil, session:, options: {}, validate: true)
|
29
29
|
@output = nil
|
30
30
|
self.type = type if type
|
31
31
|
|
32
|
-
if self.type
|
32
|
+
if self.type && validate
|
33
33
|
validate_args(input: input, people: people, session: session, options: options)
|
34
34
|
end
|
35
35
|
|
@@ -54,8 +54,8 @@ module Eco
|
|
54
54
|
|
55
55
|
# @see Eco::API::UseCases::BaseIO#initialize
|
56
56
|
# @return [Eco::API::UseCases::BaseIO]
|
57
|
-
def new(type: self.type, input: self.input, people: self.people, session: self.session, options: self.options)
|
58
|
-
self.class.new(type: type, input: input, people: people, session: session, options: options)
|
57
|
+
def new(type: self.type, input: self.input, people: self.people, session: self.session, options: self.options, validate: true)
|
58
|
+
self.class.new(type: type, input: input, people: people, session: session, options: options, validate: validate)
|
59
59
|
end
|
60
60
|
|
61
61
|
# Helper to build a `Hash` of symbol keys or `Array` with params to do callbacks.
|
@@ -48,6 +48,9 @@ module Eco
|
|
48
48
|
if callback = data[:callback]
|
49
49
|
unless usecase
|
50
50
|
# identify usecase
|
51
|
+
params = io.params(keyed: true).merge(type: type)
|
52
|
+
io = io.new(**params, validate: false)
|
53
|
+
|
51
54
|
usecase = callback.call(*io.params)
|
52
55
|
unless usecase.is_a?(Eco::API::UseCases::UseCase)
|
53
56
|
msg = "When adding a usecase, without specifying 'case_name:', "
|
@@ -83,13 +86,8 @@ module Eco
|
|
83
86
|
|
84
87
|
processed = true
|
85
88
|
|
86
|
-
params
|
87
|
-
|
88
|
-
#if (!io.people || io.people.empty?) && io.class.people_required?(type)
|
89
|
-
# params.merge!(people: core_config.people(io: io))
|
90
|
-
#end
|
91
|
-
|
92
|
-
io.new(**params)
|
89
|
+
params = io.params(keyed: true).merge(type: usecase.type)
|
90
|
+
io = io.new(**params)
|
93
91
|
|
94
92
|
if callback = data[:callback]
|
95
93
|
callback.call(*io.params)
|
data/lib/eco/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eco-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -247,6 +247,7 @@ files:
|
|
247
247
|
- lib/eco/api/common/version_patches/ecoportal_api.rb
|
248
248
|
- lib/eco/api/common/version_patches/ecoportal_api/account_preferences.rb
|
249
249
|
- lib/eco/api/common/version_patches/ecoportal_api/base_model.rb
|
250
|
+
- lib/eco/api/common/version_patches/ecoportal_api/external_people.rb
|
250
251
|
- lib/eco/api/common/version_patches/ecoportal_api/external_person.rb
|
251
252
|
- lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb
|
252
253
|
- lib/eco/api/common/version_patches/exception.rb
|