ecoportal-api-oozes 0.7.0 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +103 -1
  3. data/README.md +2 -0
  4. data/ecoportal-api-oozes.gemspec +13 -6
  5. data/lib/ecoportal/api/common/content/class_helpers.rb +35 -0
  6. data/lib/ecoportal/api/common/content/collection_model.rb +25 -3
  7. data/lib/ecoportal/api/common/content/double_model.rb +27 -12
  8. data/lib/ecoportal/api/common/content/hash_diff_patch.rb +8 -2
  9. data/lib/ecoportal/api/common/content/wrapped_response.rb +1 -1
  10. data/lib/ecoportal/api/v2.rb +38 -3
  11. data/lib/ecoportal/api/v2/page.rb +3 -3
  12. data/lib/ecoportal/api/v2/page/component.rb +24 -7
  13. data/lib/ecoportal/api/v2/page/component/action.rb +14 -3
  14. data/lib/ecoportal/api/v2/page/component/action_field.rb +40 -2
  15. data/lib/ecoportal/api/v2/page/component/chart_field.rb +54 -0
  16. data/lib/ecoportal/api/v2/page/component/chart_field/frequency.rb +29 -0
  17. data/lib/ecoportal/api/v2/page/component/chart_field/heatmap.rb +27 -0
  18. data/lib/ecoportal/api/v2/page/component/chart_field/indicator.rb +26 -0
  19. data/lib/ecoportal/api/v2/page/component/chart_field/multiseries.rb +31 -0
  20. data/lib/ecoportal/api/v2/page/component/chart_field/sankey.rb +27 -0
  21. data/lib/ecoportal/api/v2/page/component/chart_field/serie.rb +26 -0
  22. data/lib/ecoportal/api/v2/page/component/chart_field/series_config.rb +23 -0
  23. data/lib/ecoportal/api/v2/page/component/chart_fr_field.rb +32 -0
  24. data/lib/ecoportal/api/v2/page/component/checklist_field.rb +35 -2
  25. data/lib/ecoportal/api/v2/page/component/checklist_item.rb +10 -0
  26. data/lib/ecoportal/api/v2/page/component/date_field.rb +21 -0
  27. data/lib/ecoportal/api/v2/page/component/files_field.rb +1 -2
  28. data/lib/ecoportal/api/v2/page/component/gauge_field.rb +24 -1
  29. data/lib/ecoportal/api/v2/page/component/gauge_stop.rb +88 -0
  30. data/lib/ecoportal/api/v2/page/component/images_field.rb +11 -2
  31. data/lib/ecoportal/api/v2/page/component/people_field.rb +8 -1
  32. data/lib/ecoportal/api/v2/page/component/plain_text_field.rb +2 -0
  33. data/lib/ecoportal/api/v2/page/component/reference_field.rb +4 -0
  34. data/lib/ecoportal/api/v2/page/component/selection_field.rb +4 -5
  35. data/lib/ecoportal/api/v2/page/component/selection_option.rb +1 -0
  36. data/lib/ecoportal/api/v2/page/component/signature_field.rb +12 -1
  37. data/lib/ecoportal/api/v2/page/component/tag_field.rb +2 -0
  38. data/lib/ecoportal/api/v2/page/components.rb +2 -2
  39. data/lib/ecoportal/api/v2/page/section.rb +1 -0
  40. data/lib/ecoportal/api/v2/page/sections.rb +1 -1
  41. data/lib/ecoportal/api/v2/page/stages.rb +6 -0
  42. data/lib/ecoportal/api/v2/pages.rb +17 -15
  43. data/lib/ecoportal/api/v2/pages/page_stage.rb +6 -1
  44. data/lib/ecoportal/api/v2/pages/stages.rb +4 -1
  45. data/lib/ecoportal/api/v2/people.rb +31 -0
  46. data/lib/ecoportal/api/v2/registers.rb +60 -6
  47. data/lib/ecoportal/api/v2/registers/page_result.rb +21 -0
  48. data/lib/ecoportal/api/v2/registers/register.rb +37 -0
  49. data/lib/ecoportal/api/v2/registers/stage_result.rb +14 -0
  50. data/lib/ecoportal/api/v2/registers/stages_result.rb +13 -0
  51. data/lib/ecoportal/api/v2/registers/template.rb +12 -0
  52. data/lib/ecoportal/api/v2/version.rb +1 -1
  53. metadata +70 -36
  54. data/lib/ecoportal/api/v2/register.rb +0 -36
  55. data/lib/ecoportal/api/v2/template.rb +0 -10
@@ -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.0"
4
+ GEM_VERSION = "0.7.5"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,77 +1,95 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecoportal-api-oozes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
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: 2020-09-10 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
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.3
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '2.1'
22
+ version: '2.2'
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '2.1'
29
+ version: 2.1.3
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.2'
27
33
  - !ruby/object:Gem::Dependency
28
- name: rake
34
+ name: rspec
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '3.9'
40
+ - - "<"
32
41
  - !ruby/object:Gem::Version
33
- version: '12.0'
42
+ version: '4'
34
43
  type: :development
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
- - - "~>"
47
+ - - ">="
39
48
  - !ruby/object:Gem::Version
40
- version: '12.0'
49
+ version: '3.9'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '4'
41
53
  - !ruby/object:Gem::Dependency
42
- name: rspec
54
+ name: rake
43
55
  requirement: !ruby/object:Gem::Requirement
44
56
  requirements:
45
- - - "~>"
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 12.3.0
60
+ - - "<"
46
61
  - !ruby/object:Gem::Version
47
- version: '3.0'
62
+ version: '13'
48
63
  type: :development
49
64
  prerelease: false
50
65
  version_requirements: !ruby/object:Gem::Requirement
51
66
  requirements:
52
- - - "~>"
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 12.3.0
70
+ - - "<"
53
71
  - !ruby/object:Gem::Version
54
- version: '3.0'
72
+ version: '13'
55
73
  - !ruby/object:Gem::Dependency
56
74
  name: yard
57
75
  requirement: !ruby/object:Gem::Requirement
58
76
  requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.9'
62
77
  - - ">="
63
78
  - !ruby/object:Gem::Version
64
79
  version: 0.9.18
80
+ - - "<"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.10'
65
83
  type: :development
66
84
  prerelease: false
67
85
  version_requirements: !ruby/object:Gem::Requirement
68
86
  requirements:
69
- - - "~>"
70
- - !ruby/object:Gem::Version
71
- version: '0.9'
72
87
  - - ">="
73
88
  - !ruby/object:Gem::Version
74
89
  version: 0.9.18
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: '0.10'
75
93
  - !ruby/object:Gem::Dependency
76
94
  name: redcarpet
77
95
  requirement: !ruby/object:Gem::Requirement
@@ -79,9 +97,9 @@ dependencies:
79
97
  - - ">="
80
98
  - !ruby/object:Gem::Version
81
99
  version: 3.5.0
82
- - - "~>"
100
+ - - "<"
83
101
  - !ruby/object:Gem::Version
84
- version: '3.5'
102
+ version: '3.6'
85
103
  type: :development
86
104
  prerelease: false
87
105
  version_requirements: !ruby/object:Gem::Requirement
@@ -89,9 +107,9 @@ dependencies:
89
107
  - - ">="
90
108
  - !ruby/object:Gem::Version
91
109
  version: 3.5.0
92
- - - "~>"
110
+ - - "<"
93
111
  - !ruby/object:Gem::Version
94
- version: '3.5'
112
+ version: '3.6'
95
113
  - !ruby/object:Gem::Dependency
96
114
  name: pry
97
115
  requirement: !ruby/object:Gem::Requirement
@@ -112,20 +130,20 @@ dependencies:
112
130
  requirements:
113
131
  - - ">="
114
132
  - !ruby/object:Gem::Version
115
- version: 0.6.0
116
- - - "~>"
133
+ version: 0.7.4
134
+ - - "<"
117
135
  - !ruby/object:Gem::Version
118
- version: '0.7'
136
+ version: '0.8'
119
137
  type: :runtime
120
138
  prerelease: false
121
139
  version_requirements: !ruby/object:Gem::Requirement
122
140
  requirements:
123
141
  - - ">="
124
142
  - !ruby/object:Gem::Version
125
- version: 0.6.0
126
- - - "~>"
143
+ version: 0.7.4
144
+ - - "<"
127
145
  - !ruby/object:Gem::Version
128
- version: '0.7'
146
+ version: '0.8'
129
147
  description:
130
148
  email:
131
149
  - rien@ecoportal.co.nz
@@ -165,12 +183,22 @@ files:
165
183
  - lib/ecoportal/api/v2/page/component.rb
166
184
  - lib/ecoportal/api/v2/page/component/action.rb
167
185
  - lib/ecoportal/api/v2/page/component/action_field.rb
186
+ - lib/ecoportal/api/v2/page/component/chart_field.rb
187
+ - lib/ecoportal/api/v2/page/component/chart_field/frequency.rb
188
+ - lib/ecoportal/api/v2/page/component/chart_field/heatmap.rb
189
+ - lib/ecoportal/api/v2/page/component/chart_field/indicator.rb
190
+ - lib/ecoportal/api/v2/page/component/chart_field/multiseries.rb
191
+ - lib/ecoportal/api/v2/page/component/chart_field/sankey.rb
192
+ - lib/ecoportal/api/v2/page/component/chart_field/serie.rb
193
+ - lib/ecoportal/api/v2/page/component/chart_field/series_config.rb
194
+ - lib/ecoportal/api/v2/page/component/chart_fr_field.rb
168
195
  - lib/ecoportal/api/v2/page/component/checklist_field.rb
169
196
  - lib/ecoportal/api/v2/page/component/checklist_item.rb
170
197
  - lib/ecoportal/api/v2/page/component/date_field.rb
171
198
  - lib/ecoportal/api/v2/page/component/file.rb
172
199
  - lib/ecoportal/api/v2/page/component/files_field.rb
173
200
  - lib/ecoportal/api/v2/page/component/gauge_field.rb
201
+ - lib/ecoportal/api/v2/page/component/gauge_stop.rb
174
202
  - lib/ecoportal/api/v2/page/component/geo_field.rb
175
203
  - lib/ecoportal/api/v2/page/component/image.rb
176
204
  - lib/ecoportal/api/v2/page/component/images_field.rb
@@ -192,15 +220,21 @@ files:
192
220
  - lib/ecoportal/api/v2/pages.rb
193
221
  - lib/ecoportal/api/v2/pages/page_stage.rb
194
222
  - lib/ecoportal/api/v2/pages/stages.rb
195
- - lib/ecoportal/api/v2/register.rb
223
+ - lib/ecoportal/api/v2/people.rb
196
224
  - lib/ecoportal/api/v2/registers.rb
197
- - 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
198
230
  - lib/ecoportal/api/v2/version.rb
199
231
  homepage: https://www.ecoportal.com
200
232
  licenses:
201
233
  - MIT
202
234
  metadata: {}
203
- 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
+ \ "
204
238
  rdoc_options: []
205
239
  require_paths:
206
240
  - lib
@@ -208,7 +242,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
242
  requirements:
209
243
  - - ">="
210
244
  - !ruby/object:Gem::Version
211
- version: '0'
245
+ version: 2.4.4
212
246
  required_rubygems_version: !ruby/object:Gem::Requirement
213
247
  requirements:
214
248
  - - ">="