eco-helpers 3.0.26 → 3.0.28

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 (146) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +76 -5
  3. data/eco-helpers.gemspec +2 -1
  4. data/lib/eco/api/common/class_helpers.rb +1 -136
  5. data/lib/eco/api/common/loaders/base.rb +1 -1
  6. data/lib/eco/api/common/loaders/case_base.rb +1 -1
  7. data/lib/eco/api/common/loaders/config/cli.rb +1 -1
  8. data/lib/eco/api/common/loaders/config/session.rb +1 -1
  9. data/lib/eco/api/common/loaders/config/workflow.rb +1 -1
  10. data/lib/eco/api/common/loaders/config.rb +2 -5
  11. data/lib/eco/api/common/loaders/error_handler.rb +1 -1
  12. data/lib/eco/api/common/loaders/parser.rb +2 -2
  13. data/lib/eco/api/common/loaders/policy.rb +1 -1
  14. data/lib/eco/api/common/loaders/use_case/target_model.rb +1 -1
  15. data/lib/eco/api/common/loaders/use_case/type.rb +1 -1
  16. data/lib/eco/api/common/loaders/use_case.rb +1 -1
  17. data/lib/eco/api/common/people/default_parsers/archived_parser.rb +19 -0
  18. data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +4 -4
  19. data/lib/eco/api/common/people/default_parsers/date_parser.rb +3 -3
  20. data/lib/eco/api/common/people/default_parsers/freemium_parser.rb +6 -6
  21. data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +3 -3
  22. data/lib/eco/api/common/people/default_parsers/multi_parser.rb +4 -4
  23. data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +9 -6
  24. data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +6 -5
  25. data/lib/eco/api/common/people/default_parsers/xls_parser.rb +2 -2
  26. data/lib/eco/api/common/people/default_parsers.rb +1 -0
  27. data/lib/eco/api/common/people/entries.rb +16 -15
  28. data/lib/eco/api/common/people/person_entry.rb +53 -37
  29. data/lib/eco/api/common/people/person_parser.rb +8 -6
  30. data/lib/eco/api/common/people/supervisor_helpers.rb +3 -1
  31. data/lib/eco/api/common/session/logger/channels.rb +2 -1
  32. data/lib/eco/api/common/session/logger.rb +2 -2
  33. data/lib/eco/api/common/session/mailer/aws_provider.rb +3 -2
  34. data/lib/eco/api/common/session/mailer/provider_base.rb +2 -1
  35. data/lib/eco/api/common/session/mailer/sendgrid_provider.rb +9 -9
  36. data/lib/eco/api/common/session/mailer.rb +5 -3
  37. data/lib/eco/api/common/session/sftp.rb +11 -4
  38. data/lib/eco/api/common/version_patches/object.rb +2 -1
  39. data/lib/eco/api/custom/mailer.rb +1 -1
  40. data/lib/eco/api/error/handlers.rb +3 -3
  41. data/lib/eco/api/error.rb +17 -17
  42. data/lib/eco/api/microcases/people/apply_changes/set_account/account_excluded.rb +3 -11
  43. data/lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb +4 -1
  44. data/lib/eco/api/microcases/people/manage/search.rb +3 -1
  45. data/lib/eco/api/organization/people.rb +1 -0
  46. data/lib/eco/api/policies.rb +2 -2
  47. data/lib/eco/api/session/batch/job/sets.rb +1 -0
  48. data/lib/eco/api/session/batch/job/type.rb +1 -0
  49. data/lib/eco/api/session/batch/job.rb +2 -2
  50. data/lib/eco/api/session/batch/launcher/valid_methods.rb +3 -2
  51. data/lib/eco/api/session/batch/launcher.rb +4 -5
  52. data/lib/eco/api/session/batch/searcher.rb +4 -4
  53. data/lib/eco/api/session/config/api.rb +2 -2
  54. data/lib/eco/api/session/config/apis/enviro_spaces.rb +2 -2
  55. data/lib/eco/api/session/config/post_launch.rb +7 -4
  56. data/lib/eco/api/session/config/sftp.rb +1 -1
  57. data/lib/eco/api/session/config/tagtree.rb +1 -1
  58. data/lib/eco/api/session/config/workflow.rb +4 -4
  59. data/lib/eco/api/session/config.rb +25 -24
  60. data/lib/eco/api/session.rb +4 -4
  61. data/lib/eco/api/usecases/base_case/model.rb +2 -1
  62. data/lib/eco/api/usecases/base_case/type.rb +2 -1
  63. data/lib/eco/api/usecases/base_io/validations.rb +6 -4
  64. data/lib/eco/api/usecases/cli/option.rb +5 -2
  65. data/lib/eco/api/usecases/default/people/amend/clear_abilities_case.rb +2 -2
  66. data/lib/eco/api/usecases/default/people/amend/restore_db_case.rb +16 -9
  67. data/lib/eco/api/usecases/default/people/treat/analyse_people_case.rb +20 -20
  68. data/lib/eco/api/usecases/default.rb +5 -5
  69. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +8 -8
  70. data/lib/eco/api/usecases/default_cases/upsert_case.rb +4 -4
  71. data/lib/eco/api/usecases/graphql/helpers/base.rb +1 -1
  72. data/lib/eco/api/usecases/graphql/helpers/location/base/tree_tracking.rb +5 -1
  73. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb +5 -3
  74. data/lib/eco/api/usecases/graphql/helpers/location/command/result.rb +3 -3
  75. data/lib/eco/api/usecases/graphql/helpers/location/command.rb +3 -0
  76. data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +2 -2
  77. data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +9 -3
  78. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb +5 -4
  79. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb +5 -2
  80. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +3 -3
  81. data/lib/eco/api/usecases/graphql/utils/sftp.rb +1 -1
  82. data/lib/eco/api/usecases/lib/{file_pattern.rb → files/file_pattern.rb} +1 -1
  83. data/lib/eco/api/usecases/lib/{sftp.rb → files/sftp.rb} +19 -7
  84. data/lib/eco/api/usecases/lib/files.rb +7 -0
  85. data/lib/eco/api/usecases/lib.rb +1 -2
  86. data/lib/eco/api/usecases/ooze_cases/export_register_case.rb +5 -5
  87. data/lib/eco/api/usecases/ooze_samples/helpers/exportable_ooze.rb +14 -11
  88. data/lib/eco/api/usecases/ooze_samples/helpers_migration/copying.rb +14 -23
  89. data/lib/eco/api/usecases/ooze_samples/helpers_migration/typed_fields_pairing.rb +49 -27
  90. data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +9 -9
  91. data/lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb +1 -1
  92. data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +25 -17
  93. data/lib/eco/api/usecases/ooze_samples/register_migration_case.rb +41 -24
  94. data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +16 -15
  95. data/lib/eco/api/usecases/samples/drivers/cli/sftp_cli.rb +15 -15
  96. data/lib/eco/api/usecases/samples/drivers/cli/url_pull_cli.rb +5 -5
  97. data/lib/eco/api/usecases/samples/drivers/sftp_sample.rb +5 -3
  98. data/lib/eco/api/usecases/use_case.rb +6 -6
  99. data/lib/eco/api/usecases/use_case_chain/chaining.rb +6 -6
  100. data/lib/eco/api/usecases/use_case_chain.rb +4 -4
  101. data/lib/eco/api/usecases/use_case_io.rb +2 -1
  102. data/lib/eco/api/usecases.rb +9 -9
  103. data/lib/eco/cli/config/options_set.rb +4 -4
  104. data/lib/eco/cli/config/use_cases.rb +3 -3
  105. data/lib/eco/cli/scripting/argument.rb +1 -1
  106. data/lib/eco/cli_default/input.rb +9 -9
  107. data/lib/eco/cli_default/options.rb +125 -100
  108. data/lib/eco/cli_default/people.rb +3 -3
  109. data/lib/eco/cli_default/usecases.rb +83 -83
  110. data/lib/eco/cli_default/workflow.rb +7 -7
  111. data/lib/eco/data/files/helpers.rb +7 -5
  112. data/lib/eco/data/fuzzy_match/result.rb +69 -26
  113. data/lib/eco/data/fuzzy_match/results.rb +10 -10
  114. data/lib/eco/data/fuzzy_match/score.rb +13 -8
  115. data/lib/eco/data/fuzzy_match.rb +69 -50
  116. data/lib/eco/data/hashes/diff_result/meta.rb +2 -1
  117. data/lib/eco/data/locations/node_base/treeify.rb +13 -11
  118. data/lib/eco/data/locations/node_diff/accessors.rb +2 -1
  119. data/lib/eco/data/mapper.rb +4 -4
  120. data/lib/eco/language/auxiliar_logger.rb +4 -4
  121. data/lib/eco/language/delegation/chainable_delegator.rb +18 -0
  122. data/lib/eco/language/delegation/delegating_missing.rb +104 -0
  123. data/lib/eco/language/delegation/delegating_missing_const.rb +53 -0
  124. data/lib/eco/language/delegation/delegating_missing_on_class.rb +53 -0
  125. data/lib/eco/language/delegation/for_delegator/const_delegator.rb +66 -0
  126. data/lib/eco/language/delegation/for_delegator/const_lookup_hooks.rb +99 -0
  127. data/lib/eco/language/delegation/for_delegator/delegated_class.rb +71 -0
  128. data/lib/eco/language/delegation/for_delegator.rb +11 -0
  129. data/lib/eco/language/delegation.rb +10 -0
  130. data/lib/eco/language/klass/builder.rb +29 -0
  131. data/lib/eco/language/klass/helpers_built.rb +9 -0
  132. data/lib/eco/language/klass/hierarchy.rb +34 -0
  133. data/lib/eco/language/klass/inheritable_class_vars.rb +45 -0
  134. data/lib/eco/language/klass/naming.rb +21 -0
  135. data/lib/eco/language/klass/resolver.rb +30 -0
  136. data/lib/eco/language/klass/when_inherited.rb +11 -13
  137. data/lib/eco/language/klass.rb +6 -0
  138. data/lib/eco/language/methods.rb +0 -1
  139. data/lib/eco/language/models/class_helpers.rb +25 -23
  140. data/lib/eco/language/models/collection.rb +12 -2
  141. data/lib/eco/language/strings/underscore.rb +17 -0
  142. data/lib/eco/language/strings.rb +8 -0
  143. data/lib/eco/language.rb +2 -0
  144. data/lib/eco/version.rb +1 -1
  145. metadata +39 -7
  146. data/lib/eco/language/methods/delegate_missing.rb +0 -29
@@ -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: "email")
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(data, klass: klass, factory: factory)
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("filter_tags", tags, default_modifier.any.insensitive)
76
+ attr('filter_tags', tags, default_modifier.any.insensitive)
76
77
  end
77
78
 
78
79
  def filter_tags_all(tags)
79
- attr("filter_tags", tags, default_modifier.all.insensitive)
80
+ attr('filter_tags', tags, default_modifier.all.insensitive)
80
81
  end
81
82
 
82
83
  def policy_group_ids_any(ids)
83
- attr("policy_group_ids", ids, default_modifier.any.insensitive)
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("policy_group_ids", ids, default_modifier.all.insensitive)
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, "id")
129
- external_id = attr_value(object, "external_id")
130
- email = attr_value(object, "email")
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, "w") do |csv|
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 = "id")
181
- super(attr || "id")
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 = "Multiple search results match the criteria."
201
- raise MultipleSearchResults.new(msg, candidates: candidates, property: "email")
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
@@ -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
@@ -8,7 +8,9 @@ module Eco
8
8
  # * `id`
9
9
  module SupervisorHelpers
10
10
  def self.included(base)
11
- base.send(:include, ClassMethods)
11
+ super
12
+
13
+ base.send :include, ClassMethods
12
14
  end
13
15
 
14
16
  module ClassMethods
@@ -9,13 +9,14 @@ module Eco
9
9
  class << self
10
10
  def included(base)
11
11
  super
12
+
12
13
  base.extend ClassMethods
13
14
  end
14
15
  end
15
16
 
16
17
  module ClassMethods
17
18
  def channels!(&def_block)
18
- str = "Block with channel implementation expected. None given."
19
+ str = 'Block with channel implementation expected. None given.'
19
20
  raise ArgumentError, str unless block_given?
20
21
 
21
22
  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)
@@ -118,6 +118,7 @@ module Eco
118
118
  end
119
119
 
120
120
  # Upload a file to the specific `remote_folder`
121
+ # @return [String, FalseClass] on success returns the remote file path.
121
122
  def upload(local_file, remote_folder:, gid: nil)
122
123
  return false unless local_file && File.exist?(local_file)
123
124
 
@@ -133,9 +134,15 @@ module Eco
133
134
  end
134
135
 
135
136
  log(:info) {
136
- "Uploaded '#{local_file}' (#{res})"
137
+ "Uploaded '#{local_file}' as '#{dest_file}' (#{res})"
137
138
  }
138
- true
139
+
140
+ dest_file
141
+ rescue StandardError
142
+ log(:error) {
143
+ "Could not upload file '#{dest_file}' (#{res})"
144
+ }
145
+ raise
139
146
  end
140
147
 
141
148
  private
@@ -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,