eco-helpers 1.5.1 → 1.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +114 -2
  3. data/LICENSE +21 -0
  4. data/eco-helpers.gemspec +1 -1
  5. data/lib/eco/api.rb +2 -0
  6. data/lib/eco/api/common.rb +4 -0
  7. data/lib/eco/api/common/base_loader.rb +54 -0
  8. data/lib/eco/api/common/class_auto_loader.rb +109 -0
  9. data/lib/eco/api/common/class_helpers.rb +33 -0
  10. data/lib/eco/api/common/class_hierarchy.rb +1 -1
  11. data/lib/eco/api/common/class_meta_basics.rb +16 -0
  12. data/lib/eco/api/common/loaders.rb +13 -0
  13. data/lib/eco/api/common/loaders/error_handler.rb +41 -0
  14. data/lib/eco/api/common/loaders/parser.rb +127 -0
  15. data/lib/eco/api/common/loaders/policy.rb +25 -0
  16. data/lib/eco/api/common/loaders/use_case.rb +40 -0
  17. data/lib/eco/api/common/people/default_parsers.rb +3 -12
  18. data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +13 -23
  19. data/lib/eco/api/common/people/default_parsers/csv_parser.rb +20 -35
  20. data/lib/eco/api/common/people/default_parsers/date_parser.rb +15 -26
  21. data/lib/eco/api/common/people/default_parsers/freemium_parser.rb +15 -25
  22. data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +26 -0
  23. data/lib/eco/api/common/people/default_parsers/multi_parser.rb +15 -27
  24. data/lib/eco/api/common/people/default_parsers/numeric_parser.rb +14 -19
  25. data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +24 -35
  26. data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +15 -25
  27. data/lib/eco/api/common/people/entries.rb +54 -24
  28. data/lib/eco/api/common/people/entry_factory.rb +10 -8
  29. data/lib/eco/api/common/people/person_attribute_parser.rb +29 -12
  30. data/lib/eco/api/common/people/person_entry.rb +308 -216
  31. data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +3 -2
  32. data/lib/eco/api/common/people/person_parser.rb +51 -18
  33. data/lib/eco/api/common/session/logger.rb +4 -0
  34. data/lib/eco/api/common/version_patches.rb +1 -0
  35. data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +2 -0
  36. data/lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb +1 -1
  37. data/lib/eco/api/common/version_patches/exception.rb +22 -0
  38. data/lib/eco/api/common/version_patches/object.rb +10 -0
  39. data/lib/eco/api/custom.rb +13 -0
  40. data/lib/eco/api/custom/error_handler.rb +20 -0
  41. data/lib/eco/api/custom/namespace.rb +7 -0
  42. data/lib/eco/api/custom/parser.rb +50 -0
  43. data/lib/eco/api/custom/policy.rb +28 -0
  44. data/lib/eco/api/custom/use_case.rb +16 -0
  45. data/lib/eco/api/error.rb +1 -0
  46. data/lib/eco/api/error/handlers.rb +10 -3
  47. data/lib/eco/api/microcases.rb +17 -13
  48. data/lib/eco/api/microcases/account_excluded.rb +24 -0
  49. data/lib/eco/api/microcases/append_usergroups.rb +19 -0
  50. data/lib/eco/api/microcases/core_excluded.rb +4 -4
  51. data/lib/eco/api/microcases/{set_default_group.rb → fix_default_group.rb} +10 -9
  52. data/lib/eco/api/microcases/fix_filter_tags.rb +26 -6
  53. data/lib/eco/api/microcases/people_cache.rb +17 -0
  54. data/lib/eco/api/microcases/people_load.rb +59 -0
  55. data/lib/eco/api/microcases/people_refresh.rb +31 -0
  56. data/lib/eco/api/microcases/people_search.rb +65 -0
  57. data/lib/eco/api/microcases/refresh_abilities.rb +19 -0
  58. data/lib/eco/api/microcases/refresh_default_tag.rb +27 -0
  59. data/lib/eco/api/microcases/s3upload_targets.rb +39 -0
  60. data/lib/eco/api/microcases/set_account.rb +7 -19
  61. data/lib/eco/api/microcases/set_core.rb +5 -5
  62. data/lib/eco/api/microcases/set_core_with_supervisor.rb +23 -0
  63. data/lib/eco/api/microcases/set_supervisor.rb +17 -13
  64. data/lib/eco/api/microcases/strict_search.rb +12 -7
  65. data/lib/eco/api/microcases/with_each.rb +27 -0
  66. data/lib/eco/api/microcases/with_each_leaver.rb +24 -0
  67. data/lib/eco/api/microcases/with_each_present.rb +30 -0
  68. data/lib/eco/api/microcases/with_each_starter.rb +30 -0
  69. data/lib/eco/api/microcases/with_each_subordinate.rb +34 -0
  70. data/lib/eco/api/microcases/with_supervisor.rb +36 -0
  71. data/lib/eco/api/organization/people.rb +72 -35
  72. data/lib/eco/api/organization/presets_factory.rb +13 -4
  73. data/lib/eco/api/policies.rb +11 -7
  74. data/lib/eco/api/session.rb +54 -24
  75. data/lib/eco/api/session/batch.rb +1 -1
  76. data/lib/eco/api/session/batch/base_policy.rb +7 -6
  77. data/lib/eco/api/session/batch/errors.rb +28 -4
  78. data/lib/eco/api/session/batch/feedback.rb +7 -1
  79. data/lib/eco/api/session/batch/job.rb +40 -23
  80. data/lib/eco/api/session/batch/jobs.rb +9 -4
  81. data/lib/eco/api/session/batch/jobs_groups.rb +1 -1
  82. data/lib/eco/api/session/batch/request_stats.rb +95 -58
  83. data/lib/eco/api/session/batch/status.rb +35 -31
  84. data/lib/eco/api/session/config.rb +104 -42
  85. data/lib/eco/api/session/config/api.rb +17 -6
  86. data/lib/eco/api/session/config/logger.rb +2 -2
  87. data/lib/eco/api/session/config/post_launch.rb +1 -1
  88. data/lib/eco/api/session/config/workflow.rb +8 -7
  89. data/lib/eco/api/usecases.rb +47 -33
  90. data/lib/eco/api/usecases/backup/append_usergroups_case.rb +36 -0
  91. data/lib/eco/api/usecases/backup/create_case.rb +104 -0
  92. data/lib/eco/api/usecases/backup/create_details_case.rb +31 -0
  93. data/lib/eco/api/usecases/backup/create_details_with_supervisor_case.rb +48 -0
  94. data/lib/eco/api/usecases/backup/hris_case.rb +124 -0
  95. data/lib/eco/api/usecases/backup/set_default_tag_case.rb +49 -0
  96. data/lib/eco/api/usecases/backup/set_supervisor_case.rb +41 -0
  97. data/lib/eco/api/usecases/backup/transfer_account_case.rb +90 -0
  98. data/lib/eco/api/usecases/backup/update_case.rb +112 -0
  99. data/lib/eco/api/usecases/backup/update_details_case.rb +64 -0
  100. data/lib/eco/api/usecases/backup/upsert_case.rb +114 -0
  101. data/lib/eco/api/usecases/base_case.rb +2 -0
  102. data/lib/eco/api/usecases/base_io.rb +3 -3
  103. data/lib/eco/api/usecases/default_cases.rb +23 -53
  104. data/lib/eco/api/usecases/default_cases/append_usergroups_case.rb +10 -31
  105. data/lib/eco/api/usecases/default_cases/change_email_case.rb +23 -47
  106. data/lib/eco/api/usecases/default_cases/codes_to_tags_case.rb +56 -43
  107. data/lib/eco/api/usecases/default_cases/create_case.rb +15 -101
  108. data/lib/eco/api/usecases/default_cases/create_details_case.rb +11 -26
  109. data/lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb +12 -43
  110. data/lib/eco/api/usecases/default_cases/delete_sync_case.rb +11 -0
  111. data/lib/eco/api/usecases/default_cases/delete_trans_case.rb +14 -0
  112. data/lib/eco/api/usecases/default_cases/email_as_id_case.rb +10 -21
  113. data/lib/eco/api/usecases/default_cases/hris_case.rb +23 -120
  114. data/lib/eco/api/usecases/default_cases/new_email_case.rb +10 -23
  115. data/lib/eco/api/usecases/default_cases/new_id_case.rb +11 -25
  116. data/lib/eco/api/usecases/default_cases/new_id_case0.rb +14 -0
  117. data/lib/eco/api/usecases/default_cases/org_data_convert_case.rb +101 -0
  118. data/lib/eco/api/usecases/default_cases/refresh_abilities_case.rb +30 -0
  119. data/lib/eco/api/usecases/default_cases/refresh_case.rb +7 -20
  120. data/lib/eco/api/usecases/default_cases/reinvite_sync_case.rb +11 -0
  121. data/lib/eco/api/usecases/default_cases/reinvite_trans_case.rb +17 -0
  122. data/lib/eco/api/usecases/default_cases/remove_account_sync_case.rb +11 -0
  123. data/lib/eco/api/usecases/default_cases/remove_account_trans_case.rb +17 -0
  124. data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +9 -19
  125. data/lib/eco/api/usecases/default_cases/restore_db_case.rb +104 -0
  126. data/lib/eco/api/usecases/default_cases/set_default_tag_case.rb +32 -40
  127. data/lib/eco/api/usecases/default_cases/set_supervisor_case.rb +15 -33
  128. data/lib/eco/api/usecases/default_cases/switch_supervisor_case.rb +66 -57
  129. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +36 -44
  130. data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +40 -55
  131. data/lib/eco/api/usecases/default_cases/transfer_account_case.rb +264 -84
  132. data/lib/eco/api/usecases/default_cases/update_case.rb +15 -109
  133. data/lib/eco/api/usecases/default_cases/update_details_case.rb +14 -61
  134. data/lib/eco/api/usecases/default_cases/upsert_case.rb +16 -111
  135. data/lib/eco/api/usecases/use_case.rb +1 -1
  136. data/lib/eco/api/usecases/use_case_io.rb +9 -10
  137. data/lib/eco/cli/config.rb +10 -2
  138. data/lib/eco/cli/config/default.rb +2 -1
  139. data/lib/eco/cli/config/default/input_filters.rb +58 -0
  140. data/lib/eco/cli/config/default/options.rb +60 -25
  141. data/lib/eco/cli/config/default/people.rb +4 -4
  142. data/lib/eco/cli/config/default/people_filters.rb +108 -0
  143. data/lib/eco/cli/config/default/usecases.rb +89 -31
  144. data/lib/eco/cli/config/default/workflow.rb +37 -27
  145. data/lib/eco/cli/config/filters.rb +50 -0
  146. data/lib/eco/cli/config/filters/input_filters.rb +29 -0
  147. data/lib/eco/cli/config/filters/people_filters.rb +29 -0
  148. data/lib/eco/cli/config/help.rb +49 -0
  149. data/lib/eco/cli/config/options_set.rb +17 -1
  150. data/lib/eco/cli/config/use_cases.rb +79 -53
  151. data/lib/eco/cli/scripting.rb +10 -2
  152. data/lib/eco/cli/scripting/args_helpers.rb +25 -15
  153. data/lib/eco/cli/scripting/argument.rb +1 -0
  154. data/lib/eco/cli/scripting/arguments.rb +1 -1
  155. data/lib/eco/csv/table.rb +1 -1
  156. data/lib/eco/data/crypto/encryption.rb +3 -0
  157. data/lib/eco/language/match.rb +19 -9
  158. data/lib/eco/language/match_modifier.rb +13 -5
  159. data/lib/eco/language/models/collection.rb +77 -56
  160. data/lib/eco/language/models/parser_serializer.rb +39 -15
  161. data/lib/eco/version.rb +1 -1
  162. metadata +64 -18
  163. data/lib/eco/api/microcases/set_default_tag.rb +0 -23
  164. data/lib/eco/api/session/task.rb +0 -175
  165. data/lib/eco/api/usecases/default_case.rb +0 -19
  166. data/lib/eco/api/usecases/default_cases/delete_case.rb +0 -32
  167. data/lib/eco/api/usecases/default_cases/recover_db_case.rb +0 -99
  168. data/lib/eco/api/usecases/default_cases/refresh_presets_case.rb +0 -26
  169. data/lib/eco/api/usecases/default_cases/reinvite_case.rb +0 -41
  170. data/lib/eco/api/usecases/default_cases/remove_account_case.rb +0 -38
  171. data/lib/eco/api/usecases/microed_cases/hris_case.rb +0 -53
  172. data/lib/eco/api/usecases/microed_cases/update_case.rb +0 -33
  173. data/lib/eco/api/usecases/microed_cases/update_details_case.rb +0 -30
  174. data/lib/eco/api/usecases/microed_cases/upsert_case.rb +0 -36
  175. data/lib/eco/cli/config/default/filters.rb +0 -70
  176. data/lib/eco/cli/config/people_filters.rb +0 -38
@@ -1,29 +1,32 @@
1
1
  module Eco
2
2
  module Language
3
3
  module Models
4
-
4
+ # Basic class to define a parser/serializing framework
5
+ # @attr_reader attr [String, Symbol] the attribute this parser/serializer is linked to.
5
6
  class ParserSerializer
6
-
7
7
  attr_reader :attr
8
8
 
9
9
  # Parser/seralizer.
10
10
  # @param attr [String, Symbol] name of the parsed/serialized.
11
11
  # @param dependencies [Hash] provisioning of _**default dependencies**_ that will be required when calling back to the
12
- # parsing or serializing functions.
12
+ # parsing or serializing functions.
13
13
  def initialize(attr, dependencies: {})
14
- @attr = attr
14
+ @attr = attr
15
15
  @dependencies = dependencies
16
+ @parser = {}
17
+ @serializer = {}
16
18
  end
17
19
 
18
20
  # Defines the _parser_ of the attribute.
19
21
  # @note
20
22
  # 1. the _block_ should expect one or two parameters.
21
23
  # 2. the final dependencies is a merge of _default dependencies_ with `parse` call dependencies.
24
+ # @param category [Symbol] a way to classify multiple parsers by category.
22
25
  # @yield [source_data, dependencies] user defined parser that returns the parsed value.
23
26
  # @yieldparam source_data [Any] source data that will be parsed.
24
27
  # @yieldparam dependencies [Hash] hash with the provisioned dependencies.
25
- def def_parser(&block)
26
- @parser = block
28
+ def def_parser(category = :default, &block)
29
+ @parser[category.to_sym] = block
27
30
  self
28
31
  end
29
32
 
@@ -31,11 +34,12 @@ module Eco
31
34
  # @note
32
35
  # 1. the block should expect one or two parameters.
33
36
  # 2. the final dependencies is a merge of _default dependencies_ with `serialize` call dependencies.
37
+ # @param category [Symbol] a way to classify multiple serializers by category.
34
38
  # @yield [source_data, dependencies] user defined serialiser that returns the serialised value.
35
39
  # @yieldparam source_data [Any] source data that will be serialised.
36
40
  # @yieldparam dependencies [Hash] hash with the provisioned dependencies.
37
- def def_serializer(&block)
38
- @serializer = block
41
+ def def_serializer(category = :default, &block)
42
+ @serializer[category.to_sym] = block
39
43
  self
40
44
  end
41
45
 
@@ -45,9 +49,9 @@ module Eco
45
49
  # @raise [Exception] when there is **no** `parser` defined.
46
50
  # @param source [Any] source data to be parsed.
47
51
  # @param dependencies [Hash] _additional dependencies_ that should be merged to the _default dependencies_.
48
- def parse(source, dependencies: {})
49
- raise "There is no parser for this attribue '#{attr}'" if !@parser
50
- @parser.call(source, @dependencies.merge(dependencies), attr)
52
+ def parse(source, category = :default, dependencies: {})
53
+ raise "There is no parser of type '#{category}' for this attribue '#{attr}'" unless parser_category?(category)
54
+ call_block(source, @dependencies.merge(dependencies), attr, &@parser[category.to_sym])
51
55
  end
52
56
 
53
57
  # Calls the `serializer` of this attribute by passing `object` and resolved dependencies.
@@ -56,13 +60,33 @@ module Eco
56
60
  # @raise [Exception] when there is **no** `serializer` defined.
57
61
  # @param object [Any] source data to be serialized.
58
62
  # @param dependencies [Hash] _additional dependencies_ that should be merged to the _default dependencies_.
59
- def serialize(object, dependencies: {})
60
- raise "There is no serializer for this attribue '#{attr}'" if !@serializer
61
- @serializer.call(object, @dependencies.merge(dependencies), attr)
63
+ def serialize(object, category = :default, dependencies: {})
64
+ raise "There is no serializer of type '#{category}' for this attribue '#{attr}'" unless serializer_category?(category)
65
+ call_block(object, @dependencies.merge(dependencies), attr, &@serializer[category.to_sym])
62
66
  end
63
67
 
64
- end
68
+ # Checks if there's a `parser` defined for `category`
69
+ # @return [Boolean] `true` if the parser is defined, and `false` otherwise
70
+ def parser_category?(category = :default)
71
+ @parser.key?(category.to_sym)
72
+ end
73
+
74
+ # Checks if there's a `serializer` defined for `category`
75
+ # @return [Boolean] `true` if the serializer is defined, and `false` otherwise
76
+ def serializer_category?(category = :default)
77
+ @serializer.key?(category.to_sym)
78
+ end
79
+
80
+ private
65
81
 
82
+ # The methods may expect less parameters from some type of parsers.
83
+ # Here, we ensure they are called with the expected number of parameters.
84
+ def call_block(*args, &block)
85
+ params = block.parameters.zip(args).map(&:last)
86
+ yield(*params)
87
+ end
88
+
89
+ end
66
90
  end
67
91
  end
68
92
  end
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "1.5.1"
2
+ VERSION = "1.5.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -116,7 +116,7 @@ dependencies:
116
116
  requirements:
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: 0.7.1
119
+ version: 0.7.3
120
120
  - - "<"
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0.8'
@@ -126,7 +126,7 @@ dependencies:
126
126
  requirements:
127
127
  - - ">="
128
128
  - !ruby/object:Gem::Version
129
- version: 0.7.1
129
+ version: 0.7.3
130
130
  - - "<"
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0.8'
@@ -242,14 +242,23 @@ files:
242
242
  - ".yardopts"
243
243
  - CHANGELOG.md
244
244
  - Gemfile
245
+ - LICENSE
245
246
  - README.md
246
247
  - Rakefile
247
248
  - eco-helpers.gemspec
248
249
  - lib/eco-helpers.rb
249
250
  - lib/eco/api.rb
250
251
  - lib/eco/api/common.rb
252
+ - lib/eco/api/common/base_loader.rb
253
+ - lib/eco/api/common/class_auto_loader.rb
251
254
  - lib/eco/api/common/class_helpers.rb
252
255
  - lib/eco/api/common/class_hierarchy.rb
256
+ - lib/eco/api/common/class_meta_basics.rb
257
+ - lib/eco/api/common/loaders.rb
258
+ - lib/eco/api/common/loaders/error_handler.rb
259
+ - lib/eco/api/common/loaders/parser.rb
260
+ - lib/eco/api/common/loaders/policy.rb
261
+ - lib/eco/api/common/loaders/use_case.rb
253
262
  - lib/eco/api/common/people.rb
254
263
  - lib/eco/api/common/people/base_parser.rb
255
264
  - lib/eco/api/common/people/default_parsers.rb
@@ -257,6 +266,7 @@ files:
257
266
  - lib/eco/api/common/people/default_parsers/csv_parser.rb
258
267
  - lib/eco/api/common/people/default_parsers/date_parser.rb
259
268
  - lib/eco/api/common/people/default_parsers/freemium_parser.rb
269
+ - lib/eco/api/common/people/default_parsers/login_providers_parser.rb
260
270
  - lib/eco/api/common/people/default_parsers/multi_parser.rb
261
271
  - lib/eco/api/common/people/default_parsers/numeric_parser.rb
262
272
  - lib/eco/api/common/people/default_parsers/policy_groups_parser.rb
@@ -286,18 +296,40 @@ files:
286
296
  - lib/eco/api/common/version_patches/exception.rb
287
297
  - lib/eco/api/common/version_patches/hash.rb
288
298
  - lib/eco/api/common/version_patches/hash/deep_merge.rb
299
+ - lib/eco/api/common/version_patches/object.rb
300
+ - lib/eco/api/custom.rb
301
+ - lib/eco/api/custom/error_handler.rb
302
+ - lib/eco/api/custom/namespace.rb
303
+ - lib/eco/api/custom/parser.rb
304
+ - lib/eco/api/custom/policy.rb
305
+ - lib/eco/api/custom/use_case.rb
289
306
  - lib/eco/api/error.rb
290
307
  - lib/eco/api/error/handler.rb
291
308
  - lib/eco/api/error/handlers.rb
292
309
  - lib/eco/api/microcases.rb
310
+ - lib/eco/api/microcases/account_excluded.rb
311
+ - lib/eco/api/microcases/append_usergroups.rb
293
312
  - lib/eco/api/microcases/core_excluded.rb
313
+ - lib/eco/api/microcases/fix_default_group.rb
294
314
  - lib/eco/api/microcases/fix_filter_tags.rb
315
+ - lib/eco/api/microcases/people_cache.rb
316
+ - lib/eco/api/microcases/people_load.rb
317
+ - lib/eco/api/microcases/people_refresh.rb
318
+ - lib/eco/api/microcases/people_search.rb
319
+ - lib/eco/api/microcases/refresh_abilities.rb
320
+ - lib/eco/api/microcases/refresh_default_tag.rb
321
+ - lib/eco/api/microcases/s3upload_targets.rb
295
322
  - lib/eco/api/microcases/set_account.rb
296
323
  - lib/eco/api/microcases/set_core.rb
297
- - lib/eco/api/microcases/set_default_group.rb
298
- - lib/eco/api/microcases/set_default_tag.rb
324
+ - lib/eco/api/microcases/set_core_with_supervisor.rb
299
325
  - lib/eco/api/microcases/set_supervisor.rb
300
326
  - lib/eco/api/microcases/strict_search.rb
327
+ - lib/eco/api/microcases/with_each.rb
328
+ - lib/eco/api/microcases/with_each_leaver.rb
329
+ - lib/eco/api/microcases/with_each_present.rb
330
+ - lib/eco/api/microcases/with_each_starter.rb
331
+ - lib/eco/api/microcases/with_each_subordinate.rb
332
+ - lib/eco/api/microcases/with_supervisor.rb
301
333
  - lib/eco/api/organization.rb
302
334
  - lib/eco/api/organization/login_providers.rb
303
335
  - lib/eco/api/organization/people.rb
@@ -334,11 +366,20 @@ files:
334
366
  - lib/eco/api/session/config/s3_storage.rb
335
367
  - lib/eco/api/session/config/sftp.rb
336
368
  - lib/eco/api/session/config/workflow.rb
337
- - lib/eco/api/session/task.rb
338
369
  - lib/eco/api/usecases.rb
370
+ - lib/eco/api/usecases/backup/append_usergroups_case.rb
371
+ - lib/eco/api/usecases/backup/create_case.rb
372
+ - lib/eco/api/usecases/backup/create_details_case.rb
373
+ - lib/eco/api/usecases/backup/create_details_with_supervisor_case.rb
374
+ - lib/eco/api/usecases/backup/hris_case.rb
375
+ - lib/eco/api/usecases/backup/set_default_tag_case.rb
376
+ - lib/eco/api/usecases/backup/set_supervisor_case.rb
377
+ - lib/eco/api/usecases/backup/transfer_account_case.rb
378
+ - lib/eco/api/usecases/backup/update_case.rb
379
+ - lib/eco/api/usecases/backup/update_details_case.rb
380
+ - lib/eco/api/usecases/backup/upsert_case.rb
339
381
  - lib/eco/api/usecases/base_case.rb
340
382
  - lib/eco/api/usecases/base_io.rb
341
- - lib/eco/api/usecases/default_case.rb
342
383
  - lib/eco/api/usecases/default_cases.rb
343
384
  - lib/eco/api/usecases/default_cases/append_usergroups_case.rb
344
385
  - lib/eco/api/usecases/default_cases/change_email_case.rb
@@ -346,17 +387,22 @@ files:
346
387
  - lib/eco/api/usecases/default_cases/create_case.rb
347
388
  - lib/eco/api/usecases/default_cases/create_details_case.rb
348
389
  - lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb
349
- - lib/eco/api/usecases/default_cases/delete_case.rb
390
+ - lib/eco/api/usecases/default_cases/delete_sync_case.rb
391
+ - lib/eco/api/usecases/default_cases/delete_trans_case.rb
350
392
  - lib/eco/api/usecases/default_cases/email_as_id_case.rb
351
393
  - lib/eco/api/usecases/default_cases/hris_case.rb
352
394
  - lib/eco/api/usecases/default_cases/new_email_case.rb
353
395
  - lib/eco/api/usecases/default_cases/new_id_case.rb
354
- - lib/eco/api/usecases/default_cases/recover_db_case.rb
396
+ - lib/eco/api/usecases/default_cases/new_id_case0.rb
397
+ - lib/eco/api/usecases/default_cases/org_data_convert_case.rb
398
+ - lib/eco/api/usecases/default_cases/refresh_abilities_case.rb
355
399
  - lib/eco/api/usecases/default_cases/refresh_case.rb
356
- - lib/eco/api/usecases/default_cases/refresh_presets_case.rb
357
- - lib/eco/api/usecases/default_cases/reinvite_case.rb
358
- - lib/eco/api/usecases/default_cases/remove_account_case.rb
400
+ - lib/eco/api/usecases/default_cases/reinvite_sync_case.rb
401
+ - lib/eco/api/usecases/default_cases/reinvite_trans_case.rb
402
+ - lib/eco/api/usecases/default_cases/remove_account_sync_case.rb
403
+ - lib/eco/api/usecases/default_cases/remove_account_trans_case.rb
359
404
  - lib/eco/api/usecases/default_cases/reset_landing_page_case.rb
405
+ - lib/eco/api/usecases/default_cases/restore_db_case.rb
360
406
  - lib/eco/api/usecases/default_cases/set_default_tag_case.rb
361
407
  - lib/eco/api/usecases/default_cases/set_supervisor_case.rb
362
408
  - lib/eco/api/usecases/default_cases/switch_supervisor_case.rb
@@ -366,10 +412,6 @@ files:
366
412
  - lib/eco/api/usecases/default_cases/update_case.rb
367
413
  - lib/eco/api/usecases/default_cases/update_details_case.rb
368
414
  - lib/eco/api/usecases/default_cases/upsert_case.rb
369
- - lib/eco/api/usecases/microed_cases/hris_case.rb
370
- - lib/eco/api/usecases/microed_cases/update_case.rb
371
- - lib/eco/api/usecases/microed_cases/update_details_case.rb
372
- - lib/eco/api/usecases/microed_cases/upsert_case.rb
373
415
  - lib/eco/api/usecases/use_case.rb
374
416
  - lib/eco/api/usecases/use_case_chain.rb
375
417
  - lib/eco/api/usecases/use_case_io.rb
@@ -378,15 +420,19 @@ files:
378
420
  - lib/eco/cli.rb
379
421
  - lib/eco/cli/config.rb
380
422
  - lib/eco/cli/config/default.rb
381
- - lib/eco/cli/config/default/filters.rb
382
423
  - lib/eco/cli/config/default/input.rb
424
+ - lib/eco/cli/config/default/input_filters.rb
383
425
  - lib/eco/cli/config/default/options.rb
384
426
  - lib/eco/cli/config/default/people.rb
427
+ - lib/eco/cli/config/default/people_filters.rb
385
428
  - lib/eco/cli/config/default/usecases.rb
386
429
  - lib/eco/cli/config/default/workflow.rb
430
+ - lib/eco/cli/config/filters.rb
431
+ - lib/eco/cli/config/filters/input_filters.rb
432
+ - lib/eco/cli/config/filters/people_filters.rb
433
+ - lib/eco/cli/config/help.rb
387
434
  - lib/eco/cli/config/input.rb
388
435
  - lib/eco/cli/config/options_set.rb
389
- - lib/eco/cli/config/people_filters.rb
390
436
  - lib/eco/cli/config/use_cases.rb
391
437
  - lib/eco/cli/scripting.rb
392
438
  - lib/eco/cli/scripting/args_helpers.rb
@@ -1,23 +0,0 @@
1
- module Eco
2
- module API
3
- class MicroCases
4
- #self.define("set_default_tag") do |entry, person, session, options|
5
-
6
- # @param entry [PersonEntry] the input entry with the data we should set on person.
7
- # @param person [Person] the person we want to update, carrying the changes to be done.
8
- # @param options [Hash] the options
9
- def set_default_tag(entry, person, options)
10
- unless options.dig(:exclude, :account)
11
- unless options.dig(:exclude, :filter_tags) || entry.default_tag?
12
- if session.tagtree
13
- person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
14
- else
15
- tags = person.filter_tags || []
16
- person.account.default_tag = tags.first unless tags.length > 1
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,175 +0,0 @@
1
- module Eco
2
- module API
3
- class Session
4
- # Set of helpers to do most common tasks
5
- class Task < API::Common::Session::BaseSession
6
- NEWEST_FILE_MODE = [:newest, :last_file, :previous]
7
- LOAD_FILE_MODE = [:file]
8
- SAVE_FILE_MODE = [:save]
9
- API_MODE = [:api, :api_get]
10
-
11
- def file_people(filename = enviro.config.people.cache)
12
- logger.info("Going to get all the people via API")
13
- people = session.batch.get_people
14
- file = file_manager.save_json(people, filename, :timestamp)
15
- logger.info("#{people.length} people loaded and saved locally to #{file}.")
16
- Eco::API::Organization::People.new(people)
17
- end
18
-
19
- def people_refresh(people:, include_created: true)
20
- ini = people.length
21
- if include_created
22
- session.job_groups.find_jobs(type: :create).map do |job|
23
- people = people.merge(job.people)
24
- end
25
- end
26
-
27
- created = people.length - ini
28
- msg = "Going to refresh #{people.length} people with server data"
29
- msg += " (including #{created} that were created)" if created > 0
30
- session.logger.info(msg)
31
- status = session.batch.get_people(people, silent: true)
32
- entries = status.people
33
-
34
- missing = people.length - entries.length
35
- session.logger.error("Missed to obtain #{missing} people during the refresh") if missing > 0
36
-
37
- Eco::API::Organization::People.new(status.people)
38
- end
39
-
40
- def search(data, options: {}, silent: true)
41
- strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))
42
-
43
- # to scope people to be fresh data got via api
44
- session.logger.info("going to api get #{data.length} entries...")
45
-
46
- status = session.batch.search(data, silent: silent)
47
- people = Eco::API::Organization::People.new(status.people)
48
-
49
- # get the supervisors
50
- supers = people.each_with_object([]) do |person, sup|
51
- if sup_id = person.supervisor_id
52
- spr = {"id" => sup_id}
53
- sup.push(spr) unless sup.include?(spr) || people.person(id: sup_id, external_id: sup_id)
54
- end
55
- end
56
-
57
- if supers.length > 0
58
- session.logger.info("going to api get #{supers.length} current supervisors...")
59
- status = session.batch.search(supers, silent: silent)
60
- people = people.merge(status.people, strict: strict_search)
61
- end
62
-
63
- supers = data.each_with_object([]) do |entry, sup|
64
- if entry.respond_to?(:supervisor_id) && !entry.supervisor_id.to_s.strip.empty?
65
- sup_id = entry.supervisor_id
66
- spr = {"id" => entry.supervisor_id}
67
- sup.push(spr) unless sup.include?(spr) || people.person(id: sup_id, external_id: sup_id)
68
- end
69
- end
70
-
71
- if supers.length > 0
72
- session.logger.info("going to api get #{supers.length} supervisors as per entries...")
73
- status = session.batch.search(supers, silent: silent)
74
- people = people.merge(status.people, strict: strict_search)
75
- end
76
-
77
- session.logger.info("could get #{people.length} people (out of #{data.length} entries)")
78
- people
79
- end
80
-
81
- def load_people(filename = enviro.config.people.cache, modifier: [:newest, :api])
82
- modifier = [modifier].flatten
83
- people = []
84
- case
85
- when !!filename && (load_file?(modifier) || newest_file?(modifier))
86
- case
87
- when newest_file?(modifier)
88
- # search input file based on pattern (in case the name has a timestamp)
89
- file = file_manager.dir.newest_file(file: filename)
90
- logger.info("previous file found: #{file}") if !!file
91
- else
92
- file = file_manager.dir.file(filename)
93
- end
94
-
95
- if !file
96
- logger.error("could not find the file #{file_manager.dir.file(filename)}")
97
- exit if !use_api?(modifier)
98
- people = self.load_people(modifier: modifier - NEWEST_FILE_MODE - LOAD_FILE_MODE)
99
- else
100
- people = file_manager.load_json(file)
101
- if !!people && people.is_a?(Array)
102
- logger.info("#{people&.length} people loaded from file #{file}")
103
- end
104
- end
105
- when use_api?(modifier)
106
- # no previous file: use API to get all people
107
- logger.info("Going to get all the people via API")
108
- people = session.batch.get_people
109
-
110
- if save_file?(modifier) && people && people.length > 0
111
- file = file_manager.save_json(people, filename, :timestamp)
112
- logger.info("#{people.length } people saved to file #{file}.")
113
- end
114
- end
115
- Eco::API::Organization::People.new(people)
116
- end
117
-
118
- def s3upload_targets
119
- [].tap do |paths|
120
- session.config.s3storage.target_files.each_with_object(paths) do |file, arr|
121
- arr.push(session.s3upload(file: file))
122
- end
123
- session.config.s3storage.target_directories.each_with_object(paths) do |folder, arr|
124
- arr.concat(session.s3upload(directory: folder))
125
- end
126
- session.config.s3storage.target_file_patterns.each_with_object(paths) do |pattern, arr|
127
- filenames = []
128
- case pattern
129
- when Regexp
130
- Dir.entries(".").sort.each do |file|
131
- next unless File.file?(file) # Skip directories
132
- filenames.push(file) if file =~ pattern
133
- end
134
- when String
135
- Dir.glob(pattern).sort.each do |file|
136
- next unless File.file?(file) # Skip directories
137
- filenames.push(file)
138
- end
139
- else
140
- # missconfiguration
141
- end
142
- filenames.each do |file|
143
- arr.push(session.s3upload(file: file))
144
- end
145
- end
146
- end
147
- end
148
-
149
- private
150
-
151
- # MODIFIERS
152
- def use_api?(modifier)
153
- modifiers = [modifier].flatten
154
- modifiers.any? { |m| API_MODE.include?(m) }
155
- end
156
-
157
- def load_file?(modifier)
158
- modifiers = [modifier].flatten
159
- modifiers.any? { |m| LOAD_FILE_MODE.include?(m) }
160
- end
161
-
162
- def newest_file?(modifier)
163
- modifiers = [modifier].flatten
164
- modifiers.any? { |m| NEWEST_FILE_MODE.include?(m) }
165
- end
166
-
167
- def save_file?(modifier)
168
- modifiers = [modifier].flatten
169
- modifiers.any? { |m| SAVE_FILE_MODE.include?(m) }
170
- end
171
-
172
- end
173
- end
174
- end
175
- end