ecoportal-api-oozes 0.7.4 → 0.7.5

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 (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/README.md +2 -0
  4. data/ecoportal-api-oozes.gemspec +7 -0
  5. data/lib/ecoportal/api/common/content/class_helpers.rb +35 -0
  6. data/lib/ecoportal/api/common/content/hash_diff_patch.rb +2 -3
  7. data/lib/ecoportal/api/common/content/wrapped_response.rb +1 -1
  8. data/lib/ecoportal/api/v2.rb +12 -2
  9. data/lib/ecoportal/api/v2/page/component.rb +13 -5
  10. data/lib/ecoportal/api/v2/page/component/chart_field/frequency.rb +3 -3
  11. data/lib/ecoportal/api/v2/page/component/chart_field/heatmap.rb +1 -1
  12. data/lib/ecoportal/api/v2/page/component/chart_field/indicator.rb +2 -2
  13. data/lib/ecoportal/api/v2/page/component/chart_field/multiseries.rb +2 -2
  14. data/lib/ecoportal/api/v2/page/component/chart_field/sankey.rb +2 -2
  15. data/lib/ecoportal/api/v2/page/component/chart_field/serie.rb +1 -1
  16. data/lib/ecoportal/api/v2/page/component/chart_fr_field.rb +1 -1
  17. data/lib/ecoportal/api/v2/page/component/images_field.rb +10 -0
  18. data/lib/ecoportal/api/v2/page/component/signature_field.rb +11 -0
  19. data/lib/ecoportal/api/v2/page/stages.rb +6 -0
  20. data/lib/ecoportal/api/v2/pages.rb +17 -15
  21. data/lib/ecoportal/api/v2/pages/page_stage.rb +6 -1
  22. data/lib/ecoportal/api/v2/pages/stages.rb +4 -1
  23. data/lib/ecoportal/api/v2/people.rb +31 -0
  24. data/lib/ecoportal/api/v2/registers.rb +60 -6
  25. data/lib/ecoportal/api/v2/registers/page_result.rb +21 -0
  26. data/lib/ecoportal/api/v2/registers/register.rb +37 -0
  27. data/lib/ecoportal/api/v2/registers/stage_result.rb +14 -0
  28. data/lib/ecoportal/api/v2/registers/stages_result.rb +13 -0
  29. data/lib/ecoportal/api/v2/registers/template.rb +12 -0
  30. data/lib/ecoportal/api/v2/version.rb +1 -1
  31. metadata +12 -6
  32. data/lib/ecoportal/api/v2/register.rb +0 -36
  33. data/lib/ecoportal/api/v2/template.rb +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6039e6c6b1c32fcbcd956ef9a425588cbd9dfe94d06898223af14f433bab2c3a
4
- data.tar.gz: c4dca6d50e4a664d343942636079f7c3cfe11999502ca891e8cf1f8598ed79f3
3
+ metadata.gz: 5929f4395b13bbc49387e6df11b391d868533454b9c4e7a8a82059471dcc0c3e
4
+ data.tar.gz: 3dec1899afedfa10558c61cd24e3d2e2717bcaa2173284c960b93e1317ba74c8
5
5
  SHA512:
6
- metadata.gz: 91f9c47478b1054e0efb2380bb623c951d751f10c24a833b7fd380ddaa35bdc825b42b5574f23524accfc0e10ba692857c0597be9805cde1acede6d5959b0730
7
- data.tar.gz: 2106b17efa000c7d1b44ce667bf3d80fe84a4c59bb7c0772cc8d19396e5fa024e39fc7823064e9531ac9c82037be3bfdc17e8827ae41ae1bdb7b648c15d52abe
6
+ metadata.gz: 5ddfa85f7e4a424b421ef9f4163d7d3f97dc4f25c049bb04e8971472efb3fdc9857ba4b3d0cde701b09e8bb6add6bdb0c046be7e6609b8c6985e8fff36397c04
7
+ data.tar.gz: 99459754a151c61633212238c23d77cfc0fb3999ca5bf4fd5be6ee01219399f8d32fbc9b16b66fb84678fca4623edcaa1ebcd7d2a4a52b09f643111ab897f7c9
data/CHANGELOG.md CHANGED
@@ -1,6 +1,29 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.7.5] - 2021-02-xx
5
+
6
+ ### Added
7
+ - `Ecoportal::API::Common::ClassHelpers` added inheritable attribute values
8
+ - `Ecoportal::API::V2::Pages::PageStage` added missing properties
9
+ - `Ecoportal::API::V2::Page::Stages#ordered_stages` method to obtain stages in order
10
+ - `Ecoportal::API::V2::Registers#search` method search pages in the register, which includes new classes:
11
+ - `Ecoportal::API::V2::Registers::PageResult`
12
+ - `Ecoportal::API::V2::Registers::StagesResult`
13
+ - `Ecoportal::API::V2::Registers::StageResult`
14
+ - `Ecoportal::API::V2::Pages#get` added parameter `stage_id:` to be able to directly obtain the stage
15
+
16
+ ### Changed
17
+ - Moved some classes to the new namespace `Ecoportal::API::V2::Registers`
18
+ - `Ecoportal::API::V2::Registers::Register`
19
+ - `Ecoportal::API::V2::Registers::Template`
20
+
21
+ ### Fixed
22
+ - `Ecoportal::API::Common::Content::HashDiffPatch`: `deleted` operation wording and `data.patch_ver`
23
+ - `Ecoportal::API::V2::Page::Component.new_doc` should delegate to child classes that have their own implementation
24
+ - `Ecoportal::API::V2::Page::Component::ImagesField.new_doc` should include `layout`
25
+ - `Ecoportal::API::V2::Page::Component::SignatureField.new_doc` should include `color`
26
+
4
27
  ## [0.7.4] - 2021-02-12
5
28
 
6
29
  ### Added
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ **Moved to ---> 'ecoportal-api-v2'**
2
+
1
3
  # Ecoportal::API::V2
2
4
 
3
5
  This is a basic collection of helpers that can be used to interact with the
@@ -13,6 +13,8 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://www.ecoportal.com"
14
14
  spec.licenses = %w[MIT]
15
15
 
16
+ spec.required_ruby_version = '>= 2.4.4'
17
+
16
18
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
19
  f.match(%r{^(test|spec|features)/})
18
20
  end
@@ -28,4 +30,9 @@ Gem::Specification.new do |spec|
28
30
  spec.add_development_dependency "pry"
29
31
 
30
32
  spec.add_dependency 'ecoportal-api', '>= 0.7.4', '< 0.8'
33
+
34
+ spec.post_install_message = %{
35
+ The 'ecoportal-api-oozes' gem has been deprecated and has been replaced by 'ecoportal-api-v2'.
36
+ See: https://rubygems.org/gems/ecoportal-api-v2
37
+ }
31
38
  end
@@ -104,6 +104,41 @@ module Ecoportal
104
104
  val != NOT_USED
105
105
  end
106
106
 
107
+ # Keeps track on class instance variables that should be inherited by child classes.
108
+ # @note
109
+ # - subclasses will inherit the value as is at that moment
110
+ # - any change afterwards will be only on the specific class (in line with class instance variables)
111
+ # - adapted from https://stackoverflow.com/a/10729812/4352306
112
+ # TODO: this separates the logic of the method to the instance var. Think if would be possible to join them somehow.
113
+ def inheritable_class_vars(*vars)
114
+ @inheritable_class_vars ||= [:inheritable_class_vars]
115
+ @inheritable_class_vars += vars
116
+ end
117
+
118
+ # Builds the attr_reader and attr_writer of `attrs` and registers the associated instance variable as inheritable.
119
+ def inheritable_attrs(*attrs)
120
+ attrs.each do |attr|
121
+ class_eval %(
122
+ class << self; attr_accessor :#{attr} end
123
+ )
124
+ end
125
+ inheritable_class_vars(*attrs)
126
+ end
127
+
128
+ # This callback method is called whenever a subclass of the current class is created.
129
+ # @note
130
+ # - values of the instance variables are copied as they are (no dups or clones)
131
+ # - the above means: avoid methods that change the state of the mutable object on it
132
+ # - mutating methods would reflect the changes on other classes as well
133
+ # - therefore, `freeze` will be called on the values that are inherited.
134
+ def inherited(subclass)
135
+ inheritable_class_vars.each do |var|
136
+ instance_var = instance_variable_name(var)
137
+ value = instance_variable_get(instance_var)
138
+ subclass.instance_variable_set(instance_var, value.freeze)
139
+ end
140
+ end
141
+
107
142
  end
108
143
  end
109
144
  end
@@ -88,10 +88,9 @@ module Ecoportal
88
88
  return NO_CHANGES unless b.is_a?(Hash) && id = get_id(b, exception: false)
89
89
  {
90
90
  "id" => id,
91
- "operation" => "delete"
91
+ "operation" => "deleted",
92
+ "data" => patch_data(b, delete: true)
92
93
  }
93
- #,
94
- #{}"data" => patch_data(b, delete: true)
95
94
  end
96
95
 
97
96
  def patch_new(a)
@@ -27,7 +27,7 @@ module Ecoportal
27
27
  def data
28
28
  return @data if instance_variable_defined?(:@data)
29
29
  @data = (response.body || {})["data"]
30
- @data = @data[key] if @key && @data
30
+ @data = @data[@key] if @key && @data
31
31
  @data
32
32
  end
33
33
 
@@ -19,6 +19,7 @@ module Ecoportal
19
19
  end
20
20
  end
21
21
 
22
+ class_resolver :people_class, "Ecoportal::API::V2::People"
22
23
  class_resolver :registers_class, "Ecoportal::API::V2::Registers"
23
24
  class_resolver :pages_class, "Ecoportal::API::V2::Pages"
24
25
 
@@ -26,7 +27,9 @@ module Ecoportal
26
27
 
27
28
  # Creates an `V2` object to scope version specific api requests.
28
29
  # @note
29
- # - you should use either `api_key` or `user_key` and `org_key`
30
+ # - You should use either `api_key` or `user_key` and `org_key`
31
+ # - The const `VERSION` determineds the api version that client will query against.
32
+ # - This means that each subclass of `V2` should define their own `VERSION` constant.
30
33
  # @param api_key [String] the key version to stablish the api connection.
31
34
  # @param user_key [String] the user key used for the api connection (requires `org_key`).
32
35
  # @param org_key [String] the org key used for the api connection (requires `user_key`).
@@ -43,6 +46,12 @@ module Ecoportal
43
46
  )
44
47
  end
45
48
 
49
+ # Obtain specific object for people api requests.
50
+ # @return [People] an instance object ready to make people api requests.
51
+ def people
52
+ people_class.new(client)
53
+ end
54
+
46
55
  # Obtain specific object for schema api requests.
47
56
  # @return [Registers] an instance object ready to make registers api requests.
48
57
  def registers
@@ -68,5 +77,6 @@ module Ecoportal
68
77
  end
69
78
  end
70
79
 
71
- require 'ecoportal/api/v2/registers'
80
+ require 'ecoportal/api/v2/people'
72
81
  require 'ecoportal/api/v2/pages'
82
+ require 'ecoportal/api/v2/registers'
@@ -25,11 +25,14 @@ module Ecoportal
25
25
  class_resolver :chart_fr_field_class, "Ecoportal::API::V2::Page::Component::ChartFrField"
26
26
 
27
27
  class << self
28
- def new_doc(type:)
29
- {
30
- "id" => new_uuid,
31
- "type" => type
32
- }
28
+ def new_doc(type: nil)
29
+ if type
30
+ type_doc = {"type" => type}
31
+ base_doc = get_class(type_doc)&.new_doc || {}
32
+ base_doc.merge!(type_doc)
33
+ end
34
+ return base_doc if base_doc&.key?("id")
35
+ (base_doc || {}).merge("id" => new_uuid)
33
36
  end
34
37
 
35
38
  def get_class(doc)
@@ -84,6 +87,11 @@ module Ecoportal
84
87
  passthrough :type, :label, :tooltip, :global_binding
85
88
  passthrough :hidden, :accent, :deindex, :required
86
89
  passthrough :hide_view, :hidden_on_reports, :hidden_on_mobile
90
+ passarray :refs
91
+
92
+ def ref_backend
93
+ refs.first
94
+ end
87
95
 
88
96
  def ref
89
97
  if digest = self.class.hash_label(label)
@@ -10,16 +10,16 @@ module Ecoportal
10
10
  passthrough :register_id, :source_type
11
11
 
12
12
  passthrough :mode, :input
13
- passarray :tags
13
+ passarray :tags, order_matters: false
14
14
  passthrough :secondary
15
15
 
16
16
  passthrough :output, :bar_mode
17
17
  passthrough :series_size, :skip_zeroes
18
18
 
19
- passarray :filters, :people_filters, :task_filters
19
+ passarray :filters, :people_filters, :task_filters, order_matters: false
20
20
 
21
21
  passthrough :color
22
- passarray :color_map
22
+ passarray :color_map, order_matters: false
23
23
  end
24
24
  end
25
25
  end
@@ -15,7 +15,7 @@ module Ecoportal
15
15
 
16
16
  passthrough :bucket_type
17
17
 
18
- passarray :filters, :people_filters, :task_filters
18
+ passarray :filters, :people_filters, :task_filters, order_matters: false
19
19
 
20
20
  passthrough :color
21
21
  end
@@ -11,10 +11,10 @@ module Ecoportal
11
11
 
12
12
  passthrough :date_input, :secondary
13
13
  passthrough :duration, :math_mode, :currency
14
-
14
+
15
15
  passthrough :display_previous, :change_format, :invert_colors
16
16
 
17
- passarray :filters, :people_filters, :task_filters
17
+ passarray :filters, :people_filters, :task_filters, order_matters: false
18
18
 
19
19
  passthrough :color
20
20
  end
@@ -11,13 +11,13 @@ module Ecoportal
11
11
 
12
12
  passthrough :xinput, :xlabel
13
13
  passthrough :interval, :calc_mode
14
-
14
+
15
15
  passthrough :yinput, :ylabel
16
16
  passthrough :facet_by_discrete, :discrete_facet
17
17
  passthrough :facet_by_tags
18
18
  passarray :facet_tags
19
19
 
20
- passarray :filters, :people_filters, :task_filters
20
+ passarray :filters, :people_filters, :task_filters, order_matters: false
21
21
 
22
22
  passthrough :display_mode, :display_type
23
23
  passthrough :color
@@ -14,10 +14,10 @@ module Ecoportal
14
14
  passthrough :zinput, :zmode
15
15
  passarray :xtags, :ytags, :ztags
16
16
 
17
- passarray :filters, :people_filters, :task_filters
17
+ passarray :filters, :people_filters, :task_filters, order_matters: false
18
18
 
19
19
  passthrough :color
20
- passarray :color_map
20
+ passarray :color_map, order_matters: false
21
21
  end
22
22
  end
23
23
  end
@@ -14,7 +14,7 @@ module Ecoportal
14
14
 
15
15
  passthrough :visual, :stacked
16
16
 
17
- passarray :filters, :people_filters, :task_filters
17
+ passarray :filters, :people_filters, :task_filters, order_matters: false
18
18
 
19
19
  passthrough :color
20
20
  end
@@ -20,7 +20,7 @@ module Ecoportal
20
20
  passthrough :multiplier, :granularity
21
21
 
22
22
  passthrough :color
23
- passarray :color_map
23
+ passarray :color_map, order_matters: false
24
24
 
25
25
  passthrough :chart_user
26
26
 
@@ -4,6 +4,16 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class ImagesField < Page::Component
7
+
8
+ class << self
9
+ def new_doc
10
+ {
11
+ "layout" => "third"
12
+ }
13
+ end
14
+ end
15
+
16
+ passthrough :layout, :strech, :no_popup, :hide_options
7
17
  embeds_many :images, klass: "Ecoportal::API::V2::Page::Image", order_key: :weight
8
18
  end
9
19
  end
@@ -4,8 +4,19 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class SignatureField < Page::Component
7
+
8
+ class << self
9
+ def new_doc
10
+ {
11
+ "color" => "#000000"
12
+ }
13
+ end
14
+ end
15
+
7
16
  passthrough :signed_by_id, :signed_by_name, :signature_url
8
17
  passdate :signature_updated_at
18
+ passthrough :signature_content, :color
19
+
9
20
  end
10
21
  end
11
22
  end
@@ -13,6 +13,12 @@ module Ecoportal
13
13
  end
14
14
  end
15
15
 
16
+ def ordered_stages
17
+ stages.each_with_index.sort_by do |stage, index|
18
+ (stage.ordering >= 9999) ? [index, index] : [stage.ordering, index]
19
+ end.map(&:first)
20
+ end
21
+
16
22
  end
17
23
  end
18
24
  end
@@ -28,22 +28,33 @@ module Ecoportal
28
28
  # @note
29
29
  # - if the request has `success?` the returned `object.result` gives an object with that `Page`.
30
30
  # - if it failed to obtain the full page, it returns a `PageStage` with the active stage data.
31
- # @param doc [String, Hash, Page] data containing an `id` of the target page.
31
+ # @param id [String, Hash, Stage] the `id` of the target **page**.
32
+ # @param stage_id [String] the `id` of the target **stage**.
32
33
  # @return [Ecoportal::API::V2::Page, Ecoportal::API::V2::Pages::PageStage] the target page.
33
- def get(doc)
34
- pid = get_id(doc)
35
- response = client.get("/pages/#{CGI.escape(pid)}")
34
+ def get(id, stage_id: nil)
35
+ return stages.get(pid: id, sid: stage_id) if stage_id
36
+ id = get_id(id)
37
+ response = client.get("/pages/#{CGI.escape(id)}")
36
38
  wrapped = Common::Content::WrappedResponse.new(response, page_class)
37
39
 
38
40
  return wrapped.result if wrapped.success?
39
41
  if (response.status == 302) && (url = response.body["data"])
40
- if sid = url_to_stage_id(url)
41
- return stages.get(pid: pid, sid: sid)
42
+ if stage_id = url_to_stage_id(url)
43
+ return stages.get(pid: id, sid: stage_id)
42
44
  end
43
45
  end
44
46
  raise "Could not get page #{pid} - Error #{response.status}: #{response.body}"
45
47
  end
46
48
 
49
+ # Requests to update an existing page via api.
50
+ # @param doc [Hash, Page] data that at least contains an `id` (internal or external) of the target page.
51
+ # @return [Response] an object with the api response.
52
+ def update(doc)
53
+ body = get_body(doc) # , level: "page"
54
+ id = get_id(doc)
55
+ client.patch("/pages/#{CGI.escape(id)}", data: body)
56
+ end
57
+
47
58
  # Gets a `new` non-existing page via api with all the ids initialized.
48
59
  # @param from [String, Hash, Page] template or `id` of the template
49
60
  # @return [Ecoportal::API::V2::Page] the new page object.
@@ -66,15 +77,6 @@ module Ecoportal
66
77
  client.post("/pages", data: body, params: {template_id: id})
67
78
  end
68
79
 
69
- # Requests to update an existing page via api.
70
- # @param doc [Hash, Page] data that at least contains an `id` (internal or external) of the target page.
71
- # @return [Response] an object with the api response.
72
- def update(doc)
73
- body = get_body(doc) # , level: "page"
74
- id = get_id(doc)
75
- client.patch("/pages/#{CGI.escape(id)}", data: body)
76
- end
77
-
78
80
  private
79
81
 
80
82
  def url_to_stage_id(url)
@@ -3,7 +3,12 @@ module Ecoportal
3
3
  class V2
4
4
  class Pages
5
5
  class PageStage < V2::Page
6
-
6
+ passthrough :mould_counter, :archive
7
+ passthrough :task_priority, :state
8
+ passthrough :votes_enabled, :upvotes, :downvotes
9
+
10
+ passarray :force_errors, :subtags, :permits, order_matters: false
11
+ passthrough :evolution
7
12
  end
8
13
  end
9
14
  end
@@ -22,7 +22,8 @@ module Ecoportal
22
22
 
23
23
  # Gets a stage via api.
24
24
  # @note if the request has `success?` the returned `object.result` gives an object with that `Stage`.
25
- # @param doc [String, Hash, Stage] data containing an `id` of the target page.
25
+ # @param pid [String, Hash, Stage] the `id` of the target **page**.
26
+ # @param sid [String] the `id` of the target **stage**.
26
27
  # @return [Ecoportal::API::V2::Stage, Ecoportal::API::V2::Pages::PageStage] the target stage.
27
28
  def get(pid:, sid:)
28
29
  pid = get_id(pid)
@@ -35,6 +36,8 @@ module Ecoportal
35
36
 
36
37
  # Requests to update an existing stage via api.
37
38
  # @param doc [Hash, Stage] data that at least contains an `id` (internal or external) of the target stage.
39
+ # @param pid [String, nil] the `id` of the target **page**.
40
+ # @param sid [String] the `id` of the target **stage**.
38
41
  # @return [Response] an object with the api response.
39
42
  def update(doc, pid: nil, sid:)
40
43
  body = get_body(doc)
@@ -0,0 +1,31 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ # @attr_reader client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
5
+ class People < Internal::People
6
+
7
+ def batch
8
+ unavailable_method!(__method__)
9
+ end
10
+
11
+ def job
12
+ unavailable_method!(__method__)
13
+ end
14
+
15
+ private
16
+
17
+ # Re-using hook to obtain the raw data response
18
+ def body_data(body)
19
+ return body unless body.is_a?(Hash)
20
+ return body unless body.key?("data")
21
+ body["data"]
22
+ end
23
+
24
+ def unavailable_method!(str)
25
+ raise "Unavailable method '#{str}' for api '#{VERSION}'"
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,20 +1,28 @@
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
5
  class Registers
5
6
  extend Common::BaseClass
6
7
  include Enumerable
8
+ include Common::Content::DocHelpers
7
9
 
8
- class_resolver :register_class, "Ecoportal::API::V2::Register"
10
+ class_resolver :register_class, "Ecoportal::API::V2::Registers::Register"
11
+ class_resolver :register_search_result_class, "Ecoportal::API::V2::Registers::PageResult"
9
12
 
10
13
  attr_reader :client
11
14
 
12
15
  # @param client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
13
- # @return [Schemas] an instance object ready to make schema api requests.
16
+ # @return [Registers] an instance object ready to make registers api requests.
14
17
  def initialize(client)
15
18
  @client = client
16
19
  end
17
20
 
21
+ def each(params: {}, &block)
22
+ return to_enum(:each) unless block
23
+ get.each(&block)
24
+ end
25
+
18
26
  # Gets all the registers via api request.
19
27
  # @return [Enumerable<Register>] an `Enumerable` with all schemas already wrapped as `Register` objects.
20
28
  def get
@@ -22,14 +30,60 @@ module Ecoportal
22
30
  Common::Content::WrappedResponse.new(response, register_class, key: "registers")
23
31
  end
24
32
 
25
- def each(params: {}, &block)
26
- return to_enum(:each) unless block
27
- get.each(&block)
33
+ # Gets all the oozes/pages of `register_id` matching the `options`
34
+ # @param register_id [String] the `id` of the target register to search on.
35
+ # @param options [Hash] the search options
36
+ # @option options [Hash<Symbol, String>] :query plain search (like the search box in register).
37
+ # @option options [Hash<Symbol, Array<Object>>] :filters the set of filters.
38
+ def search(register_id, options = {})
39
+ # supply a query string
40
+ # or a filter array (copy/paste from dev tools in the browser)
41
+ options = {query: nil, filters: []}.update(options)
42
+ options = {}.tap do |ret|
43
+ options.each do |key, value|
44
+ if key == :filters && value.any?
45
+ ret[key] = {filters: value}.to_json
46
+ else
47
+ ret[key] = value if key
48
+ end
49
+ end
50
+ end
51
+
52
+ cursor_id = nil
53
+ results = 0
54
+ loop do
55
+ options.update(cursor_id: cursor_id) if cursor_id
56
+ response = client.get("/registers/#{register_id}/search", params: options)
57
+ raise "Request failed - Status #{response.status}: #{response.body}" unless response.success?
58
+
59
+ data = response.body["data"]
60
+ unless (total = data["total"]) == 0
61
+ results += data["results"].length
62
+ percent = results * 100 / total
63
+ msg = "Registers SEARCH"
64
+ print "#{msg}: #{percent.round}% (of #{total})\r"
65
+ $stdout.flush
66
+ end
67
+
68
+ data["results"].each do |result|
69
+ object = register_search_result_class.new(result)
70
+ yield object
71
+ end
72
+
73
+ # break unless (cursor_id = data["cursor_id"])
74
+ break if total == results
75
+ end
76
+ self
28
77
  end
29
78
 
79
+
30
80
  end
31
81
  end
32
82
  end
33
83
  end
34
84
 
35
- require 'ecoportal/api/v2/register'
85
+ require 'ecoportal/api/v2/registers/template'
86
+ require 'ecoportal/api/v2/registers/register'
87
+ require 'ecoportal/api/v2/registers/stage_result'
88
+ require 'ecoportal/api/v2/registers/stages_result'
89
+ require 'ecoportal/api/v2/registers/page_result'
@@ -0,0 +1,21 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Registers
5
+ class PageResult < Common::Content::DoubleModel
6
+ passkey :id
7
+ passthrough :template_id
8
+ passthrough :name, :state
9
+ passdate :updated_at, :created_at
10
+ passthrough :archive
11
+ passarray :tags, order_matters: false
12
+ passthrough :mould_counter
13
+
14
+ class_resolver :stages_class, "Ecoportal::API::V2::Registers::StagesResult"
15
+ embeds_many :stages, enum_class: :stages_class
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,37 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Registers
5
+ class Register < Common::Content::DoubleModel
6
+ passkey :id
7
+ passthrough :name
8
+
9
+ class_resolver :template_class, "Ecoportal::API::V2::Registers::Template"
10
+
11
+ def templates_by_id
12
+ @templates_by_id or index_templates
13
+ @templates_by_id
14
+ end
15
+
16
+ def [](id)
17
+ templates_by_id[id]
18
+ end
19
+
20
+ def templates
21
+ templates_by_id.values
22
+ end
23
+
24
+ def index_templates
25
+ @templates_by_id = {}
26
+ doc["templates"].each do |template_doc|
27
+ template = template_class.new(template_doc)
28
+ @templates_by_id[template.id] = template
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,14 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Registers
5
+ class StageResult < Common::Content::DoubleModel
6
+ passkey :id
7
+ passthrough :name, :state, :complete, :ordering
8
+ passarray :tags, order_matters: false
9
+ passarray :permits
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Registers
5
+ class StagesResult < V2::Page::Stages
6
+ class_resolver :stage_class, "Ecoportal::API::V2::Registers::StageResult"
7
+
8
+ self.klass = :stage_class
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Registers
5
+ class Template < Common::Content::DoubleModel
6
+ passkey :id
7
+ passthrough :name
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,7 +1,7 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  class V2
4
- GEM_VERSION = "0.7.4"
4
+ GEM_VERSION = "0.7.5"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecoportal-api-oozes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-12 00:00:00.000000000 Z
11
+ date: 2021-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -220,15 +220,21 @@ files:
220
220
  - lib/ecoportal/api/v2/pages.rb
221
221
  - lib/ecoportal/api/v2/pages/page_stage.rb
222
222
  - lib/ecoportal/api/v2/pages/stages.rb
223
- - lib/ecoportal/api/v2/register.rb
223
+ - lib/ecoportal/api/v2/people.rb
224
224
  - lib/ecoportal/api/v2/registers.rb
225
- - lib/ecoportal/api/v2/template.rb
225
+ - lib/ecoportal/api/v2/registers/page_result.rb
226
+ - lib/ecoportal/api/v2/registers/register.rb
227
+ - lib/ecoportal/api/v2/registers/stage_result.rb
228
+ - lib/ecoportal/api/v2/registers/stages_result.rb
229
+ - lib/ecoportal/api/v2/registers/template.rb
226
230
  - lib/ecoportal/api/v2/version.rb
227
231
  homepage: https://www.ecoportal.com
228
232
  licenses:
229
233
  - MIT
230
234
  metadata: {}
231
- post_install_message:
235
+ post_install_message: "\n The 'ecoportal-api-oozes' gem has been deprecated and
236
+ has been replaced by 'ecoportal-api-v2'.\n See: https://rubygems.org/gems/ecoportal-api-v2\n
237
+ \ "
232
238
  rdoc_options: []
233
239
  require_paths:
234
240
  - lib
@@ -236,7 +242,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
236
242
  requirements:
237
243
  - - ">="
238
244
  - !ruby/object:Gem::Version
239
- version: '0'
245
+ version: 2.4.4
240
246
  required_rubygems_version: !ruby/object:Gem::Requirement
241
247
  requirements:
242
248
  - - ">="
@@ -1,36 +0,0 @@
1
- module Ecoportal
2
- module API
3
- class V2
4
- class Register < Common::Content::DoubleModel
5
- passkey :id
6
- passthrough :name
7
-
8
- class_resolver :template_class, "Ecoportal::API::V2::Template"
9
-
10
- def templates_by_id
11
- @templates_by_id or index_templates
12
- @templates_by_id
13
- end
14
-
15
- def [](id)
16
- templates_by_id[id]
17
- end
18
-
19
- def templates
20
- templates_by_id.values
21
- end
22
-
23
- def index_templates
24
- @templates_by_id = {}
25
- doc["templates"].each do |template_doc|
26
- template = template_class.new(template_doc)
27
- @templates_by_id[template.id] = template
28
- end
29
- end
30
-
31
- end
32
- end
33
- end
34
- end
35
-
36
- require 'ecoportal/api/v2/template'
@@ -1,10 +0,0 @@
1
- module Ecoportal
2
- module API
3
- class V2
4
- class Template < Common::Content::DoubleModel
5
- passkey :id
6
- passthrough :name
7
- end
8
- end
9
- end
10
- end