eco-helpers 2.4.9 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -1
- data/eco-helpers.gemspec +1 -1
- data/lib/eco/api/common/loaders/case_base.rb +2 -3
- data/lib/eco/api/common/people/default_parsers/csv_parser.rb +97 -47
- data/lib/eco/api/common/people/default_parsers/select_parser.rb +2 -2
- data/lib/eco/api/common/people/default_parsers/xls_parser.rb +0 -1
- data/lib/eco/api/common/people/entry_factory.rb +13 -8
- data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +2 -2
- data/lib/eco/api/common/session/base_session.rb +1 -2
- data/lib/eco/api/common/session/environment.rb +6 -10
- data/lib/eco/api/common/session/helpers/prompt_user.rb +18 -18
- data/lib/eco/api/common/session/mailer.rb +1 -3
- data/lib/eco/api/common/session/s3_uploader.rb +1 -3
- data/lib/eco/api/common/session/sftp.rb +6 -4
- data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +5 -4
- data/lib/eco/api/session/config/api.rb +4 -2
- data/lib/eco/api/usecases/base_case.rb +0 -2
- data/lib/eco/api/usecases/base_io.rb +0 -3
- data/lib/eco/api/usecases/default_cases/samples/sftp_case.rb +1 -1
- data/lib/eco/api/usecases/ooze_samples/ooze_from_doc_case.rb +1 -2
- data/lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb +0 -1
- data/lib/eco/api/usecases/ooze_samples/ooze_update_case.rb +0 -1
- data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +1 -1
- data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +0 -2
- data/lib/eco/api/usecases/ooze_samples/target_oozes_update_case.rb +0 -1
- data/lib/eco/api/usecases/ooze_samples.rb +0 -1
- data/lib/eco/api/usecases/use_case.rb +4 -1
- data/lib/eco/api/usecases/use_case_chain.rb +1 -4
- data/lib/eco/api/usecases/use_case_io.rb +0 -2
- data/lib/eco/api.rb +0 -2
- data/lib/eco/cli/config/default/options.rb +11 -1
- data/lib/eco/csv.rb +4 -7
- data/lib/eco/data/files/directory.rb +0 -3
- data/lib/eco/data/files/encoding.rb +75 -0
- data/lib/eco/data/files/helpers.rb +15 -37
- data/lib/eco/data/files.rb +1 -0
- data/lib/eco/data/fuzzy_match.rb +8 -4
- data/lib/eco/data.rb +0 -1
- data/lib/eco/version.rb +1 -1
- data/lib/eco-helpers.rb +1 -1
- metadata +5 -6
- data/lib/eco/data/crypto/encryption.rb +0 -321
- data/lib/eco/data/crypto.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b15015d62d69b57bfaef2e33cb9800786806f1796621f8a7c3fdc570bec81c99
|
4
|
+
data.tar.gz: 046b93c466ef6999e97c2d17584d4e760c3d6592783448c4fed3aed2edd3a0d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '079b89d982758de246c8f81fcc5e8853fdcc75c217f1b7e417408b9234a8a942aa874e77705fe62c0863699bf72dcf666297894b6febdb3f47bcb740af2d438e'
|
7
|
+
data.tar.gz: 7feaa9e6022432a50c3fab188283e6af6566a8fe9de7b84fd3dcfba4584c64fd02cc5d926f3f50db8a44f139138844438345222d941b7407a6f4369b257ca070
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,35 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [2.
|
4
|
+
## [2.5.2] - 2023-06-xx
|
5
5
|
|
6
6
|
### Added
|
7
7
|
### Changed
|
8
8
|
### Fixed
|
9
9
|
|
10
|
+
## [2.5.1] - 2023-06-06
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- `Eco::API::Common::Session:SFTP#host` method
|
14
|
+
- New options to control csv headers check (`Eco::API::Common::People::DefaultParsers::CSVParser`)
|
15
|
+
- `Eco::API::Common::Loaders::CaseBase` add to the setter the `@usecase`
|
16
|
+
- Implemented via `Eco::API::UseCases::UseCase`
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
- Dry out dependency loading.
|
20
|
+
- `ecoportal-api` **gem** remains as eager loading.
|
21
|
+
- Patch `Ecoportal::API::V1::Person` with `include`
|
22
|
+
- Upgraded `ecoportal-api-graphql` **gem**
|
23
|
+
- `Eco::API::Common::People::PersonEntryAttributeMapper`
|
24
|
+
- Switched reversed attr defs warning to `info` logging level.
|
25
|
+
- `Eco::API::Common::DefaultParsers::SelectParser`
|
26
|
+
- When there is dependency with the hash of options, it should return nil when the option is unknown.
|
27
|
+
|
28
|
+
### Fixed
|
29
|
+
- Tidied up file encoding when getting content.
|
30
|
+
- This fixes `Eco::CSV::read`
|
31
|
+
- `Eco::API::Common::People::DefaultParsers::CSVParser` made some refactor.
|
32
|
+
|
10
33
|
## [2.4.9] - 2023-04-17
|
11
34
|
|
12
35
|
### Added
|
data/eco-helpers.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
|
33
33
|
spec.add_dependency 'ecoportal-api', '>= 0.9.4', '< 0.10'
|
34
34
|
spec.add_dependency 'ecoportal-api-v2', '>= 1.1.2', '< 1.2'
|
35
|
-
spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.
|
35
|
+
spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.7', '< 0.4'
|
36
36
|
spec.add_dependency 'aws-sdk-s3', '>= 1.83.0', '< 2'
|
37
37
|
spec.add_dependency 'aws-sdk-ses', '>= 1.36.0', '< 2'
|
38
38
|
spec.add_dependency 'dotenv', '>= 2.7.6', '< 3'
|
@@ -3,7 +3,6 @@ module Eco
|
|
3
3
|
module Common
|
4
4
|
module Loaders
|
5
5
|
class CaseBase < Loaders::Base
|
6
|
-
|
7
6
|
class << self
|
8
7
|
attr_writer :name, :type
|
9
8
|
|
@@ -19,13 +18,13 @@ module Eco
|
|
19
18
|
def name_only_once!
|
20
19
|
raise "You have already declared #{self} or you are trying to give it a name twice" if @name
|
21
20
|
end
|
22
|
-
|
23
21
|
end
|
24
22
|
|
23
|
+
attr_reader :usecase
|
24
|
+
|
25
25
|
def name
|
26
26
|
self.class.name
|
27
27
|
end
|
28
|
-
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
@@ -3,7 +3,8 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
3
3
|
|
4
4
|
def parser(data, deps)
|
5
5
|
Eco::CSV.parse(data, headers: true, skip_blanks: true).tap do |table|
|
6
|
-
|
6
|
+
require_headers!(table)
|
7
|
+
check_headers(table) if deps[:check_headers] && check_headers?
|
7
8
|
end.each_with_object([]) do |row, arr_hash|
|
8
9
|
row_hash = row.headers.uniq.each_with_object({}) do |attr, hash|
|
9
10
|
next if attr.to_s.strip.empty?
|
@@ -26,6 +27,26 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
26
27
|
|
27
28
|
private
|
28
29
|
|
30
|
+
def abort(message)
|
31
|
+
logger.error(message)
|
32
|
+
exit(1)
|
33
|
+
end
|
34
|
+
|
35
|
+
def require_headers!(table)
|
36
|
+
headers = table.headers
|
37
|
+
abort("Missing headers in CSV") unless headers && !headers.empty?
|
38
|
+
empty = []
|
39
|
+
with_value = headers.each_with_index do |header, idx|
|
40
|
+
empty << idx if header.to_s.strip.empty?
|
41
|
+
end
|
42
|
+
abort("Empty headers in column(s): #{empty.join(', ')}") unless empty.empty?
|
43
|
+
true
|
44
|
+
end
|
45
|
+
|
46
|
+
def check_headers?
|
47
|
+
!options.dig(:input, :header_check, :skip)
|
48
|
+
end
|
49
|
+
|
29
50
|
def options
|
30
51
|
ASSETS.cli.options
|
31
52
|
end
|
@@ -43,29 +64,54 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
43
64
|
end
|
44
65
|
|
45
66
|
def check_headers(table)
|
46
|
-
headers
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
67
|
+
headers = table.headers
|
68
|
+
unmatch = []
|
69
|
+
unmatch = unmatched_headers(headers) if options.dig(:input, :header_check, :order)
|
70
|
+
missing = missing_headers(headers)
|
71
|
+
unknown = unknown_headers(headers)
|
72
|
+
criteria = [unknown, missing[:direct], missing[:indirect], unmatch]
|
73
|
+
return if criteria.all?(&:empty?)
|
74
|
+
|
75
|
+
msg = "Detected possible HEADER ISSUES !!!\n"
|
76
|
+
|
77
|
+
# requires exact match
|
78
|
+
unless unmatch.empty?
|
79
|
+
msg << "CSV headers do NOT exactly match the expected:\n"
|
80
|
+
msg << " * Expected: #{known_headers}\n"
|
81
|
+
expected, given = unmatch.first
|
82
|
+
msg << " * First unmatch => Given: '#{given}' where expected '#{expected}'\n"
|
83
|
+
missed = known_headers - headers
|
84
|
+
unless missed.empty?
|
85
|
+
msg << " * Missing headers:\n"
|
86
|
+
msg << " - #{missed.join("\n - ")}\n"
|
66
87
|
end
|
67
|
-
|
68
|
-
|
88
|
+
end
|
89
|
+
msg << "Missing or Wrong HEADER names in the CSV file:\n"
|
90
|
+
msg << " * UNKNOWN (or not used?): #{unknown}\n" unless unknown.empty?
|
91
|
+
msg << " * MISSING HEADER: #{missing[:direct]}\n" unless missing[:direct].empty?
|
92
|
+
unless (data = missing[:indirect]).empty?
|
93
|
+
msg << " * MISSING INDIRECTLY:\n"
|
94
|
+
data.each do |ext, info|
|
95
|
+
msg << " - '#{ext}' => "
|
96
|
+
msg << (info[:attrs] || {}).map do |status, attrs|
|
97
|
+
if status == :inactive
|
98
|
+
"makes inactive: #{attrs}"
|
99
|
+
elsif status == :active
|
100
|
+
"there could be missing info in: #{attrs}"
|
101
|
+
end
|
102
|
+
end.compact.join("; ") + "\n"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
logger.warn(msg)
|
106
|
+
if options.dig(:input, :header_check, :must_be_valid)
|
107
|
+
abort("There were issues identified on the CSV header names. Aborting...")
|
108
|
+
end
|
109
|
+
sleep(2)
|
110
|
+
end
|
111
|
+
|
112
|
+
def unmatched_headers(headers)
|
113
|
+
known_headers.zip(headers).reject do |(expected, given)|
|
114
|
+
expected == given
|
69
115
|
end
|
70
116
|
end
|
71
117
|
|
@@ -82,27 +128,28 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
82
128
|
ext_present = known_headers_present(int_head) | ext
|
83
129
|
ext_miss = known_headers - ext_present
|
84
130
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
131
|
+
{
|
132
|
+
direct: [],
|
133
|
+
indirect: {}
|
134
|
+
}.tap do |missing|
|
135
|
+
ext_miss.each do |ext|
|
136
|
+
next unless int = fields_mapper.to_internal(ext)
|
137
|
+
missing[:direct] << ext if all_internal_attrs.include?(int)
|
138
|
+
related_attrs_requirements = required_attrs.values.select do |req|
|
139
|
+
dep = req.dependant?(int)
|
140
|
+
affects = dep && !int_head.include?(int)
|
141
|
+
in_header = int_head.include?(req.attr)
|
142
|
+
affects || (dep && !in_header)
|
143
|
+
end
|
144
|
+
next if related_attrs_requirements.empty?
|
145
|
+
data = missing[:indirect][ext] = {}
|
146
|
+
data[:int] = int
|
147
|
+
data[:attrs] = {}
|
148
|
+
related_attrs_requirements.each_with_object(data[:attrs]) do |req, attrs|
|
149
|
+
status = req.active?(*int_head) ? :active : :inactive
|
150
|
+
attrs[status] ||= []
|
151
|
+
attrs[status] << req.attr
|
152
|
+
end
|
106
153
|
end
|
107
154
|
end
|
108
155
|
end
|
@@ -114,8 +161,11 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
114
161
|
end
|
115
162
|
end
|
116
163
|
|
164
|
+
# Scopes what internal attrs appear in headers as they are
|
117
165
|
def internal_present_or_active(headers, inactive_requirements = {})
|
118
|
-
|
166
|
+
# internal attrs that are not being mapped
|
167
|
+
int_all = all_internal_attrs.reject {|i| fields_mapper.external?(i)}
|
168
|
+
hint = headers & int_all
|
119
169
|
hext = headers - hint
|
120
170
|
int_present = hint + hext.map {|e| fields_mapper.to_internal(e)}.compact
|
121
171
|
|
@@ -142,8 +192,9 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
142
192
|
int_present
|
143
193
|
end
|
144
194
|
|
195
|
+
# The csv header names as expected
|
145
196
|
def known_headers
|
146
|
-
@known_headers ||= fields_mapper.list(:external).compact
|
197
|
+
@known_headers ||= fields_mapper.list(:external).compact.uniq
|
147
198
|
end
|
148
199
|
|
149
200
|
def fields_mapper
|
@@ -167,5 +218,4 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
167
218
|
def person_parser
|
168
219
|
session.entry_factory.person_parser
|
169
220
|
end
|
170
|
-
|
171
221
|
end
|
@@ -11,9 +11,9 @@ module Eco
|
|
11
11
|
options_hash = deps[:select_hashes][deps["attr"]]
|
12
12
|
next value if !options_hash
|
13
13
|
if value.is_a?(Array)
|
14
|
-
value.map { |v| options_hash[v&.downcase.strip]
|
14
|
+
value.map { |v| options_hash[v&.downcase.strip] }.compact
|
15
15
|
elsif value
|
16
|
-
options_hash[value&.downcase.strip]
|
16
|
+
options_hash[value&.downcase.strip]
|
17
17
|
end
|
18
18
|
end.def_serializer do |value|
|
19
19
|
value
|
@@ -86,10 +86,10 @@ module Eco
|
|
86
86
|
# @option options [Boolean] :check_headers signals if the `csv` file headers should be expected.
|
87
87
|
# @return [Eco::API::Common::People::Entries] collection of `Eco::API::Common::People::PersonEntry`.
|
88
88
|
def entries(data: (no_data = true; nil), file: (no_file = true; nil), format: (no_format = true; nil), **options)
|
89
|
-
fatal("You should at least use data: or file:, but not both")
|
89
|
+
fatal("You should at least use data: or file:, but not both") if no_data == no_file
|
90
90
|
fatal("You must specify a valid format: (symbol) when you use file.") if file && no_format
|
91
|
-
fatal("Format should be a Symbol. Given '#{format}'")
|
92
|
-
fatal("There is no parser/serializer for format ':#{format.to_s}'")
|
91
|
+
fatal("Format should be a Symbol. Given '#{format}'") if format && !format.is_a?(Symbol)
|
92
|
+
fatal("There is no parser/serializer for format ':#{format.to_s}'") unless no_format || @person_parser.defined?(format)
|
93
93
|
|
94
94
|
options.merge!(content: data) unless no_data
|
95
95
|
options.merge!(file: file) unless no_file
|
@@ -113,9 +113,8 @@ module Eco
|
|
113
113
|
# Get content only when it's not :xls
|
114
114
|
# note: even if content was provided, file takes precedence
|
115
115
|
if (format != :xls) && file
|
116
|
-
content = get_file_content(file, encoding)
|
116
|
+
content = get_file_content(file, encoding: encoding)
|
117
117
|
end
|
118
|
-
#content = get_file_content(file, format, encoding) if (format != :xls) && file
|
119
118
|
|
120
119
|
case content
|
121
120
|
when Hash
|
@@ -129,15 +128,16 @@ module Eco
|
|
129
128
|
case sample
|
130
129
|
when Hash, Array, ::CSV::Row
|
131
130
|
Eco::CSV::Table.new(content).to_array_of_hashes
|
131
|
+
when NilClass
|
132
|
+
abort("There is NO input data")
|
132
133
|
else
|
133
|
-
|
134
|
+
abort("Input content 'Array' of '#{sample.class}' is not supported.")
|
134
135
|
end
|
135
136
|
else
|
136
137
|
if file && format == :xls
|
137
138
|
person_parser.parse(format, file)
|
138
139
|
else
|
139
|
-
|
140
|
-
exit(1)
|
140
|
+
abort("Could not obtain any data out of these: #{kargs}. Given content: '#{content.class}'")
|
141
141
|
end
|
142
142
|
end.tap do |out_array|
|
143
143
|
start_from_two = (format == :csv) || format == :xls
|
@@ -189,6 +189,11 @@ module Eco
|
|
189
189
|
|
190
190
|
private
|
191
191
|
|
192
|
+
def abort(message)
|
193
|
+
logger.error(message)
|
194
|
+
exit(1)
|
195
|
+
end
|
196
|
+
|
192
197
|
def fatal(msg)
|
193
198
|
logger.fatal(msg)
|
194
199
|
raise msg
|
@@ -133,7 +133,7 @@ module Eco
|
|
133
133
|
attr = @attr_map.to_internal(value.strip)
|
134
134
|
when @attr_map.internal?(value) || @attr_map.internal?(value.strip) || @attr_map.internal?(value.strip.downcase)
|
135
135
|
unless cached_warning("external", "reversed", value)
|
136
|
-
logger.
|
136
|
+
logger.info("The mapper [external, internal] attribute names may be declared reversedly for EXTERNAL attribute: '#{value}'")
|
137
137
|
end
|
138
138
|
end
|
139
139
|
end
|
@@ -172,7 +172,7 @@ module Eco
|
|
172
172
|
attr = @attr_map.to_external(value.strip)
|
173
173
|
when @attr_map.external?(value) || @attr_map.external?(value.strip) || @attr_map.external?(value.strip.downcase)
|
174
174
|
unless cached_warning("internal", "reversed", value)
|
175
|
-
logger.
|
175
|
+
logger.info("The mapper [external, internal] attribute names may be declared reversedly for INTERNAL attribute: '#{value}'")
|
176
176
|
end
|
177
177
|
end
|
178
178
|
end
|
@@ -12,7 +12,7 @@ module Eco
|
|
12
12
|
alias_method :fm, :file_manager
|
13
13
|
|
14
14
|
include Session::Helpers
|
15
|
-
|
15
|
+
|
16
16
|
def initialize(e)
|
17
17
|
raise "Expected object Eco::API::Common::Session::Environment. Given: #{e.class}" unless e.is_a?(Environment)
|
18
18
|
self.environment = e
|
@@ -72,7 +72,6 @@ module Eco
|
|
72
72
|
logger.fatal(msg)
|
73
73
|
raise msg
|
74
74
|
end
|
75
|
-
|
76
75
|
end
|
77
76
|
end
|
78
77
|
end
|
@@ -24,9 +24,8 @@ module Eco
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def mailer
|
27
|
-
|
28
|
-
|
29
|
-
end
|
27
|
+
return nil unless mailer?
|
28
|
+
@mailer ||= Eco::API::Common::Session::Mailer.new(enviro: self)
|
30
29
|
end
|
31
30
|
|
32
31
|
def mailer?
|
@@ -34,9 +33,8 @@ module Eco
|
|
34
33
|
end
|
35
34
|
|
36
35
|
def sftp
|
37
|
-
|
38
|
-
|
39
|
-
end
|
36
|
+
return nil unless sftp?
|
37
|
+
@sftp ||= Eco::API::Common::Session::SFTP.new(enviro: self)
|
40
38
|
end
|
41
39
|
|
42
40
|
def sftp?
|
@@ -44,9 +42,8 @@ module Eco
|
|
44
42
|
end
|
45
43
|
|
46
44
|
def s3uploader
|
47
|
-
|
48
|
-
|
49
|
-
end
|
45
|
+
return nil unless s3uploader?
|
46
|
+
@s3uploader ||= Eco::API::Common::Session::S3Uploader.new(enviro: self)
|
50
47
|
end
|
51
48
|
|
52
49
|
def s3uploader?
|
@@ -56,7 +53,6 @@ module Eco
|
|
56
53
|
def api(version: nil)
|
57
54
|
config.api(logger, version: version)
|
58
55
|
end
|
59
|
-
|
60
56
|
end
|
61
57
|
end
|
62
58
|
end
|
@@ -1,31 +1,31 @@
|
|
1
|
-
require 'timeout'
|
2
1
|
module Eco
|
3
2
|
module API
|
4
3
|
module Common
|
5
4
|
module Session
|
6
5
|
module Helpers
|
7
6
|
module PromptUser
|
8
|
-
|
7
|
+
# Prompts user for input with option for default on timeout.
|
9
8
|
def prompt_user(question, default:, explanation: "", timeout: nil)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
9
|
+
require 'timeout'
|
10
|
+
response = \
|
11
|
+
if config.run_mode_remote?
|
12
|
+
default
|
13
|
+
else
|
14
|
+
puts explanation
|
15
|
+
print "#{question} "
|
16
|
+
if timeout
|
17
|
+
begin
|
18
|
+
Timeout::timeout(timeout) { STDIN.gets.chop }
|
19
|
+
rescue Timeout::Error
|
20
|
+
default
|
21
|
+
end
|
22
|
+
else
|
23
|
+
STDIN.gets.chop
|
24
|
+
end
|
25
|
+
end
|
25
26
|
return response unless block_given?
|
26
27
|
yield(response)
|
27
28
|
end
|
28
|
-
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'aws-sdk-ses'
|
2
|
-
|
3
1
|
module Eco
|
4
2
|
module API
|
5
3
|
module Common
|
@@ -42,6 +40,7 @@ module Eco
|
|
42
40
|
private
|
43
41
|
|
44
42
|
def ses
|
43
|
+
require 'aws-sdk-ses'
|
45
44
|
begin
|
46
45
|
@ses ||= Aws::SES::Client.new(
|
47
46
|
access_key_id: fetch_access_key_id,
|
@@ -98,7 +97,6 @@ module Eco
|
|
98
97
|
def fetch_message_id_domain
|
99
98
|
config.mailer.message_id_domain
|
100
99
|
end
|
101
|
-
|
102
100
|
end
|
103
101
|
end
|
104
102
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'aws-sdk-s3'
|
2
|
-
|
3
1
|
module Eco
|
4
2
|
module API
|
5
3
|
module Common
|
@@ -75,6 +73,7 @@ module Eco
|
|
75
73
|
end
|
76
74
|
|
77
75
|
def bucket
|
76
|
+
require 'aws-sdk-s3'
|
78
77
|
begin
|
79
78
|
@bucket ||= Aws::S3::Resource.new(
|
80
79
|
access_key_id: fetch_access_key_id,
|
@@ -128,7 +127,6 @@ module Eco
|
|
128
127
|
def fetch_region
|
129
128
|
config.s3storage.region || ENV['AWS_REGION']
|
130
129
|
end
|
131
|
-
|
132
130
|
end
|
133
131
|
end
|
134
132
|
end
|
@@ -1,20 +1,23 @@
|
|
1
|
-
require "net/sftp"
|
2
1
|
module Eco
|
3
2
|
module API
|
4
3
|
module Common
|
5
4
|
module Session
|
6
5
|
class SFTP
|
7
|
-
|
8
6
|
def initialize (enviro:)
|
9
7
|
raise "Required Environment object (enviro:). Given: #{enviro}" if enviro && !enviro.is_a?(Eco::API::Common::Session::Environment)
|
10
8
|
@enviro = enviro
|
11
9
|
end
|
12
10
|
|
11
|
+
def host
|
12
|
+
@host ||= fetch_host
|
13
|
+
end
|
14
|
+
|
13
15
|
# @see Net::SFTP::Session
|
14
16
|
def sftp_session
|
17
|
+
require "net/sftp"
|
15
18
|
begin
|
16
19
|
@sftp_session ||= Net::SFTP.start(
|
17
|
-
|
20
|
+
host,
|
18
21
|
fetch_user,
|
19
22
|
**session_options
|
20
23
|
)
|
@@ -135,7 +138,6 @@ module Eco
|
|
135
138
|
def fetch_base_path
|
136
139
|
config.sftp.base_path || ENV['SFTP_BASE_PATH']
|
137
140
|
end
|
138
|
-
|
139
141
|
end
|
140
142
|
end
|
141
143
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
module
|
1
|
+
module Eco
|
2
2
|
module API
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Common
|
4
|
+
module PersonPatch
|
5
|
+
# @attr entry [Eco::API::Common::People::PersonEntry, Hash] the input entry plain hash data used to update/create this person.
|
6
6
|
attr_accessor :entry
|
7
7
|
|
8
8
|
def identify(section = :person)
|
@@ -14,6 +14,7 @@ module Ecoportal
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
17
|
+
Ecoportal::API::V1::Person.include PersonPatch
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -24,8 +24,10 @@ module Eco
|
|
24
24
|
when :v1
|
25
25
|
Ecoportal::API::V1
|
26
26
|
when :v2
|
27
|
+
require 'ecoportal/api-v2'
|
27
28
|
Ecoportal::API::V2
|
28
29
|
when :graphql
|
30
|
+
require 'ecoportal/api-graphql'
|
29
31
|
Ecoportal::API::GraphQL
|
30
32
|
else
|
31
33
|
end
|
@@ -45,8 +47,8 @@ module Eco
|
|
45
47
|
self["mode"] = mode
|
46
48
|
self["user_key"] = user_key
|
47
49
|
self["external_key"] = external_key
|
48
|
-
self["email"] = email
|
49
|
-
self["pass"] = pass
|
50
|
+
self["email"] = email || ENV['USER_EMAIL']
|
51
|
+
self["pass"] = pass || ENV['USER_PASS']
|
50
52
|
self["org_id"] = org_id
|
51
53
|
end
|
52
54
|
|
@@ -3,7 +3,6 @@ module Eco
|
|
3
3
|
class UseCases
|
4
4
|
# Core class of UseCases. It basically defines and manages allowed `types`
|
5
5
|
class BaseCase
|
6
|
-
|
7
6
|
class InvalidType < StandardError
|
8
7
|
def initialize(msg = nil, type:, types:)
|
9
8
|
msg ||= "Invalid type."
|
@@ -27,7 +26,6 @@ module Eco
|
|
27
26
|
raise InvalidType.new(type: type, types: types) unless valid_type?(type)
|
28
27
|
end
|
29
28
|
end
|
30
|
-
|
31
29
|
end
|
32
30
|
end
|
33
31
|
end
|
@@ -26,7 +26,6 @@ module Eco
|
|
26
26
|
def people_required?(type)
|
27
27
|
!valid_type?(type) || [:filter, :transform, :sync, :error_handler, :export].include?(type)
|
28
28
|
end
|
29
|
-
|
30
29
|
end
|
31
30
|
|
32
31
|
attr_reader :input, :people, :session, :options
|
@@ -111,9 +110,7 @@ module Eco
|
|
111
110
|
def people_required?
|
112
111
|
self.class.people_required?(type)
|
113
112
|
end
|
114
|
-
|
115
113
|
end
|
116
|
-
|
117
114
|
end
|
118
115
|
end
|
119
116
|
end
|
@@ -47,7 +47,7 @@ class Eco::API::UseCases::DefaultCases::Samples::Sftp < Eco::API::Common::Loader
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def list_folder
|
50
|
-
puts "Listing remote folder: '#{remote_folder}':"
|
50
|
+
puts "Listing remote folder: '#{remote_folder}' (host: #{sftp.host}):"
|
51
51
|
with_remote_files {|file| puts file.longname}
|
52
52
|
end
|
53
53
|
|