eco-helpers 3.0.26 → 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.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -5
  3. data/eco-helpers.gemspec +1 -1
  4. data/lib/eco/api/common/loaders/base.rb +1 -1
  5. data/lib/eco/api/common/loaders/case_base.rb +1 -1
  6. data/lib/eco/api/common/loaders/error_handler.rb +1 -1
  7. data/lib/eco/api/common/loaders/parser.rb +2 -2
  8. data/lib/eco/api/common/loaders/policy.rb +1 -1
  9. data/lib/eco/api/common/loaders/use_case.rb +1 -1
  10. data/lib/eco/api/common/people/default_parsers/archived_parser.rb +19 -0
  11. data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +4 -4
  12. data/lib/eco/api/common/people/default_parsers/date_parser.rb +3 -3
  13. data/lib/eco/api/common/people/default_parsers/freemium_parser.rb +6 -6
  14. data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +3 -3
  15. data/lib/eco/api/common/people/default_parsers/multi_parser.rb +4 -4
  16. data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +9 -6
  17. data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +6 -5
  18. data/lib/eco/api/common/people/default_parsers/xls_parser.rb +2 -2
  19. data/lib/eco/api/common/people/default_parsers.rb +1 -0
  20. data/lib/eco/api/common/people/entries.rb +16 -15
  21. data/lib/eco/api/common/people/person_entry.rb +53 -37
  22. data/lib/eco/api/common/people/person_parser.rb +8 -6
  23. data/lib/eco/api/common/session/logger/channels.rb +1 -1
  24. data/lib/eco/api/common/session/logger.rb +2 -2
  25. data/lib/eco/api/common/session/mailer/aws_provider.rb +3 -2
  26. data/lib/eco/api/common/session/mailer/provider_base.rb +2 -1
  27. data/lib/eco/api/common/session/mailer/sendgrid_provider.rb +9 -9
  28. data/lib/eco/api/common/session/mailer.rb +5 -3
  29. data/lib/eco/api/common/session/sftp.rb +2 -2
  30. data/lib/eco/api/common/version_patches/object.rb +2 -1
  31. data/lib/eco/api/custom/mailer.rb +1 -1
  32. data/lib/eco/api/error/handlers.rb +3 -3
  33. data/lib/eco/api/error.rb +17 -17
  34. data/lib/eco/api/microcases/people/apply_changes/set_account/account_excluded.rb +3 -11
  35. data/lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb +4 -1
  36. data/lib/eco/api/microcases/people/manage/search.rb +3 -1
  37. data/lib/eco/api/organization/people.rb +1 -0
  38. data/lib/eco/api/policies.rb +2 -2
  39. data/lib/eco/api/session/batch/job.rb +2 -2
  40. data/lib/eco/api/session/batch/launcher.rb +4 -5
  41. data/lib/eco/api/session/batch/searcher.rb +4 -4
  42. data/lib/eco/api/session/config/api.rb +2 -2
  43. data/lib/eco/api/session/config/apis/enviro_spaces.rb +2 -2
  44. data/lib/eco/api/session/config/post_launch.rb +7 -4
  45. data/lib/eco/api/session/config/sftp.rb +1 -1
  46. data/lib/eco/api/session/config/tagtree.rb +1 -1
  47. data/lib/eco/api/session/config/workflow.rb +4 -4
  48. data/lib/eco/api/session/config.rb +25 -24
  49. data/lib/eco/api/session.rb +4 -4
  50. data/lib/eco/api/usecases/base_io/validations.rb +4 -3
  51. data/lib/eco/api/usecases/cli/option.rb +5 -2
  52. data/lib/eco/api/usecases/default/people/amend/clear_abilities_case.rb +2 -2
  53. data/lib/eco/api/usecases/default/people/amend/restore_db_case.rb +16 -9
  54. data/lib/eco/api/usecases/default/people/treat/analyse_people_case.rb +20 -20
  55. data/lib/eco/api/usecases/default.rb +5 -5
  56. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +8 -8
  57. data/lib/eco/api/usecases/default_cases/upsert_case.rb +4 -4
  58. data/lib/eco/api/usecases/graphql/helpers/base.rb +1 -1
  59. data/lib/eco/api/usecases/graphql/helpers/location/base/tree_tracking.rb +5 -1
  60. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb +2 -1
  61. data/lib/eco/api/usecases/graphql/helpers/location/command/result.rb +3 -3
  62. data/lib/eco/api/usecases/graphql/helpers/location/command.rb +3 -0
  63. data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +2 -2
  64. data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +9 -3
  65. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb +5 -4
  66. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb +5 -2
  67. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +3 -3
  68. data/lib/eco/api/usecases/graphql/utils/sftp.rb +1 -1
  69. data/lib/eco/api/usecases/lib/{file_pattern.rb → files/file_pattern.rb} +3 -1
  70. data/lib/eco/api/usecases/lib/{sftp.rb → files/sftp.rb} +12 -3
  71. data/lib/eco/api/usecases/lib/files.rb +7 -0
  72. data/lib/eco/api/usecases/lib.rb +1 -2
  73. data/lib/eco/api/usecases/ooze_cases/export_register_case.rb +5 -5
  74. data/lib/eco/api/usecases/ooze_samples/helpers/exportable_ooze.rb +14 -11
  75. data/lib/eco/api/usecases/ooze_samples/helpers_migration/copying.rb +14 -23
  76. data/lib/eco/api/usecases/ooze_samples/helpers_migration/typed_fields_pairing.rb +49 -27
  77. data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +9 -9
  78. data/lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb +1 -1
  79. data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +25 -17
  80. data/lib/eco/api/usecases/ooze_samples/register_migration_case.rb +41 -24
  81. data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +16 -15
  82. data/lib/eco/api/usecases/samples/drivers/cli/sftp_cli.rb +15 -15
  83. data/lib/eco/api/usecases/samples/drivers/cli/url_pull_cli.rb +5 -5
  84. data/lib/eco/api/usecases/samples/drivers/sftp_sample.rb +2 -2
  85. data/lib/eco/api/usecases/use_case.rb +6 -6
  86. data/lib/eco/api/usecases/use_case_chain/chaining.rb +6 -6
  87. data/lib/eco/api/usecases/use_case_chain.rb +4 -4
  88. data/lib/eco/api/usecases/use_case_io.rb +2 -1
  89. data/lib/eco/api/usecases.rb +9 -9
  90. data/lib/eco/cli/config/options_set.rb +4 -4
  91. data/lib/eco/cli/config/use_cases.rb +3 -3
  92. data/lib/eco/cli/scripting/argument.rb +1 -1
  93. data/lib/eco/cli_default/input.rb +9 -9
  94. data/lib/eco/cli_default/options.rb +125 -100
  95. data/lib/eco/cli_default/people.rb +3 -3
  96. data/lib/eco/cli_default/usecases.rb +83 -83
  97. data/lib/eco/cli_default/workflow.rb +7 -7
  98. data/lib/eco/data/files/helpers.rb +3 -3
  99. data/lib/eco/data/fuzzy_match/result.rb +69 -26
  100. data/lib/eco/data/fuzzy_match/results.rb +10 -10
  101. data/lib/eco/data/fuzzy_match/score.rb +13 -8
  102. data/lib/eco/data/fuzzy_match.rb +65 -48
  103. data/lib/eco/data/locations/node_base/treeify.rb +13 -11
  104. data/lib/eco/data/mapper.rb +4 -4
  105. data/lib/eco/language/auxiliar_logger.rb +4 -4
  106. data/lib/eco/language/delegation/const_delegator.rb +64 -0
  107. data/lib/eco/language/delegation/const_lookup_hooks.rb +81 -0
  108. data/lib/eco/language/delegation/delegated_class.rb +84 -0
  109. data/lib/eco/language/delegation.rb +8 -0
  110. data/lib/eco/language/klass/when_inherited.rb +1 -0
  111. data/lib/eco/language/methods/delegate_missing.rb +1 -0
  112. data/lib/eco/language/models/class_helpers.rb +25 -23
  113. data/lib/eco/language/models/collection.rb +12 -2
  114. data/lib/eco/language.rb +1 -0
  115. data/lib/eco/version.rb +1 -1
  116. metadata +12 -6
@@ -108,86 +108,102 @@ module Eco
108
108
  # @note `Eco::API::Common::People::EntryFactory#entries` adds this `idx` (i.e. row number)
109
109
  # @return [Integer] the entry number in the input file
110
110
  def idx
111
- final_entry["idx"]
111
+ final_entry['idx']
112
112
  end
113
113
 
114
114
  # @return [String, nil] the _internal id_ of this person if defined.
115
115
  def id
116
- final_entry["id"]
116
+ final_entry['id']
117
117
  end
118
118
 
119
119
  def id?
120
- final_entry.key?("id")
120
+ final_entry.key?('id')
121
121
  end
122
122
 
123
123
  # @return [String, nil] the _external id_ of this person if defined.
124
124
  def external_id
125
- final_entry["external_id"]
125
+ final_entry['external_id']
126
126
  end
127
127
 
128
128
  def external_id?
129
- final_entry.key?("external_id")
129
+ final_entry.key?('external_id')
130
+ end
131
+
132
+ def archived
133
+ final_entry['archived']
134
+ end
135
+
136
+ def archived_flag?
137
+ final_entry.key?('archived')
130
138
  end
131
139
 
132
140
  # @return [String, nil] the _name_ of this person if defined.
133
141
  def name
134
- final_entry["name"]
142
+ final_entry['name']
135
143
  end
136
144
 
137
145
  def name?
138
- final_entry.key?("name")
146
+ final_entry.key?('name')
139
147
  end
140
148
 
141
149
  # @return [String, nil] the _email_ of this person if defined.
142
150
  def email
143
- final_entry["email"]
151
+ final_entry['email']
144
152
  end
145
153
 
146
154
  def email?
147
- final_entry.key?("email")
155
+ final_entry.key?('email')
148
156
  end
149
157
 
150
158
  # @return [String, nil] the _supervisor id_ of this person if defined.
151
159
  def supervisor_id
152
- final_entry["supervisor_id"]
160
+ final_entry['supervisor_id']
153
161
  end
154
162
 
155
163
  def supervisor_id=(value)
156
- final_entry["supervisor_id"] = value
164
+ final_entry['supervisor_id'] = value
157
165
  end
158
166
 
159
167
  def supervisor_id?
160
- final_entry.key?("supervisor_id")
168
+ final_entry.key?('supervisor_id')
161
169
  end
162
170
 
163
171
  def filter_tags
164
- final_entry["filter_tags"] || []
172
+ final_entry['filter_tags'] || []
165
173
  end
166
174
 
167
175
  def filter_tags?
168
- final_entry.key?("filter_tags")
176
+ final_entry.key?('filter_tags')
177
+ end
178
+
179
+ def contractor_organization_id
180
+ final_entry['contractor_organization_id']
181
+ end
182
+
183
+ def contractor_organization_id?
184
+ final_entry.key?('contractor_organization_id')
169
185
  end
170
186
 
171
187
  def policy_group_ids
172
- final_entry["policy_group_ids"] || []
188
+ final_entry['policy_group_ids'] || []
173
189
  end
174
190
 
175
191
  def policy_group_ids?
176
- final_entry.key?("policy_group_ids")
192
+ final_entry.key?('policy_group_ids')
177
193
  end
178
194
 
179
195
  def default_tag?
180
- final_entry.key?("default_tag")
196
+ final_entry.key?('default_tag')
181
197
  end
182
198
 
183
199
  def default_tag
184
- final_entry["default_tag"]
200
+ final_entry['default_tag']
185
201
  end
186
202
 
187
203
  # Provides a reference to this person entry.
188
204
  # @return [String] string summary of this person identity.
189
205
  def identify
190
- str_id = id ? "id: '#{id}'; " : ""
206
+ str_id = id ? "id: '#{id}'; " : ''
191
207
  "(row: #{idx}) '#{name}' (#{str_id}ext_id: '#{external_id}'; email: '#{email}')"
192
208
  end
193
209
 
@@ -200,7 +216,7 @@ module Eco
200
216
  else
201
217
  final_entry.each.map do |k, v|
202
218
  "'#{k}': '#{v.to_json}'"
203
- end.join(" | ")
219
+ end.join(' | ')
204
220
  end
205
221
  end
206
222
 
@@ -217,7 +233,7 @@ module Eco
217
233
  @final_entry.slice(*scoped_attrs).each do |attr, value|
218
234
  set_part(person, attr, value)
219
235
  rescue StandardError => e
220
- raise unless attr == "email"
236
+ raise unless attr == 'email'
221
237
 
222
238
  log(:error) { "#{e} - setting blank email instead." }
223
239
  set_part(person, attr, nil)
@@ -284,7 +300,7 @@ module Eco
284
300
  def _external_serializing(mapped_entry)
285
301
  target_attrs = @emap.all_model_attrs | @emap.aliased_attrs
286
302
  rest_keys = mapped_entry.keys - target_attrs
287
- target_attrs -= ["send_invites"]
303
+ target_attrs -= ['send_invites']
288
304
  external_entry = target_attrs.each_with_object({}) do |attr, hash|
289
305
  unless hash.key?(ext_attr = @emap.to_external(attr))
290
306
  hash[ext_attr] = mapped_entry[attr]
@@ -312,7 +328,7 @@ module Eco
312
328
  # @return [Hash] entry with **internal** names and **external** values and types.
313
329
  def _mapped_serializing(internal_entry)
314
330
  mapped_hash = internal_entry.merge(_serialize_values(internal_entry, :internal))
315
- model_attrs = @person_parser.all_model_attrs - ["send_invites"]
331
+ model_attrs = @person_parser.all_model_attrs - ['send_invites']
316
332
  aux_hash = mapped_hash.slice(*model_attrs)
317
333
  merge_missing_attrs(aux_hash, mapped_hash)
318
334
  end
@@ -383,7 +399,7 @@ module Eco
383
399
  hash.merge(hash_attr(attr, get_part(person.details, attr)))
384
400
  end
385
401
  merging(core_hash, account_hash, details_hash) do |final_entry|
386
- final_entry["Has account?"] = !person.account.nil?
402
+ final_entry['Has account?'] = !person.account.nil?
387
403
  final_entry.merge(_serialize_values(person, :person))
388
404
  end
389
405
  end
@@ -412,14 +428,14 @@ module Eco
412
428
  end
413
429
  value = @person_parser.serialize(:multiple, value) if field.multiple
414
430
  if @person_parser.defined?(field.type.to_sym)
415
- value = @person_parser.serialize(field.type.to_sym, value, deps: {"attr" => attr})
431
+ value = @person_parser.serialize(field.type.to_sym, value, deps: {'attr' => attr})
416
432
  end
417
433
  value
418
434
  elsif %w[policy_group_ids filter_tags login_provider_ids starred_ids].include?(attr)
419
435
  @person_parser.serialize(:multiple, value)
420
- elsif %w[freemium accept_eula].include?(attr)
436
+ elsif %w[freemium accept_eula archived].include?(attr)
421
437
  @person_parser.serialize(:boolean, value)
422
- elsif ["subordinates"].include?(attr)
438
+ elsif ['subordinates'].include?(attr)
423
439
  @person_parser.serialize(:number, value)
424
440
  else
425
441
  value
@@ -437,19 +453,19 @@ module Eco
437
453
  value = @person_parser.parse(:multiple, value) if field.multiple
438
454
 
439
455
  if @person_parser.defined?(field.type.to_sym)
440
- value = @person_parser.parse(field.type.to_sym, value, deps: {"attr" => attr})
456
+ value = @person_parser.parse(field.type.to_sym, value, deps: {'attr' => attr})
441
457
  end
442
458
  value
443
- elsif attr == "email"
459
+ elsif attr == 'email'
444
460
  value = value.strip.downcase if value
445
461
  value
446
462
  elsif %w[policy_group_ids filter_tags login_provider_ids starred_ids].include?(attr)
447
463
  value = @person_parser.parse(:multiple, value)
448
- value = value.compact.map(&:upcase) if attr == "filter_tags"
464
+ value = value.compact.map(&:upcase) if attr == 'filter_tags'
449
465
  value
450
- elsif %w[freemium accept_eula].include?(attr)
466
+ elsif %w[freemium accept_eula archived].include?(attr)
451
467
  @person_parser.parse(:boolean, value)
452
- elsif ["subordinates"].include?(attr)
468
+ elsif ['subordinates'].include?(attr)
453
469
  @person_parser.parse(:number, value)
454
470
  else
455
471
  value
@@ -527,13 +543,13 @@ module Eco
527
543
  print_it = proc do |name, model|
528
544
  puts "#{name}:"
529
545
  pp model
530
- puts "*" * 30
546
+ puts '*' * 30
531
547
  end
532
548
 
533
- fin = proc { print_it.call("final_entry", @final_entry) }
534
- int = proc { print_it.call("internal_entry", @internal_entry) }
535
- mad = proc { print_it.call("mapped_entry", @mapped_entry) }
536
- ext = proc { print_it.call("external_entry", @external_entry) }
549
+ fin = proc { print_it.call('final_entry', @final_entry) }
550
+ int = proc { print_it.call('internal_entry', @internal_entry) }
551
+ mad = proc { print_it.call('mapped_entry', @mapped_entry) }
552
+ ext = proc { print_it.call('external_entry', @external_entry) }
537
553
 
538
554
  call_order = parsing? ? [ext, mad, int, fin] : [fin, int, mad, ext]
539
555
  call_order.each(&:call)
@@ -12,14 +12,16 @@ module Eco
12
12
  # name attributes, including _core_, _account_ and _details_.
13
13
  class PersonParser
14
14
  extend Eco::API::Common::ClassAutoLoader
15
- autoloads_children_of "Eco::API::Common::Loaders::Parser"
16
- autoload_namespace_ignore "Eco::API"
15
+ autoloads_children_of 'Eco::API::Common::Loaders::Parser'
16
+ autoload_namespace_ignore 'Eco::API'
17
17
 
18
18
  CORE_ATTRS = %w[
19
19
  id external_id email name
20
20
  supervisor_id filter_tags
21
- contractor_organization_id freemium
21
+ archived
22
+ contractor_organization_id
22
23
  brand_id
24
+ freemium
23
25
  ].freeze
24
26
  ACCOUNT_ATTRS = %w[
25
27
  policy_group_ids default_tag
@@ -39,7 +41,7 @@ module Eco
39
41
 
40
42
  # @example Example of usage:
41
43
  # person_parser = PersonParser.new(schema: schema)
42
- # person_parser.define_attribute("example") do |parser|
44
+ # person_parser.define_attribute('example') do |parser|
43
45
  # parser.def_parser do |str, deps|
44
46
  # i = value.to_i rescue 0
45
47
  # i +=5 if deps.dig(:sum_5)
@@ -82,7 +84,7 @@ module Eco
82
84
  return nil unless @schema
83
85
 
84
86
  @select_tables ||= @schema.fields.select do |fld|
85
- fld.type == "select"
87
+ fld.type == 'select'
86
88
  end.to_h do |fld|
87
89
  msg = "The schema selection field '#{fld.name}' is missing selection options."
88
90
  raise msg unless fld.options&.any?
@@ -239,7 +241,7 @@ module Eco
239
241
  def define_attribute(attr, dependencies: {}, &definition)
240
242
  unless valid?(attr)
241
243
  msg = "The attribute '#{attr_to_str(attr)}' is not part of "
242
- msg << "core, account or target schema, or does "
244
+ msg << 'core, account or target schema, or does '
243
245
  msg << "not match any type: #{@details_attrs}"
244
246
  raise msg
245
247
  end
@@ -15,7 +15,7 @@ module Eco
15
15
 
16
16
  module ClassMethods
17
17
  def channels!(&def_block)
18
- str = "Block with channel implementation expected. None given."
18
+ str = 'Block with channel implementation expected. None given.'
19
19
  raise ArgumentError, str unless block_given?
20
20
 
21
21
  channels.each do |channel|
@@ -73,5 +73,5 @@ module Eco
73
73
  end
74
74
  end
75
75
 
76
- require_relative "logger/cache"
77
- require_relative "logger/log"
76
+ require_relative 'logger/cache'
77
+ require_relative 'logger/log'
@@ -11,14 +11,14 @@ module Eco
11
11
  source: fetch_from,
12
12
  message: {
13
13
  subject: {
14
- charset: "UTF-8",
14
+ charset: 'UTF-8',
15
15
  data: subject
16
16
  },
17
17
  body: {
18
18
  # NOTE: (html) will let you send html instead
19
19
  # you can use both at once if you like
20
20
  text: {
21
- charset: "UTF-8",
21
+ charset: 'UTF-8',
22
22
  data: body
23
23
  }
24
24
  }
@@ -59,6 +59,7 @@ module Eco
59
59
  }.tap do |dest|
60
60
  cc = [cc].flatten.compact.uniq
61
61
  bcc = [bcc].flatten.compact.uniq
62
+
62
63
  dest.merge!(cc_addresses: cc) unless cc.empty?
63
64
  dest.merge!(bcc_addresses: bcc) unless bcc.empty?
64
65
  end
@@ -9,6 +9,7 @@ module Eco
9
9
  def to_desc(to: nil, cc: nil, bcc: nil)
10
10
  cc_to = [cc].flatten.compact.uniq
11
11
  bcc_to = [bcc].flatten.compact.uniq
12
+
12
13
  { to_addresses: [to].flatten.compact.uniq }.tap do |dest|
13
14
  dest.merge!(cc_addresses: cc_to) unless cc_to.empty?
14
15
  dest.merge!(bcc_addresses: bcc_to) unless bcc_to.empty?
@@ -26,7 +27,7 @@ module Eco
26
27
  end
27
28
 
28
29
  def send_mail(subject:, body:, to: nil, cc: nil, bcc: nil) # rubocop:disable Lint/UnusedMethodArgument
29
- raise "You must implement this method"
30
+ raise 'You must implement this method'
30
31
  end
31
32
 
32
33
  def fetch_to(value = nil)
@@ -16,7 +16,7 @@ module Eco
16
16
  bcc: bcc
17
17
  )
18
18
 
19
- mailer._("send").post(request_body: data)
19
+ mailer._('send').post(request_body: data)
20
20
  end
21
21
 
22
22
  def fetch_to(value = nil)
@@ -40,20 +40,20 @@ module Eco
40
40
 
41
41
  def to_data(subject:, body:, to: nil, cc: nil, bcc: nil)
42
42
  {
43
- "personalizations" => [
43
+ 'personalizations' => [
44
44
  {
45
- "to" => fetch_to(to).flatten,
46
- "subject" => subject
45
+ 'to' => fetch_to(to).flatten,
46
+ 'subject' => subject
47
47
  }.tap do |pers|
48
48
  merge_if('cc', cc, target: pers)
49
49
  merge_if('bcc', bcc, target: pers)
50
50
  end
51
51
  ],
52
- "from" => fetch_from,
53
- "content" => [
52
+ 'from' => fetch_from,
53
+ 'content' => [
54
54
  {
55
- "type" => "text/plain",
56
- "value" => body
55
+ 'type' => 'text/plain',
56
+ 'value' => body
57
57
  }
58
58
  ]
59
59
  }
@@ -87,7 +87,7 @@ module Eco
87
87
  return if value.to_s.strip.empty?
88
88
 
89
89
  {
90
- "email" => value
90
+ 'email' => value
91
91
  }
92
92
  end
93
93
  end
@@ -31,7 +31,7 @@ module Eco
31
31
  return false unless (serv = service)
32
32
 
33
33
  unless serv.configured?
34
- msg = "Mailer: You are missing configuration parameters "
34
+ msg = 'Mailer: You are missing configuration parameters '
35
35
  msg << "for '#{provider}'. Review your .env file"
36
36
  log(:error) { msg }
37
37
  return false
@@ -48,10 +48,11 @@ module Eco
48
48
 
49
49
  to_addr = serv.fetch_to(to)
50
50
  msg = "Sent email #{ProviderBase.to_desc(
51
- to: to_addr,
52
- cc: cc,
51
+ to: to_addr,
52
+ cc: cc,
53
53
  bcc: bcc
54
54
  )}"
55
+
55
56
  puts msg
56
57
  log(:debug) { msg }
57
58
  end
@@ -69,6 +70,7 @@ module Eco
69
70
  msg = "Unknown mail provider '#{provider}'"
70
71
  puts msg
71
72
  log(:debug) { msg }
73
+
72
74
  nil
73
75
  end
74
76
  end
@@ -102,12 +102,12 @@ module Eco
102
102
  # @param local_folder [String] local destination folder (`"."` if not specified)
103
103
  # @return [Array<String>] list of created files
104
104
  def download(files, local_folder: nil, &block)
105
- puts "Creating local files:"
105
+ puts 'Creating local files:'
106
106
  created_files = []
107
107
 
108
108
  [files].flatten.compact.map do |fullname|
109
109
  basename = windows_basename(fullname)
110
- dest_fullname = File.join(local_folder || ".", basename)
110
+ dest_fullname = File.join(local_folder || '.', basename)
111
111
  puts " * #{dest_fullname}"
112
112
  created_files << dest_fullname
113
113
  sftp_session.download(fullname, dest_fullname)
@@ -2,8 +2,9 @@ Object.class_eval do
2
2
  unless method_defined?(:yield_self)
3
3
  define_method(:yield_self) do |&block|
4
4
  return block.call(self) if block
5
+
5
6
  out = self
6
- out = [self] unless self.is_a?(Enumerable)
7
+ out = [self] unless is_a?(Enumerable)
7
8
  out.each
8
9
  end
9
10
  end
@@ -1,7 +1,7 @@
1
1
  # Helper class to create a custom `Config`
2
2
  # @example Example of usage:
3
3
  # class Custom::Workflow::Mailer < Eco::API::Custom::Mailer
4
- # ORG = "Org Name"
4
+ # ORG = 'Org Name'
5
5
  # end
6
6
  class Eco::API::Custom::Mailer < Eco::API::Common::Loaders::Workflow::Mailer
7
7
  extend Eco::Language::Klass::WhenInherited
@@ -2,8 +2,8 @@ module Eco
2
2
  module API
3
3
  class Error
4
4
  class Handlers < Eco::API::UseCases
5
- autoloads_children_of "Eco::API::Common::Loaders::ErrorHandler"
6
- autoload_namespace_ignore "Eco::API"
5
+ autoloads_children_of 'Eco::API::Common::Loaders::ErrorHandler'
6
+ autoload_namespace_ignore 'Eco::API'
7
7
 
8
8
  def define(*_args)
9
9
  raise "Missusage. You should use 'on' method instead"
@@ -12,7 +12,7 @@ module Eco
12
12
  # @param klass_err [Eco::API::Error] the specific error class that triggers this handler.
13
13
  def on(klass_err, type: :error_handler, retry: true, &block)
14
14
  Eco::API::Error.validate_err_class(klass_err)
15
- raise "Expected block but not given" unless block
15
+ raise 'Expected block but not given' unless block
16
16
 
17
17
  Eco::API::Error::Handler.new(
18
18
  klass_err,
data/lib/eco/api/error.rb CHANGED
@@ -9,82 +9,82 @@ module Eco
9
9
  end
10
10
  end
11
11
 
12
- @str_err = "api error on the server reply"
12
+ @str_err = 'api error on the server reply'
13
13
  @match = /.*/
14
14
  #RxValidId = /[a-f0-9]{24}/
15
15
 
16
16
  class Unclassified < Eco::API::Error
17
- @str_error = "Unclassified error message"
17
+ @str_error = 'Unclassified error message'
18
18
  @match = /.*/
19
19
  end
20
20
 
21
21
  class InternalServerError < Eco::API::Error
22
- @str_err = "Internal Server Error"
22
+ @str_err = 'Internal Server Error'
23
23
  @match = /#{@str_err}/
24
24
  end
25
25
 
26
26
  class UnknownPersonId < Eco::API::Error
27
- @str_err = "Unknown person id"
27
+ @str_err = 'Unknown person id'
28
28
  @match = /Cannot find person with id (.*)/
29
29
  end
30
30
 
31
31
  class ExternalIdTaken < Eco::API::Error
32
- @str_err = "external ID already taken"
32
+ @str_err = 'external ID already taken'
33
33
  @match = /#{@str_err}/
34
34
  end
35
35
 
36
36
  class EmailMissing < Eco::API::Error
37
- @str_err = "missing email for account creation"
37
+ @str_err = 'missing email for account creation'
38
38
  @match = /#{@str_err}/
39
39
  end
40
40
 
41
41
  class EmailInvalid < Eco::API::Error
42
- @str_err = "Email is invalid"
42
+ @str_err = 'Email is invalid'
43
43
  @match = /#{@str_err}/
44
44
  end
45
45
 
46
46
  class EmailTaken < Eco::API::Error
47
- @str_err = "user email already taken"
48
- @str_err_2 = "Email is already taken"
47
+ @str_err = 'user email already taken'
48
+ @str_err_2 = 'Email is already taken'
49
49
  @match = /(?:#{@str_err}|#{@str_err_2})/
50
50
  end
51
51
 
52
52
  class SupervisorNotFound < Eco::API::Error
53
- @str_err = "Supervisor not found"
53
+ @str_err = 'Supervisor not found'
54
54
  @match = /Supervisor (.*?) not found/
55
55
  end
56
56
 
57
57
  class CyclicSupervisor < Eco::API::Error
58
- @str_err = "Supervisor is cyclic!"
58
+ @str_err = 'Supervisor is cyclic!'
59
59
  @match = /#{@str_err}/
60
60
  end
61
61
 
62
62
  class SchemaNotFound < Eco::API::Error
63
- @str_err = "Schema not found"
63
+ @str_err = 'Schema not found'
64
64
  @match = /Schema (.*?) not found/
65
65
  end
66
66
 
67
67
  class InvalidObjectId < Eco::API::Error
68
- @str_err = "Invalid ObjectId."
68
+ @str_err = 'Invalid ObjectId.'
69
69
  @match = /'(.*?)' is an invalid ObjectId./
70
70
  end
71
71
 
72
72
  class UnknownField < Eco::API::Error
73
- @str_err = "Unknown field."
73
+ @str_err = 'Unknown field.'
74
74
  @match = /(.+?) is an unknown field/
75
75
 
76
76
  class UnknownCoreField < UnknownField
77
- @str_err = "Unknown core field."
77
+ @str_err = 'Unknown core field.'
78
78
  @match = /(.+?) is an unknown field/
79
79
  end
80
80
 
81
81
  class UnknownAccountField < UnknownField
82
- @str_err = "Unknown account field."
82
+ @str_err = 'Unknown account field.'
83
83
  @match = /account > (.+?) is an unknown field/
84
84
  end
85
85
 
86
86
  class UnknownDetailsField < UnknownField
87
- @str_err = "Unknown details field."
87
+ @str_err = 'Unknown details field.'
88
88
  @match = /details > (.+?) is an unknown field/
89
89
  end
90
90
  end
@@ -12,17 +12,9 @@ module Eco
12
12
  [].tap do |account_excluded|
13
13
  next if person.new?
14
14
 
15
- if options.dig(:exclude, :policy_groups)
16
- account_excluded.push('policy_group_ids')
17
- end
18
-
19
- if options.dig(:exclude, :default_tag)
20
- account_excluded.push('default_tag')
21
- end
22
-
23
- if options.dig(:exclude, :login_providers)
24
- account_excluded.push('login_provider_ids')
25
- end
15
+ account_excluded.push('policy_group_ids') if options.dig(:exclude, :policy_groups)
16
+ account_excluded.push('default_tag') if options.dig(:exclude, :default_tag)
17
+ account_excluded.push('login_provider_ids') if options.dig(:exclude, :login_providers)
26
18
  end
27
19
  end
28
20
  end
@@ -5,13 +5,16 @@ module Eco
5
5
  module ApplyChanges
6
6
  module SetCore
7
7
  module CoreExcluded
8
+ CAN_EXCLUDE_CREATION = %w[filter_tags archived contractor_organization_id].freeze
9
+ CAN_EXCLUDE_UPDATE = %w[name external_id email filter_tags contractor_organization_id].freeze
10
+
8
11
  # @note by default `supervisor_id` is always excluded.
9
12
  # @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
10
13
  # @param options [Hash] the options.
11
14
  # @return [Array<String>] the core parameters that should not be included.
12
15
  def core_excluded(person, options)
13
16
  ['supervisor_id'].tap do |core_excluded|
14
- can_exclude = person.new?? ['filter_tags'] : %w[name external_id email filter_tags]
17
+ can_exclude = person.new?? CAN_EXCLUDE_CREATION : CAN_EXCLUDE_UPDATE
15
18
 
16
19
  exclusions = can_exclude.select do |attr|
17
20
  options.dig(:exclude, attr.to_sym)
@@ -93,7 +93,9 @@ module Eco
93
93
  next if !sup_id || request.include?(spr)
94
94
 
95
95
  micro.with_supervisor(sup_id, people) do |supervisor|
96
- request.push(spr) unless supervisor
96
+ next if supervisor
97
+
98
+ request.push(spr)
97
99
  end
98
100
  end
99
101
  end
@@ -14,6 +14,7 @@ module Eco
14
14
 
15
15
  def initialize(people = [], klass: Ecoportal::API::Internal::Person)
16
16
  @klass = Ecoportal::API::Internal::Person unless klass == Ecoportal::API::V1::Person
17
+
17
18
  super(people, klass: @klass)
18
19
  @caches_init = false
19
20
  end
@@ -3,8 +3,8 @@ module Eco
3
3
  # @todo the autoloading happens on `add`, and there could be multiple pending children to load.
4
4
  # This could translate into the policies not being loaded in order
5
5
  class Policies < Eco::API::UseCases
6
- autoloads_children_of "Eco::API::Common::Loaders::Policy"
7
- autoload_namespace_ignore "Eco::API"
6
+ autoloads_children_of 'Eco::API::Common::Loaders::Policy'
7
+ autoload_namespace_ignore 'Eco::API'
8
8
 
9
9
  attr_reader :policies
10
10