ecoportal-api-v2 2.0.5 → 2.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +7 -0
  3. data/CHANGELOG.md +25 -1
  4. data/ecoportal-api-v2.gemspec +1 -1
  5. data/lib/ecoportal/api/common/content/class_helpers.rb +1 -1
  6. data/lib/ecoportal/api/common/content/client.rb +1 -1
  7. data/lib/ecoportal/api/common/content/doc_helpers.rb +2 -2
  8. data/lib/ecoportal/api/common/content/double_model.rb +8 -8
  9. data/lib/ecoportal/api/common/content/hash_diff_patch.rb +2 -1
  10. data/lib/ecoportal/api/common/content/wrapped_response.rb +1 -1
  11. data/lib/ecoportal/api/common.v2.rb +4 -0
  12. data/lib/ecoportal/api/v2/page/component/action.rb +1 -1
  13. data/lib/ecoportal/api/v2/page/component/chart_field/config.rb +1 -1
  14. data/lib/ecoportal/api/v2/page/component/checklist_item.rb +1 -1
  15. data/lib/ecoportal/api/v2/page/component/file.rb +1 -1
  16. data/lib/ecoportal/api/v2/page/component/gauge_stop.rb +1 -1
  17. data/lib/ecoportal/api/v2/page/component/geo_coordinates.rb +2 -2
  18. data/lib/ecoportal/api/v2/page/component/image.rb +2 -2
  19. data/lib/ecoportal/api/v2/page/component/law.rb +1 -1
  20. data/lib/ecoportal/api/v2/page/component/people_viewable_field.rb +1 -1
  21. data/lib/ecoportal/api/v2/page/component/selection_option.rb +1 -1
  22. data/lib/ecoportal/api/v2/page/component/selection_options.rb +1 -1
  23. data/lib/ecoportal/api/v2/page/component.rb +1 -1
  24. data/lib/ecoportal/api/v2/page/components.rb +1 -1
  25. data/lib/ecoportal/api/v2/page/force/binding.rb +1 -1
  26. data/lib/ecoportal/api/v2/page/force/bindings.rb +3 -3
  27. data/lib/ecoportal/api/v2/page/force/helper.rb +1 -1
  28. data/lib/ecoportal/api/v2/page/force.rb +1 -1
  29. data/lib/ecoportal/api/v2/page/forces.rb +4 -4
  30. data/lib/ecoportal/api/v2/page/mould_counter.rb +1 -1
  31. data/lib/ecoportal/api/v2/page/permission_flags.rb +1 -1
  32. data/lib/ecoportal/api/v2/page/permit.rb +1 -1
  33. data/lib/ecoportal/api/v2/page/section.rb +1 -1
  34. data/lib/ecoportal/api/v2/page/sections.rb +2 -2
  35. data/lib/ecoportal/api/v2/page/stage.rb +1 -1
  36. data/lib/ecoportal/api/v2/page/stages.rb +1 -1
  37. data/lib/ecoportal/api/v2/page.rb +1 -1
  38. data/lib/ecoportal/api/v2/pages/page_create_response.rb +1 -1
  39. data/lib/ecoportal/api/v2/pages/page_stage/task.rb +12 -8
  40. data/lib/ecoportal/api/v2/pages/page_stage/tasks.rb +1 -1
  41. data/lib/ecoportal/api/v2/pages/page_stage.rb +8 -4
  42. data/lib/ecoportal/api/v2/pages/stages.rb +2 -2
  43. data/lib/ecoportal/api/v2/pages.rb +19 -9
  44. data/lib/ecoportal/api/v2/people.rb +1 -1
  45. data/lib/ecoportal/api/v2/registers/page_result/membrane_droplet.rb +1 -1
  46. data/lib/ecoportal/api/v2/registers/page_result.rb +2 -2
  47. data/lib/ecoportal/api/v2/registers/register.rb +1 -1
  48. data/lib/ecoportal/api/v2/registers/search_results.rb +1 -1
  49. data/lib/ecoportal/api/v2/registers/stage_result.rb +1 -1
  50. data/lib/ecoportal/api/v2/registers/template.rb +1 -1
  51. data/lib/ecoportal/api/v2/registers.rb +5 -5
  52. data/lib/ecoportal/api/v2/s3/files/poll.rb +1 -1
  53. data/lib/ecoportal/api/v2/s3/files/poll_status.rb +2 -2
  54. data/lib/ecoportal/api/v2/s3/files.rb +4 -3
  55. data/lib/ecoportal/api/v2/s3.rb +4 -3
  56. data/lib/ecoportal/api/v2.rb +7 -2
  57. data/lib/ecoportal/api/v2_version.rb +1 -1
  58. data/lib/ecoportal/api-v2.rb +3 -2
  59. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97b022ff724f1d1d3f80b357d482e54ebba3750751de3771097840c1a9a1e697
4
- data.tar.gz: f587813ad0917441c55c1a5dde359ca5e12070ee22d899f5a41646fa63af40dc
3
+ metadata.gz: 5640c86f2f87990f7d4c3906f4732ee196b757966c3c3cc08f0a87e458ccb4a5
4
+ data.tar.gz: c90366a05f7c35fc77a0d8374384258277092e9d7b3ee25f458ab815a41162ce
5
5
  SHA512:
6
- metadata.gz: 8d4e4f6c25ab85c7c8c0a119fdab33b107b519022c66ce57c2159e1de89cb73e200243e59105adc7c50d0dd3a718367ecbc9d47e8fda5766d6ab33c3a09ed3cd
7
- data.tar.gz: d8230c7c42ff3f358d9b33a8a81d194f8aba30149089c5201f5bf21a905028195503e8a0530a6a99e4c1ce4f828f4ea5e4b691b4528a569e20fb362c6884f84e
6
+ metadata.gz: 2aa98c2d721ff735425e9c21aee036698e5467a3c010e35d84921d9352ae12400f627c8a2a16359177ac22e583a417b05302c852b513b3d6d6bc4743b8cac170
7
+ data.tar.gz: f356407dfd38797be43f29ad02d7a1772c7136cf1d686eb2554dc226316184aa70e27c89b9de39d52725ab6b95505149a1d7b38a39897915862d8a0dfa33e3ca
data/.rubocop.yml CHANGED
@@ -29,6 +29,11 @@ Style/ConditionalAssignment:
29
29
  Enabled: false
30
30
  Style/BlockDelimiters:
31
31
  BracesRequiredMethods: ['log']
32
+ Style/HashSyntax:
33
+ EnforcedShorthandSyntax: either
34
+ EnforcedStyle: no_mixed_keys
35
+ Style/ArgumentsForwarding:
36
+ UseAnonymousForwarding: false
32
37
  Style/ClassAndModuleChildren:
33
38
  Enabled: false
34
39
  Style/FrozenStringLiteralComment:
@@ -92,3 +97,5 @@ Naming/MethodParameterName:
92
97
  AllowedNames: ['x', 'y', 'i', 'j', 'id', 'io']
93
98
  Naming/RescuedExceptionsVariableName:
94
99
  Enabled: false
100
+ Naming/BlockForwarding:
101
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## [2.0.6] - 2024-08-xx
5
+ ## [2.0.10] - 2024-08-xx
6
6
 
7
7
  ### Added
8
8
 
@@ -10,6 +10,30 @@ All notable changes to this project will be documented in this file.
10
10
 
11
11
  ### Fixed
12
12
 
13
+ ## [2.0.9] - 2024-08-22
14
+
15
+ ### Added
16
+
17
+ - `force_complete` stage tasks
18
+
19
+ ## [2.0.8] - 2024-08-08
20
+
21
+ ### Fixed
22
+
23
+ - Force to load via `ecoportal/api-v2`
24
+
25
+ ## [2.0.7] - 2024-08-08
26
+
27
+ ### Fixed
28
+
29
+ - Get `Common` namespaced all over the code
30
+
31
+ ## [2.0.6] - 2024-08-08
32
+
33
+ ### Fixed
34
+
35
+ - use full path and `require` only
36
+
13
37
  ## [2.0.5] - 2024-08-07
14
38
 
15
39
  ### Fixed
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_development_dependency "pry" , '>= 0.14'
26
+ spec.add_development_dependency "pry" , '~> 0.14'
27
27
  spec.add_development_dependency "rake", '>= 13.0.3', "< 14"
28
28
  spec.add_development_dependency "redcarpet", '>= 3.6.0', "< 4"
29
29
  spec.add_development_dependency "rspec", '>= 3.12.0', "< 4"
@@ -4,7 +4,7 @@ module Ecoportal
4
4
  module Common
5
5
  module Content
6
6
  module ClassHelpers
7
- include Common::BaseClass
7
+ include Ecoportal::API::Common::BaseClass
8
8
  NOT_USED = "no_used!".freeze
9
9
 
10
10
  # Class resolver
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  module Common
4
4
  module Content
5
5
  # @see Ecoportal::API::Common::Client
6
- class Client < Common::Client
6
+ class Client < Ecoportal::API::Common::Client
7
7
  attr_accessor :logger
8
8
 
9
9
  # @note the `api_key` will be automatically added as parameter `X-ECOPORTAL-API-KEY` in the header of the http requests.
@@ -13,9 +13,9 @@ module Ecoportal
13
13
  when doc.respond_to?(:as_update)
14
14
  doc.as_update
15
15
  when doc.respond_to?(:as_json)
16
- Common::Content::HashDiffPatch.patch_diff(doc.as_json, nil)
16
+ HashDiffPatch.patch_diff(doc.as_json, nil)
17
17
  when doc.is_a?(Hash)
18
- Common::Content::HashDiffPatch.patch_diff(doc, nil)
18
+ HashDiffPatch.patch_diff(doc, nil)
19
19
  else
20
20
  raise "Could not get body for doc: #{doc}"
21
21
  end
@@ -5,7 +5,7 @@ module Ecoportal
5
5
  # Basic model class, to **build _get_ / _set_ `methods`** for a given property
6
6
  # which differs of `attr_*` ruby native class methods because `pass*`
7
7
  # completelly **links** the methods **to a subjacent `Hash` model**
8
- class DoubleModel < Common::BaseModel
8
+ class DoubleModel < Ecoportal::API::Common::BaseModel
9
9
  class UnlinkedModel < StandardError
10
10
  def initialize(msg = "Something went wrong when linking the document.", from: nil, key: nil)
11
11
  msg += " From: #{from}." if from
@@ -17,9 +17,9 @@ module Ecoportal
17
17
  class NoKeyMethod < StandardError
18
18
  end
19
19
 
20
- NOT_USED = Common::Content::ClassHelpers::NOT_USED
21
- extend Common::Content::ClassHelpers
22
- include Common::Content::ModelHelpers
20
+ NOT_USED = ClassHelpers::NOT_USED
21
+ extend ClassHelpers
22
+ include ModelHelpers
23
23
 
24
24
  class << self
25
25
  attr_reader :key
@@ -176,7 +176,7 @@ module Ecoportal
176
176
  method = method.to_s.freeze
177
177
  var = instance_variable_name(method)
178
178
 
179
- dim_class = new_class(method, inherits: Common::Content::ArrayModel) do |klass|
179
+ dim_class = new_class(method, inherits: ArrayModel) do |klass|
180
180
  klass.order_matters = order_matters
181
181
  klass.uniq = uniq
182
182
  end
@@ -213,7 +213,7 @@ module Ecoportal
213
213
  if enum_class
214
214
  eclass = enum_class
215
215
  elsif klass
216
- eclass = new_class("#{method}::#{klass}", inherits: Common::Content::CollectionModel) do |dim_class|
216
+ eclass = new_class("#{method}::#{klass}", inherits: CollectionModel) do |dim_class|
217
217
  # NOTE: new_class may resolve the namespace of the class to an already existing class
218
218
  dim_class.klass ||= klass
219
219
  dim_class.order_matters = order_matters
@@ -378,7 +378,7 @@ module Ecoportal
378
378
  # `original_doc` and `doc`
379
379
  def as_update
380
380
  new_doc = as_json
381
- Common::Content::HashDiffPatch.patch_diff(new_doc, original_doc)
381
+ HashDiffPatch.patch_diff(new_doc, original_doc)
382
382
  end
383
383
 
384
384
  # @return [Boolean] stating if there are changes
@@ -509,7 +509,7 @@ module Ecoportal
509
509
  # It allows to work-around missing item_key
510
510
  def setup_items_key(embedded_class, obj_doc)
511
511
  # only if is going to be a collection
512
- return unless obj_doc.is_a?(Array) && embedded_class < Common::Content::CollectionModel
512
+ return unless obj_doc.is_a?(Array) && embedded_class < CollectionModel
513
513
  return unless (item_class = embedded_class.klass)
514
514
  # if already has key don't need to work around
515
515
  return if item_class&.key
@@ -3,10 +3,11 @@ module Ecoportal
3
3
  module Common
4
4
  module Content
5
5
  module HashDiffPatch
6
+ extend DocHelpers
7
+
6
8
  ID_KEYS = %w[id]
7
9
  META_KEYS = %w[id patch_ver]
8
10
  NO_CHANGES = "%not-changed!%"
9
- extend Content::DocHelpers
10
11
 
11
12
  class << self
12
13
  # The `patch data` is built as follows:
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  module Common
4
4
  module Content
5
- class WrappedResponse < Common::WrappedResponse
5
+ class WrappedResponse < Ecoportal::API::Common::WrappedResponse
6
6
  include Enumerable
7
7
 
8
8
  attr_reader :response, :result
@@ -1,6 +1,10 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  module Common
4
+ unless Ecoportal::API.const_defined?(:GEM2_VERSION)
5
+ msg = "Correct way to require this gem is `require 'ecoportal/api-v2`"
6
+ raise LoadError, msg
7
+ end
4
8
  end
5
9
  end
6
10
  end
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class V2
4
4
  class Page
5
5
  class Component
6
- class Action < Common::Content::DoubleModel
6
+ class Action < Ecoportal::API::Common::Content::DoubleModel
7
7
  class << self
8
8
  def new_doc
9
9
  {
@@ -4,7 +4,7 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class ChartField
7
- class Config < Common::Content::DoubleModel
7
+ class Config < Ecoportal::API::Common::Content::DoubleModel
8
8
 
9
9
  class << self
10
10
  def new_doc
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class V2
4
4
  class Page
5
5
  class Component
6
- class ChecklistItem < Common::Content::DoubleModel
6
+ class ChecklistItem < Ecoportal::API::Common::Content::DoubleModel
7
7
 
8
8
  class << self
9
9
  def new_doc
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class V2
4
4
  class Page
5
5
  class Component
6
- class File < Common::Content::DoubleModel
6
+ class File < Ecoportal::API::Common::Content::DoubleModel
7
7
  class << self
8
8
  def new_doc
9
9
  {
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class V2
4
4
  class Page
5
5
  class Component
6
- class GaugeStop < Common::Content::DoubleModel
6
+ class GaugeStop < Ecoportal::API::Common::Content::DoubleModel
7
7
 
8
8
  class << self
9
9
  def new_doc
@@ -3,13 +3,13 @@ module Ecoportal
3
3
  class V2
4
4
  class Page
5
5
  class Component
6
- class GeoCoordinates < Common::Content::DoubleModel
6
+ class GeoCoordinates < Ecoportal::API::Common::Content::DoubleModel
7
7
  passthrough :lat, :lon
8
8
 
9
9
  def empty?
10
10
  !lat || !lon
11
11
  end
12
-
12
+
13
13
  def to_s
14
14
  "#{lat},#{lon}" if lat & lon
15
15
  end
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class V2
4
4
  class Page
5
5
  class Component
6
- class Image < Common::Content::DoubleModel
6
+ class Image < Ecoportal::API::Common::Content::DoubleModel
7
7
  class << self
8
8
  def new_doc
9
9
  {
@@ -12,7 +12,7 @@ module Ecoportal
12
12
  }
13
13
  end
14
14
  end
15
-
15
+
16
16
  passkey :id
17
17
  passforced :patch_ver, default: 1
18
18
  passthrough :weight
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class V2
4
4
  class Page
5
5
  class Component
6
- class Law < Common::Content::DoubleModel
6
+ class Law < Ecoportal::API::Common::Content::DoubleModel
7
7
 
8
8
  class << self
9
9
  def new_doc
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class V2
4
4
  class Page
5
5
  class Component
6
- class PeopleViewableField < Common::Content::DoubleModel
6
+ class PeopleViewableField < Ecoportal::API::Common::Content::DoubleModel
7
7
  passkey :id
8
8
  passthrough :type, read_only: true
9
9
  end
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class V2
4
4
  class Page
5
5
  class Component
6
- class SelectionOption < Common::Content::DoubleModel
6
+ class SelectionOption < Ecoportal::API::Common::Content::DoubleModel
7
7
  class << self
8
8
  def new_doc
9
9
  {
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class V2
4
4
  class Page
5
5
  class Component
6
- class SelectionOptions < Common::Content::CollectionModel
6
+ class SelectionOptions < Ecoportal::API::Common::Content::CollectionModel
7
7
  class_resolver :option_class, "Ecoportal::API::V2::Page::Component::SelectionOption"
8
8
 
9
9
  self.klass = :option_class
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Page
5
- class Component < Common::Content::DoubleModel
5
+ class Component < Ecoportal::API::Common::Content::DoubleModel
6
6
  extend Ecoportal::API::Common::Content::StringDigest
7
7
 
8
8
  class_resolver :tag_field_class, "Ecoportal::API::V2::Page::Component::TagField"
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Page
5
- class Components < Common::Content::CollectionModel
5
+ class Components < Ecoportal::API::Common::Content::CollectionModel
6
6
  class_resolver :component_class, "Ecoportal::API::V2::Page::Component"
7
7
 
8
8
  klass do |doc|
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class V2
4
4
  class Page
5
5
  class Force
6
- class Binding < Common::Content::DoubleModel
6
+ class Binding < Ecoportal::API::Common::Content::DoubleModel
7
7
  class << self
8
8
  def new_doc
9
9
  {
@@ -3,11 +3,11 @@ module Ecoportal
3
3
  class V2
4
4
  class Page
5
5
  class Force
6
- class Bindings < Common::Content::CollectionModel
6
+ class Bindings < Ecoportal::API::Common::Content::CollectionModel
7
7
  class_resolver :binding_class, "Ecoportal::API::V2::Page::Force::Binding"
8
8
 
9
- self.klass = :binding_class
10
- order_matters = true
9
+ self.klass = :binding_class
10
+ self.order_matters = true
11
11
 
12
12
  def ooze
13
13
  self._parent.ooze
@@ -4,7 +4,7 @@ module Ecoportal
4
4
  class V2
5
5
  class Page
6
6
  class Force
7
- class Helper < Common::Content::DoubleModel
7
+ class Helper < Ecoportal::API::Common::Content::DoubleModel
8
8
  class << self
9
9
  def new_doc
10
10
  {
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Page
5
- class Force < Common::Content::DoubleModel
5
+ class Force < Ecoportal::API::Common::Content::DoubleModel
6
6
  INITIAL_WEIGHT = 9999
7
7
 
8
8
  class << self
@@ -2,12 +2,12 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Page
5
- class Forces < Common::Content::CollectionModel
5
+ class Forces < Ecoportal::API::Common::Content::CollectionModel
6
6
  class_resolver :force_class, "Ecoportal::API::V2::Page::Force"
7
7
 
8
- self.klass = :force_class
9
- order_matters = true
10
- self.order_key = :weight
8
+ self.klass = :force_class
9
+ self.order_matters = true
10
+ self.order_key = :weight
11
11
 
12
12
  def ooze
13
13
  self._parent.ooze
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Page
5
- class MouldCounter < Common::Content::DoubleModel
5
+ class MouldCounter < Ecoportal::API::Common::Content::DoubleModel
6
6
  UID_REGEX = /^(?<prefix>.*?)(?<counter>\d+)(?<postfix>.*)$/i
7
7
  STR_LEN = 5
8
8
  BASE_NUM_STR = "0" * STR_LEN
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Page
5
- class PermissionFlags < Common::Content::DoubleModel
5
+ class PermissionFlags < Ecoportal::API::Common::Content::DoubleModel
6
6
  class << self
7
7
  def new_doc
8
8
  {
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Page
5
- class Permit < Common::Content::DoubleModel
5
+ class Permit < Ecoportal::API::Common::Content::DoubleModel
6
6
  class << self
7
7
  def new_doc
8
8
  {
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Page
5
- class Section < Common::Content::DoubleModel
5
+ class Section < Ecoportal::API::Common::Content::DoubleModel
6
6
  INITIAL_WEIGHT = 9999
7
7
 
8
8
  class << self
@@ -2,12 +2,12 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Page
5
- class Sections < Common::Content::CollectionModel
5
+ class Sections < Ecoportal::API::Common::Content::CollectionModel
6
6
  class_resolver :section_class, "Ecoportal::API::V2::Page::Section"
7
7
 
8
8
  self.klass = :section_class
9
9
  self.order_key = :weight
10
-
10
+
11
11
  def ooze
12
12
  self._parent.ooze
13
13
  end
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Page
5
- class Stage < Common::Content::DoubleModel
5
+ class Stage < Ecoportal::API::Common::Content::DoubleModel
6
6
  passkey :id
7
7
  passforced :patch_ver, default: 1
8
8
  passthrough :name, :ordering
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Page
5
- class Stages < Common::Content::CollectionModel
5
+ class Stages < Ecoportal::API::Common::Content::CollectionModel
6
6
  class_resolver :stage_class, "Ecoportal::API::V2::Page::Stage"
7
7
 
8
8
  self.klass = :stage_class
@@ -1,7 +1,7 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  class V2
4
- class Page < Common::Content::DoubleModel
4
+ class Page < Ecoportal::API::Common::Content::DoubleModel
5
5
  ALLOWED_KEYS = %w[
6
6
  id external_id patch_ver name template_id
7
7
  base_tags tags
@@ -4,7 +4,7 @@ module Ecoportal
4
4
  class Pages
5
5
  # @attr_reader page_id [String] the `id` of the new ooze.
6
6
  # @attr_reader active_stage_id [String] the active stage `id` of the new ooze.
7
- class PageCreateResponse < Common::Content::DoubleModel
7
+ class PageCreateResponse < Ecoportal::API::Common::Content::DoubleModel
8
8
  passthrough :page_id, :active_stage_id
9
9
  end
10
10
  end
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class V2
4
4
  class Pages
5
5
  class PageStage
6
- class Task < Common::Content::DoubleModel
6
+ class Task < Ecoportal::API::Common::Content::DoubleModel
7
7
  passkey :id
8
8
  passforced :patch_ver, default: 0
9
9
 
@@ -41,19 +41,23 @@ module Ecoportal
41
41
  type == 'review_page'
42
42
  end
43
43
 
44
- def complete!
45
- return mark_as_submit if fill_in?
46
- return mark_as_sign_off if review?
44
+ def complete!(force: false)
45
+ return mark_as_submit(force: force) if fill_in?
46
+ return mark_as_sign_off(force: force) if review?
47
47
  end
48
48
 
49
49
  private
50
50
 
51
- def mark_as_submit
52
- doc['submitted'] = true
51
+ def mark_as_submit(force: false)
52
+ return doc['submitted'] = true unless force
53
+
54
+ doc['forced_complete'] = true
53
55
  end
54
56
 
55
- def mark_as_sign_off
56
- doc['sign_off'] = true
57
+ def mark_as_sign_off(force: false)
58
+ return doc['sign_off'] = true unless force
59
+
60
+ doc['forced_complete'] = true
57
61
  end
58
62
  end
59
63
  end
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class V2
4
4
  class Pages
5
5
  class PageStage
6
- class Tasks < Common::Content::CollectionModel
6
+ class Tasks < Ecoportal::API::Common::Content::CollectionModel
7
7
  class_resolver :task_class, "Ecoportal::API::V2::Pages::PageStage::Task"
8
8
 
9
9
  self.klass = :task_class
@@ -66,13 +66,17 @@ module Ecoportal
66
66
  msg.empty?? true : msg
67
67
  end
68
68
 
69
- def mark_as_submit
70
- tasks.fill_in(active: true).each(&:complete!)
69
+ def mark_as_submit(force: false)
70
+ tasks.fill_in(active: true).each do |task|
71
+ task.complete!(force: force)
72
+ end
71
73
  end
72
74
  alias_method :submit!, :mark_as_submit
73
75
 
74
- def mark_as_sign_off
75
- tasks.review(active: true).each(&:complete!)
76
+ def mark_as_sign_off(force: false)
77
+ tasks.review(active: true).each do |task|
78
+ task.complete!(force: force)
79
+ end
76
80
  end
77
81
  alias_method :sign_off!, :mark_as_sign_off
78
82
  end
@@ -7,8 +7,8 @@ module Ecoportal
7
7
  #
8
8
  # @attr_reader client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
9
9
  class Stages
10
- extend Common::BaseClass
11
- include Common::Content::DocHelpers
10
+ extend Ecoportal::API::Common::BaseClass
11
+ include Ecoportal::API::Common::Content::DocHelpers
12
12
 
13
13
  class_resolver :page_stage_class, "Ecoportal::API::V2::Pages::PageStage"
14
14
 
@@ -1,12 +1,12 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  class V2
4
- # @attr_reader client [Common::Client] a `Common::Client` object that
5
- # holds the configuration of the api connection.
4
+ # @attr_reader client [Ecoportal::API::Common::Client] a `Ecoportal::API::Common::Client`
5
+ # object that holds the configuration of the api connection.
6
6
  class Pages
7
7
  STAGE_REX = /stages\/(?<sid>.*)/.freeze
8
- extend Common::BaseClass
9
- include Common::Content::DocHelpers
8
+ extend Ecoportal::API::Common::BaseClass
9
+ include Ecoportal::API::Common::Content::DocHelpers
10
10
 
11
11
  class_resolver :stages_class, "Ecoportal::API::V2::Pages::Stages"
12
12
  class_resolver :page_class, "Ecoportal::API::V2::Page"
@@ -15,7 +15,8 @@ module Ecoportal
15
15
 
16
16
  attr_reader :client
17
17
 
18
- # @param client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
18
+ # @param client [Ecoportal::API::Common::Client] a `Ecoportal::API::Common::Client` object that holds
19
+ # the configuration of the api connection.
19
20
  # @return [Schemas] an instance object ready to make schema api requests.
20
21
  def initialize(client)
21
22
  @client = client
@@ -39,7 +40,7 @@ module Ecoportal
39
40
 
40
41
  id = get_id(id)
41
42
  response = client.get("/pages/#{CGI.escape(id)}")
42
- wrapped = Common::Content::WrappedResponse.new(response, page_class)
43
+ wrapped = Ecoportal::API::Common::Content::WrappedResponse.new(response, page_class)
43
44
 
44
45
  return wrapped.result if wrapped.success?
45
46
 
@@ -77,7 +78,10 @@ module Ecoportal
77
78
  def get_new(from)
78
79
  id = get_id(from)
79
80
  response = client.get("/pages/new", params: {template_id: id})
80
- wrapped = Common::Content::WrappedResponse.new(response, page_stage_class)
81
+ wrapped = Ecoportal::API::Common::Content::WrappedResponse.new(
82
+ response,
83
+ page_stage_class
84
+ )
81
85
 
82
86
  return wrapped.result if wrapped.success?
83
87
  raise "Could not get new page from template #{id} - Error #{response.status}: #{response.body}"
@@ -99,9 +103,15 @@ module Ecoportal
99
103
  end
100
104
  end
101
105
  response = client.post("/pages", data: body, params: {template_id: id})
102
- wrapped = Common::Content::WrappedResponse.new(response, create_page_response_class)
106
+ wrapped = Ecoportal::API::Common::Content::WrappedResponse.new(
107
+ response,
108
+ create_page_response_class
109
+ )
103
110
  return wrapped.result if wrapped.success?
104
- raise "Could not create page from template #{id} - Error #{response.status}: #{response.body}"
111
+
112
+ msg = "Could not create page from template #{id} "
113
+ msg << "- Error #{response.status}: #{response.body}"
114
+ raise msg
105
115
  end
106
116
 
107
117
  private
@@ -1,7 +1,7 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  class V2
4
- # @attr_reader client [Common::Client] a `Common::Client` object that
4
+ # @attr_reader client [Ecoportal::API::Common::Client] a `Ecoportal::API::Common::Client` object that
5
5
  # holds the configuration of the api connection.
6
6
  class People < API::Internal::People
7
7
  def batch
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class V2
4
4
  class Registers
5
5
  class PageResult
6
- class MembraneDroplet < Common::Content::DoubleModel
6
+ class MembraneDroplet < Ecoportal::API::Common::Content::DoubleModel
7
7
  passkey :ref
8
8
  passthrough :label, :type, :value
9
9
  passthrough :field_configuration_id
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Registers
5
- class PageResult < Common::Content::DoubleModel
5
+ class PageResult < Ecoportal::API::Common::Content::DoubleModel
6
6
  passkey :id
7
7
  passthrough :template_id
8
8
  passthrough :name, :state
@@ -22,4 +22,4 @@ module Ecoportal
22
22
  end
23
23
  end
24
24
 
25
- require_relative 'page_result/membrane_droplet'
25
+ require 'ecoportal/api/v2/registers/page_result/membrane_droplet'
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Registers
5
- class Register < Common::Content::DoubleModel
5
+ class Register < Ecoportal::API::Common::Content::DoubleModel
6
6
  passkey :id
7
7
  passthrough :name
8
8
 
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Registers
5
- class SearchResults < Common::Content::DoubleModel
5
+ class SearchResults < Ecoportal::API::Common::Content::DoubleModel
6
6
  passthrough :total, :total_before_filtering
7
7
  passarray :tags, order_matters: false
8
8
  embeds_many :results, klass: "Ecoportal::API::V2::Registers::PageResult"
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Registers
5
- class StageResult < Common::Content::DoubleModel
5
+ class StageResult < Ecoportal::API::Common::Content::DoubleModel
6
6
  passkey :id
7
7
  passthrough :name, :state, :complete, :ordering
8
8
  passarray :tags, order_matters: false
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class V2
4
4
  class Registers
5
- class Template < Common::Content::DoubleModel
5
+ class Template < Ecoportal::API::Common::Content::DoubleModel
6
6
  passkey :id
7
7
  passthrough :name
8
8
  end
@@ -2,12 +2,12 @@ require 'base64'
2
2
  module Ecoportal
3
3
  module API
4
4
  class V2
5
- # @attr_reader client [Common::Client] a `Common::Client` object that
5
+ # @attr_reader client [Ecoportal::API::Common::Client] a `Ecoportal::API::Common::Client` object that
6
6
  # holds the configuration of the api connection.
7
7
  class Registers
8
- extend Common::BaseClass
8
+ extend Ecoportal::API::Common::BaseClass
9
+ include Ecoportal::API::Common::Content::DocHelpers
9
10
  include Enumerable
10
- include Common::Content::DocHelpers
11
11
 
12
12
  class_resolver :register_class, "Ecoportal::API::V2::Registers::Register"
13
13
  class_resolver :register_search_result_class, "Ecoportal::API::V2::Registers::PageResult"
@@ -15,7 +15,7 @@ module Ecoportal
15
15
 
16
16
  attr_reader :client
17
17
 
18
- # @param client [Common::Client] a `Common::Client` object that
18
+ # @param client [Ecoportal::API::Common::Client] a `Ecoportal::API::Common::Client` object that
19
19
  # holds the configuration of the api connection.
20
20
  # @return [Registers] an instance object ready to make registers api requests.
21
21
  def initialize(client)
@@ -32,7 +32,7 @@ module Ecoportal
32
32
  # @return [Enumerable<Register>] an `Enumerable` with all schemas already wrapped as `Register` objects.
33
33
  def get
34
34
  response = client.get("/templates")
35
- Common::Content::WrappedResponse.new(
35
+ Ecoportal::API::Common::Content::WrappedResponse.new(
36
36
  response,
37
37
  register_class,
38
38
  key: "registers"
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class V2
4
4
  class S3
5
5
  class Files
6
- class Poll < Common::Content::DoubleModel
6
+ class Poll < Ecoportal::API::Common::Content::DoubleModel
7
7
  passthrough :poll_url
8
8
  embeds_one :status, nullable: true, klass: "Ecoportal::API::V2::S3::Files::PollStatus"
9
9
 
@@ -3,8 +3,8 @@ module Ecoportal
3
3
  class V2
4
4
  class S3
5
5
  class Files
6
- class PollStatus < Common::Content::DoubleModel
7
- class FileContainer < Common::Content::DoubleModel
6
+ class PollStatus < Ecoportal::API::Common::Content::DoubleModel
7
+ class FileContainer < Ecoportal::API::Common::Content::DoubleModel
8
8
  passkey :id
9
9
  passthrough :file_container_id # same as :id :)
10
10
  passthrough :name, :label
@@ -1,14 +1,14 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  class V2
4
- # @attr_reader client [Common::Client] a `Common::Client` object that
4
+ # @attr_reader client [Ecoportal::API::Common::Client] a `Ecoportal::API::Common::Client` object that
5
5
  # holds the configuration of the api connection.
6
6
  class S3
7
7
  class Files
8
8
  class FailedPollRequest < StandardError; end
9
9
  class CantCheckStatus < StandardError; end
10
10
 
11
- extend Common::BaseClass
11
+ extend Ecoportal::API::Common::BaseClass
12
12
 
13
13
  POLL_TIMEOUT = 240
14
14
  DELAY_STATUS_CHECK = 5
@@ -18,7 +18,8 @@ module Ecoportal
18
18
 
19
19
  attr_reader :client, :s3_api
20
20
 
21
- # @param client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
21
+ # @param client [Ecoportal::API::Common::Client] a `Ecoportal::API::Common::Client`
22
+ # object that holds the configuration of the api connection.
22
23
  # @param s3_api [V2::S3] the parent S3 api object.
23
24
  # @return [Schemas] an instance object ready to make schema api requests.
24
25
  def initialize(client, s3_api:)
@@ -1,19 +1,20 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  class V2
4
- # @attr_reader client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
4
+ # @attr_reader client [Ecoportal::API::Common::Client] a `Ecoportal::API::Common::Client` object that holds the configuration of the api connection.
5
5
  class S3
6
6
  class MissingLocalFile < ArgumentError; end
7
7
  class CredentialsGetFailed < StandardError; end
8
8
 
9
- extend Common::BaseClass
9
+ extend Ecoportal::API::Common::BaseClass
10
10
 
11
11
  class_resolver :data_class, "Ecoportal::API::V2::S3::Data"
12
12
  class_resolver :files_class, "Ecoportal::API::V2::S3::Files"
13
13
 
14
14
  attr_reader :client
15
15
 
16
- # @param client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
16
+ # @param client [Ecoportal::API::Common::Client] a `Ecoportal::API::Common::Client`
17
+ # object that holds the configuration of the api connection.
17
18
  # @return [Schemas] an instance object ready to make schema api requests.
18
19
  def initialize(client)
19
20
  @client = client
@@ -5,8 +5,13 @@ module Ecoportal
5
5
  # @attr_reader client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
6
6
  # @attr_reader logger [Logger] the logger.
7
7
  class V2
8
- extend Common::BaseClass
9
- include Common::Logging
8
+ unless Ecoportal::API.const_defined?(:GEM2_VERSION)
9
+ msg = "Correct way to require this gem is `require 'ecoportal/api-v2`"
10
+ raise LoadError, msg
11
+ end
12
+
13
+ extend Ecoportal::API::Common::BaseClass
14
+ include Ecoportal::API::Common::Logging
10
15
 
11
16
  VERSION = "v2".freeze
12
17
 
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- GEM2_VERSION = '2.0.5'.freeze
3
+ GEM2_VERSION = '2.0.9'.freeze
4
4
  end
5
5
  end
@@ -6,5 +6,6 @@ module Ecoportal
6
6
  end
7
7
  end
8
8
 
9
- require_relative "api/common.v2"
10
- require_relative "api/v2"
9
+ require 'ecoportal/api/v2_version'
10
+ require 'ecoportal/api/common.v2'
11
+ require 'ecoportal/api/v2'
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecoportal-api-v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-07 00:00:00.000000000 Z
11
+ date: 2024-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.14'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.14'
27
27
  - !ruby/object:Gem::Dependency