eco-helpers 3.0.25 → 3.0.27
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/CHANGELOG.md +39 -1
- data/eco-helpers.gemspec +1 -1
- data/lib/eco/api/common/loaders/base.rb +13 -1
- data/lib/eco/api/common/loaders/case_base.rb +1 -1
- data/lib/eco/api/common/loaders/error_handler.rb +1 -1
- data/lib/eco/api/common/loaders/parser.rb +2 -2
- data/lib/eco/api/common/loaders/policy.rb +1 -1
- data/lib/eco/api/common/loaders/use_case.rb +1 -1
- data/lib/eco/api/common/people/default_parsers/archived_parser.rb +19 -0
- data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +4 -4
- data/lib/eco/api/common/people/default_parsers/date_parser.rb +3 -3
- data/lib/eco/api/common/people/default_parsers/freemium_parser.rb +6 -6
- data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +3 -3
- data/lib/eco/api/common/people/default_parsers/multi_parser.rb +4 -4
- data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +9 -6
- data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +6 -5
- data/lib/eco/api/common/people/default_parsers/xls_parser.rb +2 -2
- data/lib/eco/api/common/people/default_parsers.rb +1 -0
- data/lib/eco/api/common/people/entries.rb +16 -15
- data/lib/eco/api/common/people/person_entry.rb +53 -37
- data/lib/eco/api/common/people/person_parser.rb +8 -6
- data/lib/eco/api/common/session/logger/channels.rb +1 -1
- data/lib/eco/api/common/session/logger.rb +2 -2
- data/lib/eco/api/common/session/mailer/aws_provider.rb +3 -2
- data/lib/eco/api/common/session/mailer/provider_base.rb +6 -2
- data/lib/eco/api/common/session/mailer/sendgrid_provider.rb +9 -9
- data/lib/eco/api/common/session/mailer.rb +8 -3
- data/lib/eco/api/common/session/sftp.rb +2 -2
- data/lib/eco/api/common/version_patches/object.rb +2 -1
- data/lib/eco/api/custom/mailer.rb +1 -1
- data/lib/eco/api/error/handlers.rb +3 -3
- data/lib/eco/api/error.rb +17 -17
- data/lib/eco/api/microcases/people/apply_changes/set_account/account_excluded.rb +3 -11
- data/lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb +4 -1
- data/lib/eco/api/microcases/people/manage/search.rb +3 -1
- data/lib/eco/api/organization/people.rb +1 -0
- data/lib/eco/api/policies.rb +2 -2
- data/lib/eco/api/session/batch/job.rb +2 -2
- data/lib/eco/api/session/batch/launcher.rb +4 -5
- data/lib/eco/api/session/batch/searcher.rb +4 -4
- data/lib/eco/api/session/config/api.rb +2 -2
- data/lib/eco/api/session/config/apis/enviro_spaces.rb +3 -3
- data/lib/eco/api/session/config/apis/space_helpers.rb +4 -4
- data/lib/eco/api/session/config/apis.rb +1 -1
- data/lib/eco/api/session/config/post_launch.rb +7 -4
- data/lib/eco/api/session/config/sftp.rb +1 -1
- data/lib/eco/api/session/config/tagtree.rb +1 -1
- data/lib/eco/api/session/config/workflow.rb +4 -4
- data/lib/eco/api/session/config.rb +25 -24
- data/lib/eco/api/session.rb +4 -4
- data/lib/eco/api/usecases/base_io/validations.rb +4 -3
- data/lib/eco/api/usecases/cli/option.rb +5 -2
- data/lib/eco/api/usecases/default/people/amend/clear_abilities_case.rb +2 -2
- data/lib/eco/api/usecases/default/people/amend/restore_db_case.rb +16 -9
- data/lib/eco/api/usecases/default/people/treat/analyse_people_case.rb +20 -20
- data/lib/eco/api/usecases/default.rb +5 -5
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +8 -8
- data/lib/eco/api/usecases/default_cases/upsert_case.rb +4 -4
- data/lib/eco/api/usecases/graphql/helpers/base.rb +1 -1
- data/lib/eco/api/usecases/graphql/helpers/location/base/tree_tracking.rb +5 -1
- data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb +2 -1
- data/lib/eco/api/usecases/graphql/helpers/location/command/result.rb +3 -3
- data/lib/eco/api/usecases/graphql/helpers/location/command.rb +3 -0
- data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +2 -2
- data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +9 -3
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb +5 -4
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb +5 -2
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +3 -3
- data/lib/eco/api/usecases/graphql/utils/sftp.rb +1 -1
- data/lib/eco/api/usecases/lib/{file_pattern.rb → files/file_pattern.rb} +5 -1
- data/lib/eco/api/usecases/lib/{sftp.rb → files/sftp.rb} +27 -16
- data/lib/eco/api/usecases/lib/files.rb +7 -0
- data/lib/eco/api/usecases/lib.rb +1 -2
- data/lib/eco/api/usecases/ooze_cases/export_register_case.rb +5 -5
- data/lib/eco/api/usecases/ooze_samples/helpers/exportable_ooze.rb +14 -11
- data/lib/eco/api/usecases/ooze_samples/helpers_migration/copying.rb +14 -23
- data/lib/eco/api/usecases/ooze_samples/helpers_migration/typed_fields_pairing.rb +49 -27
- data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +9 -9
- data/lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb +1 -1
- data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +25 -17
- data/lib/eco/api/usecases/ooze_samples/register_migration_case.rb +41 -24
- data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +16 -15
- data/lib/eco/api/usecases/samples/drivers/cli/sftp_cli.rb +15 -15
- data/lib/eco/api/usecases/samples/drivers/cli/url_pull_cli.rb +5 -5
- data/lib/eco/api/usecases/samples/drivers/sftp_sample.rb +2 -2
- data/lib/eco/api/usecases/use_case.rb +6 -6
- data/lib/eco/api/usecases/use_case_chain/chaining.rb +6 -6
- data/lib/eco/api/usecases/use_case_chain.rb +4 -4
- data/lib/eco/api/usecases/use_case_io.rb +2 -1
- data/lib/eco/api/usecases.rb +9 -9
- data/lib/eco/cli/config/options_set.rb +4 -4
- data/lib/eco/cli/config/use_cases.rb +3 -3
- data/lib/eco/cli/scripting/argument.rb +1 -1
- data/lib/eco/cli_default/input.rb +9 -9
- data/lib/eco/cli_default/options.rb +125 -100
- data/lib/eco/cli_default/people.rb +3 -3
- data/lib/eco/cli_default/usecases.rb +83 -83
- data/lib/eco/cli_default/workflow.rb +7 -7
- data/lib/eco/data/files/helpers.rb +3 -3
- data/lib/eco/data/fuzzy_match/result.rb +69 -26
- data/lib/eco/data/fuzzy_match/results.rb +10 -10
- data/lib/eco/data/fuzzy_match/score.rb +13 -8
- data/lib/eco/data/fuzzy_match.rb +65 -48
- data/lib/eco/data/locations/node_base/treeify.rb +13 -11
- data/lib/eco/data/mapper.rb +4 -4
- data/lib/eco/language/auxiliar_logger.rb +4 -4
- data/lib/eco/language/delegation/const_delegator.rb +64 -0
- data/lib/eco/language/delegation/const_lookup_hooks.rb +81 -0
- data/lib/eco/language/delegation/delegated_class.rb +84 -0
- data/lib/eco/language/delegation.rb +8 -0
- data/lib/eco/language/klass/when_inherited.rb +1 -0
- data/lib/eco/language/methods/delegate_missing.rb +1 -0
- data/lib/eco/language/models/class_helpers.rb +25 -23
- data/lib/eco/language/models/collection.rb +12 -2
- data/lib/eco/language.rb +1 -0
- data/lib/eco/version.rb +1 -1
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc0d97c18d012621fea4cc9df6f7f3af54ba2a29da761c123c2502e7708f2267
|
4
|
+
data.tar.gz: ea83680a1a302da67ecdded6a0ea22043effe995d496c88289e7f55d54c9bde1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c0c45e02b3d5ee47fe5de33d38a4b1ade68eb759d1134b1df6c0880cbbba128f78299b2687af9177ca858a353e750339c2a85fc9731f78d194fd347faf329f0
|
7
|
+
data.tar.gz: 96e499c457c58667a29fffd0f0779bc986b6fc5635c1de4a5d0be5526778bd6065f6305f94c39f63badebfd8474ac76c5c780c766d28ae4824d1743ddf49e986
|
data/CHANGELOG.md
CHANGED
@@ -2,14 +2,52 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
## [3.0.
|
5
|
+
## [3.0.27] - 2025-03-xx
|
6
6
|
|
7
7
|
### Added
|
8
8
|
|
9
|
+
- For `Ecoportal::API::V1::Person#archived` (**archived** flag)
|
10
|
+
- `PersonParser::CORE_ATTRS`: **exposed** `archived`
|
11
|
+
- Added `DefaultParsers::ArchivedParser`
|
12
|
+
- **Options** to **exclude** `archived`
|
13
|
+
- `PersonEntry`
|
14
|
+
- added methods `#archived` and `archived_key?`
|
15
|
+
- **enforced** `boolan` parsing and serializing
|
16
|
+
- For `Ecoportal::API::V1::Person#contractor_organization_id`
|
17
|
+
- Added **option** to `exclude-contractor-organization` from people updates.
|
18
|
+
- `PersonEntry`
|
19
|
+
- added methods `#contractor_organization_id` and `contractor_organization_id?`
|
20
|
+
- Updated `restore-db` case with the new exclusions
|
21
|
+
- Included copying of `contractor_organization_id` and `archived`
|
22
|
+
- `Eco::Language::Delegation`
|
23
|
+
- See usage at <https://stackoverflow.com/a/79537526/4352306> for usage.
|
24
|
+
|
9
25
|
### Changed
|
10
26
|
|
27
|
+
- Moved `Lib::Sftp` and `Lib::FilePattern` to `Lib::Files`
|
28
|
+
- `Lib::Files::Sftp`: some configurable parameters could already exist via **method**
|
29
|
+
- Check if `super` exists
|
30
|
+
- This gives precedence to existing methods (over i.e. **const**, over **options** cli modifiers; ... may need review at a later stage)
|
31
|
+
- `Eco::API::Common::People::DefaultParsers::BooleanParser`
|
32
|
+
- Renamed method from `truthy` to `truthy?`
|
33
|
+
- upgraded `ecoportal-api` gem
|
34
|
+
|
11
35
|
### Fixed
|
12
36
|
|
37
|
+
- align `respond_to` with `send` (should check private methods too).
|
38
|
+
- `Lib::Files::FilePattern`
|
39
|
+
- should allow `file_pattern` method to be **private**.
|
40
|
+
- `ClassHelpers`... `inherited` should call **super**.
|
41
|
+
|
42
|
+
## [3.0.26] - 2025-03-23
|
43
|
+
|
44
|
+
### Added
|
45
|
+
|
46
|
+
- default constant for `FILE_PATTERN`
|
47
|
+
- `Loaders::Base` **added**:
|
48
|
+
- `#api_space` and `#api_space_default?`
|
49
|
+
- `GROUP_ID` constant to also spot the sftp **gid**
|
50
|
+
|
13
51
|
## [3.0.25] - 2025-03-23
|
14
52
|
|
15
53
|
### Added
|
data/eco-helpers.gemspec
CHANGED
@@ -40,7 +40,7 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_dependency 'bcrypt_pbkdf', '~> 1.0'
|
41
41
|
spec.add_dependency 'docx', '>= 0.8.0', '< 0.9'
|
42
42
|
spec.add_dependency 'dotenv', '~> 3'
|
43
|
-
spec.add_dependency 'ecoportal-api', '~> 0.10', '>= 0.10.
|
43
|
+
spec.add_dependency 'ecoportal-api', '~> 0.10', '>= 0.10.9'
|
44
44
|
spec.add_dependency 'ecoportal-api-graphql', '~> 0.4', '>= 0.4.5'
|
45
45
|
spec.add_dependency 'ecoportal-api-v2', '~> 2.0', '>= 2.0.16'
|
46
46
|
spec.add_dependency 'ed25519', '~> 1.2'
|
@@ -27,11 +27,23 @@ module Eco
|
|
27
27
|
# @note
|
28
28
|
# - this method should implement the loading logics for the given `Children` class.
|
29
29
|
def initialize
|
30
|
-
raise
|
30
|
+
raise 'You should implement this method'
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
+
def api_space_default?
|
36
|
+
space = api_space
|
37
|
+
return true if space.nil?
|
38
|
+
return true if space == :default
|
39
|
+
|
40
|
+
false
|
41
|
+
end
|
42
|
+
|
43
|
+
def api_space
|
44
|
+
options.dig(:api, :space)
|
45
|
+
end
|
46
|
+
|
35
47
|
def simulate?
|
36
48
|
options[:simulate] || options[:dry_run]
|
37
49
|
end
|
@@ -32,7 +32,7 @@ module Eco
|
|
32
32
|
# @param handler [Eco::API::Error::Hanlder] the `error handler` instance object.
|
33
33
|
# @param job [Eco::API::Session::Batch::Job] the `Batch::Job` made on purpose for this handler.
|
34
34
|
def main(data, session, options, handler, job) # rubocop:disable Lint/UnusedMethodArgument
|
35
|
-
raise
|
35
|
+
raise 'You should implement this method'
|
36
36
|
end
|
37
37
|
|
38
38
|
def error
|
@@ -134,7 +134,7 @@ module Eco
|
|
134
134
|
# (i.e. Array instread of String with '|' delimiters).
|
135
135
|
# @param deps [Hash] the merged dependencies (default to the class object and when calling the parser).
|
136
136
|
def parser(_data, _deps)
|
137
|
-
raise
|
137
|
+
raise 'You should implement this method'
|
138
138
|
end
|
139
139
|
|
140
140
|
# @param data [Hash, Ecoportal::API::V1::Person] all the person data at the specified `serializing_phase`:
|
@@ -144,7 +144,7 @@ module Eco
|
|
144
144
|
# - when `:person`: it will receive the `person` object.
|
145
145
|
# @param deps [Hash] the merged dependencies (default to the class object and when calling the parser).
|
146
146
|
# def serializer(data, deps)
|
147
|
-
# raise
|
147
|
+
# raise 'You should implement this method'
|
148
148
|
# end
|
149
149
|
|
150
150
|
# @return [String, Symbol] the field/attribute or type this parser is linked to.
|
@@ -17,7 +17,7 @@ module Eco
|
|
17
17
|
# @param policy [Eco::API::Policies::Policy] the `policy` instance object.
|
18
18
|
# @param job [Eco::API::Session::Batch::Job] the `Batch::Job` that these `people` belong to the queue thereof.
|
19
19
|
def main(data, session, options, policy, job = nil) # rubocop:disable Lint/UnusedMethodArgument
|
20
|
-
raise
|
20
|
+
raise 'You should implement this method'
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -33,7 +33,7 @@ module Eco
|
|
33
33
|
# @param options [Hash] the options that modify the case behaviour or bring some dependencies.
|
34
34
|
# @param usecase [Eco::API::Policies::Policy] the `usecase` instance object.
|
35
35
|
def main(*_args)
|
36
|
-
raise
|
36
|
+
raise 'You should implement this method'
|
37
37
|
end
|
38
38
|
|
39
39
|
def cli_apply!
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Eco::API::Common::People::DefaultParsers::ArchivedParser < Eco::API::Common::Loaders::Parser
|
2
|
+
attribute 'archived'
|
3
|
+
|
4
|
+
def parser(hash, _deps)
|
5
|
+
value = hash[attribute]
|
6
|
+
value = value.first if value.is_a?(Array)
|
7
|
+
truthy?(value)
|
8
|
+
end
|
9
|
+
|
10
|
+
def serializer(person, _deps)
|
11
|
+
person.archived?.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def truthy?(value)
|
17
|
+
%w[true y yes x].include?(value.to_s&.downcase)
|
18
|
+
end
|
19
|
+
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
class Eco::API::Common::People::DefaultParsers::BooleanParser < Eco::API::Common::Loaders::Parser
|
2
2
|
attribute :boolean
|
3
3
|
|
4
|
-
def parser(value,
|
5
|
-
value.is_a?(Array) ? value.map { |v| truthy(v) } : truthy(value)
|
4
|
+
def parser(value, _deps)
|
5
|
+
value.is_a?(Array) ? value.map { |v| truthy?(v) } : truthy?(value)
|
6
6
|
end
|
7
7
|
|
8
|
-
def serializer(value,
|
8
|
+
def serializer(value, _deps)
|
9
9
|
value.to_s
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
-
def truthy(value)
|
14
|
+
def truthy?(value)
|
15
15
|
%w[true y yes x].include?(value.to_s.strip.downcase)
|
16
16
|
end
|
17
17
|
end
|
@@ -16,7 +16,7 @@ class Eco::API::Common::People::DefaultParsers::DateParser < Eco::API::Common::L
|
|
16
16
|
|
17
17
|
def parse_date(value, attr:)
|
18
18
|
return value.map {|val| parse_date(val, attr: attr)}.compact if value.is_a?(Enumerable)
|
19
|
-
return
|
19
|
+
return if blank?(value)
|
20
20
|
|
21
21
|
value = value.to_s.strip
|
22
22
|
return wrong!(value, attr: attr) unless date?(value)
|
@@ -31,9 +31,9 @@ class Eco::API::Common::People::DefaultParsers::DateParser < Eco::API::Common::L
|
|
31
31
|
|
32
32
|
def serialize_date(value)
|
33
33
|
return value.map {|val| serialize_date(val)}.compact if value.is_a?(Enumerable)
|
34
|
-
return
|
34
|
+
return if blank?(value)
|
35
35
|
return value if value.is_a?(String)
|
36
|
-
return
|
36
|
+
return unless [Date, Time].any? {|type| value.is_a?(type)}
|
37
37
|
|
38
38
|
value&.strftime('%Y-%m-%d')
|
39
39
|
rescue TypeError, Date::Error
|
@@ -1,19 +1,19 @@
|
|
1
1
|
class Eco::API::Common::People::DefaultParsers::FreemiumParser < Eco::API::Common::Loaders::Parser
|
2
|
-
attribute
|
2
|
+
attribute 'freemium'
|
3
3
|
|
4
|
-
def parser(hash,
|
5
|
-
value = hash[
|
4
|
+
def parser(hash, _deps)
|
5
|
+
value = hash['freemium']
|
6
6
|
value = value.first if value.is_a?(Array)
|
7
|
-
truthy(value)
|
7
|
+
truthy?(value)
|
8
8
|
end
|
9
9
|
|
10
|
-
def serializer(person,
|
10
|
+
def serializer(person, _deps)
|
11
11
|
person.freemium&.to_s
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def truthy
|
16
|
+
def truthy?(value)
|
17
17
|
%w[true y yes x].include?(value.to_s&.downcase)
|
18
18
|
end
|
19
19
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class Eco::API::Common::People::DefaultParsers::LoginProvidersParser < Eco::API::Common::Loaders::Parser
|
2
|
-
attribute
|
2
|
+
attribute 'login_provider_ids'
|
3
3
|
parsing_phase :final
|
4
4
|
serializing_phase :final
|
5
5
|
|
6
6
|
def parser(hash, _deps)
|
7
|
-
hash[
|
7
|
+
hash['login_provider_ids'].map do |name|
|
8
8
|
login_providers.to_id(name&.downcase&.strip).tap do |known|
|
9
9
|
unless !name || known || unknown_pgs.include?(name)
|
10
10
|
unknown_pgs.push(name)
|
@@ -15,7 +15,7 @@ class Eco::API::Common::People::DefaultParsers::LoginProvidersParser < Eco::API:
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def serializer(hash, _deps)
|
18
|
-
if (ids = hash[
|
18
|
+
if (ids = hash['login_provider_ids'])
|
19
19
|
login_providers.to_name(ids)
|
20
20
|
else
|
21
21
|
[]
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class Eco::API::Common::People::DefaultParsers::MultiParser < Eco::API::Common::Loaders::Parser
|
2
2
|
attribute :multiple
|
3
3
|
|
4
|
-
def parser(value,
|
4
|
+
def parser(value, _deps)
|
5
5
|
into_a(value)
|
6
6
|
end
|
7
7
|
|
8
|
-
def serializer(value,
|
9
|
-
into_a(value).join(
|
8
|
+
def serializer(value, _deps)
|
9
|
+
into_a(value).join('|')
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
@@ -14,7 +14,7 @@ class Eco::API::Common::People::DefaultParsers::MultiParser < Eco::API::Common::
|
|
14
14
|
def into_a(value)
|
15
15
|
return [] if value.nil?
|
16
16
|
return value if value.is_a?(Array)
|
17
|
-
return value.split(
|
17
|
+
return value.split('|') if value.is_a?(String) && value.include?('|')
|
18
18
|
[].push(value)
|
19
19
|
end
|
20
20
|
end
|
@@ -1,15 +1,18 @@
|
|
1
1
|
class Eco::API::Common::People::DefaultParsers::PolicyGroupsParser < Eco::API::Common::Loaders::Parser
|
2
|
-
attribute
|
2
|
+
attribute 'policy_group_ids'
|
3
3
|
parsing_phase :final
|
4
4
|
|
5
5
|
def parser(hash, _deps)
|
6
|
-
policy_group_ids = hash[
|
6
|
+
policy_group_ids = hash['policy_group_ids'] || []
|
7
|
+
|
7
8
|
policy_group_ids.map do |name|
|
8
9
|
policy_groups.to_id(name&.downcase&.strip).tap do |known|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
next if known
|
11
|
+
next if name.nil?
|
12
|
+
next if unknown_pgs.include?(name)
|
13
|
+
|
14
|
+
unknown_pgs.push(name)
|
15
|
+
log(:warn) { "Unknown Policy Group: '#{name}'" }
|
13
16
|
end
|
14
17
|
end.compact.tap do |pg_names|
|
15
18
|
pg_names.push(default_id) if pg_names.empty?
|
@@ -1,20 +1,21 @@
|
|
1
1
|
class Eco::API::Common::People::DefaultParsers::SendInvitesParser < Eco::API::Common::Loaders::Parser
|
2
|
-
attribute
|
2
|
+
attribute 'send_invites'
|
3
3
|
|
4
4
|
def parser(hash, _deps)
|
5
|
-
value = hash[
|
5
|
+
value = hash['send_invites']
|
6
6
|
value = value.first if value.is_a?(Array)
|
7
|
-
truthy(value)
|
7
|
+
truthy?(value)
|
8
8
|
end
|
9
9
|
|
10
10
|
def serializer(person, _deps)
|
11
|
-
return unless account = person.account
|
11
|
+
return unless (account = person.account)
|
12
|
+
|
12
13
|
account.send_invites&.to_s
|
13
14
|
end
|
14
15
|
|
15
16
|
private
|
16
17
|
|
17
|
-
def truthy(value)
|
18
|
+
def truthy?(value)
|
18
19
|
%w[true y yes x].include?(value.to_s&.downcase)
|
19
20
|
end
|
20
21
|
end
|
@@ -12,7 +12,7 @@ class Eco::API::Common::People::DefaultParsers::XLSParser < Eco::API::Common::Lo
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def serializer(_array_hash, _deps)
|
15
|
-
raise
|
15
|
+
raise 'Not implemented. TODO: using axlsx or rubyXL gems. See: https://spin.atomicobject.com/2017/03/22/parsing-excel-files-ruby/'
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
@@ -28,7 +28,7 @@ class Eco::API::Common::People::DefaultParsers::XLSParser < Eco::API::Common::Lo
|
|
28
28
|
|
29
29
|
def expected_headers
|
30
30
|
log(:info) {
|
31
|
-
|
31
|
+
'Headers detection is using your fields_map.json file (native behaviour)'
|
32
32
|
}
|
33
33
|
session.fields_mapper.list(:external).uniq
|
34
34
|
end
|
@@ -19,6 +19,7 @@ require_relative 'default_parsers/numeric_parser'
|
|
19
19
|
require_relative 'default_parsers/date_parser'
|
20
20
|
require_relative 'default_parsers/multi_parser'
|
21
21
|
require_relative 'default_parsers/send_invites_parser'
|
22
|
+
require_relative 'default_parsers/archived_parser'
|
22
23
|
require_relative 'default_parsers/freemium_parser'
|
23
24
|
require_relative 'default_parsers/policy_groups_parser'
|
24
25
|
require_relative 'default_parsers/login_providers_parser'
|
@@ -16,7 +16,7 @@ module Eco
|
|
16
16
|
# @param candiates [Array<PersonEntry>] the entries that match the same search criterion.
|
17
17
|
# @param property [String] the property of the entry model that triggered the error
|
18
18
|
# (base of the search criterion).
|
19
|
-
def initialize(msg, candidates: [], property:
|
19
|
+
def initialize(msg, candidates: [], property: 'email')
|
20
20
|
@candidates = candidates
|
21
21
|
@property = property
|
22
22
|
super("#{msg} #{candidates_summary}")
|
@@ -26,7 +26,7 @@ module Eco
|
|
26
26
|
# @return [Array<String>] the `candidates` identified
|
27
27
|
def identify_candidates(with_index: false)
|
28
28
|
candidates.map.each_with_index do |entry, i|
|
29
|
-
index = with_index ? "#{i}. " :
|
29
|
+
index = with_index ? "#{i}. " : ''
|
30
30
|
"#{index} #{entry.identify}"
|
31
31
|
end
|
32
32
|
end
|
@@ -50,7 +50,8 @@ module Eco
|
|
50
50
|
alias_method :entries, :to_a
|
51
51
|
|
52
52
|
def initialize(data = [], klass:, factory:)
|
53
|
-
super
|
53
|
+
super
|
54
|
+
|
54
55
|
@caches_init = false
|
55
56
|
end
|
56
57
|
|
@@ -72,19 +73,19 @@ module Eco
|
|
72
73
|
# @!group Special filters
|
73
74
|
|
74
75
|
def filter_tags_any(tags)
|
75
|
-
attr(
|
76
|
+
attr('filter_tags', tags, default_modifier.any.insensitive)
|
76
77
|
end
|
77
78
|
|
78
79
|
def filter_tags_all(tags)
|
79
|
-
attr(
|
80
|
+
attr('filter_tags', tags, default_modifier.all.insensitive)
|
80
81
|
end
|
81
82
|
|
82
83
|
def policy_group_ids_any(ids)
|
83
|
-
attr(
|
84
|
+
attr('policy_group_ids', ids, default_modifier.any.insensitive)
|
84
85
|
end
|
85
86
|
|
86
87
|
def policy_group_ids_all(ids)
|
87
|
-
attr(
|
88
|
+
attr('policy_group_ids', ids, default_modifier.all.insensitive)
|
88
89
|
end
|
89
90
|
# @!endgroup
|
90
91
|
|
@@ -125,9 +126,9 @@ module Eco
|
|
125
126
|
# Search function to find an `entry` based on one of different options
|
126
127
|
# see Eco::API::Common::People::Entries#entry
|
127
128
|
def find(object, strict: false)
|
128
|
-
id = attr_value(object,
|
129
|
-
external_id = attr_value(object,
|
130
|
-
email = attr_value(object,
|
129
|
+
id = attr_value(object, 'id')
|
130
|
+
external_id = attr_value(object, 'external_id')
|
131
|
+
email = attr_value(object, 'email')
|
131
132
|
entry(id: id, external_id: external_id, email: email, strict: strict)
|
132
133
|
end
|
133
134
|
# @!endgroup
|
@@ -159,7 +160,7 @@ module Eco
|
|
159
160
|
header = each_with_object([]) do |entry, hds|
|
160
161
|
hds.push(*entry.internal_entry.keys).uniq!
|
161
162
|
end
|
162
|
-
CSV.open(filename,
|
163
|
+
CSV.open(filename, 'w') do |csv|
|
163
164
|
csv << header
|
164
165
|
each do |entry|
|
165
166
|
csv << entry.internal_entry.values_at(*header)
|
@@ -177,8 +178,8 @@ module Eco
|
|
177
178
|
to_h(:supervisor_id)
|
178
179
|
end
|
179
180
|
|
180
|
-
def to_h(attr =
|
181
|
-
super(attr ||
|
181
|
+
def to_h(attr = 'id')
|
182
|
+
super(attr || 'id')
|
182
183
|
end
|
183
184
|
# @!endgroup
|
184
185
|
|
@@ -197,8 +198,8 @@ module Eco
|
|
197
198
|
return candidates.first if candidates.length == 1
|
198
199
|
|
199
200
|
if prevent_multiple_match && !candidates.empty?
|
200
|
-
msg =
|
201
|
-
raise MultipleSearchResults.new(msg, candidates: candidates, property:
|
201
|
+
msg = 'Multiple search results match the criteria.'
|
202
|
+
raise MultipleSearchResults.new(msg, candidates: candidates, property: 'email')
|
202
203
|
end
|
203
204
|
|
204
205
|
@by_external_id[email]&.first
|