ecoportal-api 0.7.5 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a3b6466476eefca80c4c105572ff4fc9789861951dfbc6c0390277a33c35a27
4
- data.tar.gz: bee1361739b8a7bb6336aa4198a078a76f67479818d82a6bd1b1d3fd0ea77867
3
+ metadata.gz: ba5ffaf73f0c065f6aa6572b5ac82132af9ee19f61692f80605ee156b29d24ee
4
+ data.tar.gz: d82d89d09d4ae1edb88a3dc01f613478e7bd5ab38184dadb7c507e53e65bae54
5
5
  SHA512:
6
- metadata.gz: e32a1b38746232a63d2939267345fc5d3ceb3a02d6a297bffdc2ccd7df82ea27fe1748e0836905eed8848fabfe25694e6332402d012537c529b224a0bad17367
7
- data.tar.gz: 5c9d4e78ff2b63dc6a1ff31518976c88fdd955e3c36621a194e767bc0686ca6b2a16e11f3cc23a29a7a0e252050686170124d9761cbce5000ba97a4aca00c014
6
+ metadata.gz: f3b637bd2bc2970b7f46eb8d92edc6b83a38ef4489d6d185e4cea47d8a5e6cd774d9bf9e8712bd0d76aa9a52c770e89207f0c7af283fcb85bc1cb481d31fca10
7
+ data.tar.gz: 6a5dd4dd6fd2691971c526e79d2278a84351484a0d9ffdd93e3604392f4b59e21515255001c51016835a37506496d1d292f33c4dc69d4db7042e9c3d521721c3
data/CHANGELOG.md CHANGED
@@ -1,7 +1,20 @@
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
4
+ ## [0.8.2] - 2021-02-xx
5
+
6
+ ### Added
7
+
8
+ ### Fixed
9
+ - `Ecoportal::API::V1::Person#filter_tags=` should ignore `nil` values
10
+
11
+ ### Changed
12
+ - removed all the namespace under `Ecoportal::API::V2` as that is managed by `ecoportal-api-oozes` gem
13
+ - url: https://rubygems.org/gems/ecoportal-api-oozes
14
+ - `Ecoportal::API::V1::People.get` should return a `Person` object
15
+ - observe that it was returning the `WrappedResponse` (an `Enumerable` helper that works better when getting multiple people).
16
+
17
+ ## [0.7.5] - 2021-02-12
5
18
 
6
19
  ### Added
7
20
 
@@ -76,6 +89,10 @@ All notable changes to this project will be documented in this file.
76
89
  ## [0.7.0] - 2020-09-11
77
90
 
78
91
  ### Added
92
+ - added hook, **private** method `body_data` for child classes to define behaviour on `response.body` to
93
+ - `Ecoportal::API::V1::People`
94
+ - `Ecoportal::API::Common::BatchOperation`
95
+
79
96
  ### Changed
80
97
  - `Ecoportal::API::Internal::Permissions`: **update for new abilities of ecoPortal release `1.5.2`**
81
98
  - decoupled abilities: `person_core` into `person_core_create`, `person_core_edit`
@@ -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
@@ -20,13 +22,13 @@ Gem::Specification.new do |spec|
20
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
23
  spec.require_paths = ["lib"]
22
24
 
23
- spec.add_development_dependency "bundler", "~> 2.1", ">= 2.1.3"
24
- spec.add_development_dependency "rake", "~> 12.0"
25
- spec.add_development_dependency "rspec", "~> 3", ">= 3.9"
26
- spec.add_development_dependency "yard", "~> 0.9", ">= 0.9.18"
27
- spec.add_development_dependency "redcarpet", "~> 3.5", ">= 3.5.0"
28
- spec.add_development_dependency "pry" , "~> 0.13"
25
+ spec.add_development_dependency "bundler", ">= 2.2.11", "< 2.3"
26
+ spec.add_development_dependency "rspec", ">= 3.10.0", "< 3.11"
27
+ spec.add_development_dependency "rake", ">= 13.0.3", "< 13.1"
28
+ spec.add_development_dependency "yard", ">= 0.9.26", "< 0.10"
29
+ spec.add_development_dependency "redcarpet", ">= 3.5.1", "< 3.6"
30
+ spec.add_development_dependency "pry" , "~> 0.14"
29
31
 
30
- spec.add_dependency 'http', '~> 4'
32
+ spec.add_dependency 'http', '~> 4.4.1', "< 5"
31
33
  spec.add_dependency 'hash-polyfill', '~> 0'
32
34
  end
data/lib/ecoportal/api.rb CHANGED
@@ -11,5 +11,4 @@ end
11
11
  require "ecoportal/api/logger"
12
12
  require "ecoportal/api/common"
13
13
  require "ecoportal/api/v1"
14
- require "ecoportal/api/v2"
15
14
  require "ecoportal/api/internal"
@@ -27,7 +27,7 @@ module Ecoportal
27
27
 
28
28
  log(:info) { "Processing batch responses" }
29
29
 
30
- response.body.each.with_index do |subresponse, idx|
30
+ body_data(response.body).each.with_index do |subresponse, idx|
31
31
  callback = @operations[idx][:callback]
32
32
  status = subresponse["status"]
33
33
  body = subresponse["response"]
@@ -97,6 +97,12 @@ module Ecoportal
97
97
 
98
98
  private
99
99
 
100
+ # Hook for other api versions to obtain the raw data of a response
101
+ # @note this was introduced to allow `v2` to reuse this class
102
+ def body_data(body)
103
+ body
104
+ end
105
+
100
106
  def log_batch_response(operation, response)
101
107
  level = response.success?? :debug : :warn
102
108
  log(:info) { "BATCH #{operation[:method]} #{operation[:path]}" }
@@ -37,10 +37,11 @@ module Ecoportal
37
37
  loop do
38
38
  params.update(cursor_id: cursor_id) if cursor_id
39
39
  response = client.get("/people", params: params)
40
- raise "Request failed - Status #{response.status}: #{response.body}" unless response.success?
40
+ body = body_data(response.body)
41
+ raise "Request failed - Status #{response.status}: #{body}" unless response.success?
41
42
 
42
- unless silent || (total = response.body["total_results"]) == 0
43
- results += response.body["results"].length
43
+ unless silent || (total = body["total_results"]) == 0
44
+ results += body["results"].length
44
45
  percent = results * 100 / total
45
46
  msg = "People GET"
46
47
  msg += " (search=#{params[:q]})" if params.key?(:q)
@@ -48,10 +49,10 @@ module Ecoportal
48
49
  $stdout.flush
49
50
  end
50
51
 
51
- response.body["results"].each do |person|
52
+ body["results"].each do |person|
52
53
  yield person_class.new(person)
53
54
  end
54
- break unless (cursor_id = response.body["cursor_id"])
55
+ break unless (cursor_id = body["cursor_id"])
55
56
  end
56
57
  self
57
58
  end
@@ -70,10 +71,13 @@ module Ecoportal
70
71
  # Gets a person via api.
71
72
  # @note if the request has `success?` the returned `object.result` gives an object with that `Person`.
72
73
  # @param doc [String, Hash, Person] data containing an `id` (internal or external) of the target person.
73
- # @return [WrappedResponse] an object with the api response.
74
+ # @return [Person] the person with `id` (internal or external) contained in `doc`.
74
75
  def get(doc)
75
- response = client.get("/people/"+CGI.escape(get_id(doc)))
76
- Common::WrappedResponse.new(response, person_class)
76
+ id = get_id(doc)
77
+ response = client.get("/people/"+CGI.escape(id))
78
+ body = body_data(response.body)
79
+ return person_class.new(body) if response.success?
80
+ raise "Could not get person #{id} - Error #{reponse.status}: #{body}"
77
81
  end
78
82
 
79
83
  # Requests an update of a person via api.
@@ -107,7 +111,7 @@ module Ecoportal
107
111
  # @return [Response] an object with the api response.
108
112
  def delete(doc)
109
113
  id = get_id(doc)
110
- client.delete("/people/"+CGI.escape(id))
114
+ client.delete("/people/"+CGI.escape(id))
111
115
  end
112
116
 
113
117
  # Creates a `BatchOperation` and yields it to the given bock.
@@ -150,13 +154,13 @@ module Ecoportal
150
154
  JobStatus = Struct.new(:id, :complete?, :errored?, :progress)
151
155
  def job_status(job_id)
152
156
  response = client.get("/people/job/#{CGI.escape(job_id)}/status")
153
-
157
+ body = body_data(response.body)
154
158
  raise "Status error" unless response.success?
155
159
  JobStatus.new(
156
- response.body["id"],
157
- response.body["complete"],
158
- response.body["errored"],
159
- response.body["progress"]
160
+ body["id"],
161
+ body["complete"],
162
+ body["errored"],
163
+ body["progress"]
160
164
  )
161
165
  end
162
166
 
@@ -186,11 +190,18 @@ module Ecoportal
186
190
  job_id = nil
187
191
  client.without_response_logging do
188
192
  client.post("/people/job", data: operation.as_json).tap do |response|
189
- job_id = response.body["id"]
193
+ job_id = body_data(response.body)["id"]
190
194
  end
191
195
  end
192
196
  job_id
193
197
  end
198
+
199
+ # Hook for other api versions to obtain the raw data of a response
200
+ # @note this was introduced to allow `v2` to reuse this class
201
+ def body_data(body)
202
+ body
203
+ end
204
+
194
205
  end
195
206
  end
196
207
  end
@@ -59,7 +59,7 @@ module Ecoportal
59
59
  unless value.is_a?(Array)
60
60
  raise "filter_tags= needs to be passed an Array, got #{value.class}"
61
61
  end
62
- end_tags = value.map do |tag|
62
+ end_tags = value.compact.map do |tag|
63
63
  unless tag.match(VALID_TAG_REGEX)
64
64
  raise "Invalid filter tag #{tag.inspect}"
65
65
  end
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- VERSION = "0.7.5"
3
+ VERSION = "0.8.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,137 +1,149 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecoportal-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tapio Saarinen
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-23 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
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.1'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
- version: 2.1.3
19
+ version: 2.2.11
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.3'
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '2.1'
30
27
  - - ">="
31
28
  - !ruby/object:Gem::Version
32
- version: 2.1.3
29
+ version: 2.2.11
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.3'
33
33
  - !ruby/object:Gem::Dependency
34
- name: rake
34
+ name: rspec
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 3.10.0
40
+ - - "<"
38
41
  - !ruby/object:Gem::Version
39
- version: '12.0'
42
+ version: '3.11'
40
43
  type: :development
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
44
- - - "~>"
47
+ - - ">="
45
48
  - !ruby/object:Gem::Version
46
- version: '12.0'
49
+ version: 3.10.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '3.11'
47
53
  - !ruby/object:Gem::Dependency
48
- name: rspec
54
+ name: rake
49
55
  requirement: !ruby/object:Gem::Requirement
50
56
  requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '3'
54
57
  - - ">="
55
58
  - !ruby/object:Gem::Version
56
- version: '3.9'
59
+ version: 13.0.3
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '13.1'
57
63
  type: :development
58
64
  prerelease: false
59
65
  version_requirements: !ruby/object:Gem::Requirement
60
66
  requirements:
61
- - - "~>"
62
- - !ruby/object:Gem::Version
63
- version: '3'
64
67
  - - ">="
65
68
  - !ruby/object:Gem::Version
66
- version: '3.9'
69
+ version: 13.0.3
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '13.1'
67
73
  - !ruby/object:Gem::Dependency
68
74
  name: yard
69
75
  requirement: !ruby/object:Gem::Requirement
70
76
  requirements:
71
- - - "~>"
72
- - !ruby/object:Gem::Version
73
- version: '0.9'
74
77
  - - ">="
75
78
  - !ruby/object:Gem::Version
76
- version: 0.9.18
79
+ version: 0.9.26
80
+ - - "<"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.10'
77
83
  type: :development
78
84
  prerelease: false
79
85
  version_requirements: !ruby/object:Gem::Requirement
80
86
  requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: '0.9'
84
87
  - - ">="
85
88
  - !ruby/object:Gem::Version
86
- version: 0.9.18
89
+ version: 0.9.26
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: '0.10'
87
93
  - !ruby/object:Gem::Dependency
88
94
  name: redcarpet
89
95
  requirement: !ruby/object:Gem::Requirement
90
96
  requirements:
91
97
  - - ">="
92
98
  - !ruby/object:Gem::Version
93
- version: 3.5.0
94
- - - "~>"
99
+ version: 3.5.1
100
+ - - "<"
95
101
  - !ruby/object:Gem::Version
96
- version: '3.5'
102
+ version: '3.6'
97
103
  type: :development
98
104
  prerelease: false
99
105
  version_requirements: !ruby/object:Gem::Requirement
100
106
  requirements:
101
107
  - - ">="
102
108
  - !ruby/object:Gem::Version
103
- version: 3.5.0
104
- - - "~>"
109
+ version: 3.5.1
110
+ - - "<"
105
111
  - !ruby/object:Gem::Version
106
- version: '3.5'
112
+ version: '3.6'
107
113
  - !ruby/object:Gem::Dependency
108
114
  name: pry
109
115
  requirement: !ruby/object:Gem::Requirement
110
116
  requirements:
111
117
  - - "~>"
112
118
  - !ruby/object:Gem::Version
113
- version: '0.13'
119
+ version: '0.14'
114
120
  type: :development
115
121
  prerelease: false
116
122
  version_requirements: !ruby/object:Gem::Requirement
117
123
  requirements:
118
124
  - - "~>"
119
125
  - !ruby/object:Gem::Version
120
- version: '0.13'
126
+ version: '0.14'
121
127
  - !ruby/object:Gem::Dependency
122
128
  name: http
123
129
  requirement: !ruby/object:Gem::Requirement
124
130
  requirements:
125
131
  - - "~>"
126
132
  - !ruby/object:Gem::Version
127
- version: '4'
133
+ version: 4.4.1
134
+ - - "<"
135
+ - !ruby/object:Gem::Version
136
+ version: '5'
128
137
  type: :runtime
129
138
  prerelease: false
130
139
  version_requirements: !ruby/object:Gem::Requirement
131
140
  requirements:
132
141
  - - "~>"
133
142
  - !ruby/object:Gem::Version
134
- version: '4'
143
+ version: 4.4.1
144
+ - - "<"
145
+ - !ruby/object:Gem::Version
146
+ version: '5'
135
147
  - !ruby/object:Gem::Dependency
136
148
  name: hash-polyfill
137
149
  requirement: !ruby/object:Gem::Requirement
@@ -205,13 +217,6 @@ files:
205
217
  - lib/ecoportal/api/v1/person_schemas.rb
206
218
  - lib/ecoportal/api/v1/schema_field.rb
207
219
  - lib/ecoportal/api/v1/schema_field_value.rb
208
- - lib/ecoportal/api/v2.rb
209
- - lib/ecoportal/api/v2/field.rb
210
- - lib/ecoportal/api/v2/page.rb
211
- - lib/ecoportal/api/v2/pages.rb
212
- - lib/ecoportal/api/v2/register_search_result.rb
213
- - lib/ecoportal/api/v2/registers.rb
214
- - lib/ecoportal/api/v2/stage.rb
215
220
  - lib/ecoportal/api/version.rb
216
221
  homepage: https://www.ecoportal.com
217
222
  licenses:
@@ -225,7 +230,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
225
230
  requirements:
226
231
  - - ">="
227
232
  - !ruby/object:Gem::Version
228
- version: '0'
233
+ version: 2.4.4
229
234
  required_rubygems_version: !ruby/object:Gem::Requirement
230
235
  requirements:
231
236
  - - ">="
@@ -1,47 +0,0 @@
1
- module Ecoportal
2
- module API
3
- # @attr_reader client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
4
- # @attr_reader logger [Logger] the logger.
5
- class V2
6
- extend Common::BaseClass
7
- include Common::Logging
8
-
9
- VERSION = "v2"
10
- class_resolver :registers_class, "Ecoportal::API::V2::Registers"
11
- class_resolver :pages_class, "Ecoportal::API::V2::Pages"
12
-
13
- attr_reader :client, :logger
14
-
15
- # Creates an `V2` object to scope version specific api requests.
16
- # @note
17
- # - The const `VERSION` determineds the api version that client will query against.
18
- # - This means that each subclass of `V2` should define their own `VERSION` constant.
19
- # @param api_key [String] the key version to stablish the api connection.
20
- # @param host [String] api server domain.
21
- # @param logger [Logger] an object with `Logger` interface to generate logs.
22
- # @return [V2] an object with the api version suit.
23
- def initialize(api_key, version: VERSION, host: "live.ecoportal.com", logger: default_logger)
24
- @logger = logger
25
- @client = Common::Client.new(
26
- api_key: api_key,
27
- host: host,
28
- version: self.class::VERSION,
29
- logger: @logger
30
- )
31
- end
32
-
33
- # Obtain specific object for register api requests.
34
- # @return [Register] an instance object ready to make register api requests.
35
- def registers
36
- registers_class.new(client)
37
- end
38
-
39
- def pages
40
- pages_class.new(client)
41
- end
42
- end
43
- end
44
- end
45
-
46
- require 'ecoportal/api/v2/registers'
47
- require 'ecoportal/api/v2/pages'
@@ -1,9 +0,0 @@
1
- module Ecoportal
2
- module API
3
- class V2
4
- class Field < Common::BaseModel
5
- passthrough :id, :label, :value, :type
6
- end
7
- end
8
- end
9
- end
@@ -1,30 +0,0 @@
1
- module Ecoportal
2
- module API
3
- class V2
4
- class Page < Common::BaseModel
5
- passthrough :id, :name, :state
6
-
7
- class_resolver :stage_class, "Ecoportal::API::V2::Stage"
8
- class_resolver :field_class, "Ecoportal::API::V2::Field"
9
-
10
- def stages
11
- return nil unless doc["evolution"]
12
- return @stages if defined?(@stages)
13
- @stages = (doc["evolution"]["stages"] || []).each_with_index.map do |stage, i|
14
- stage_class.new(stage, parent: self, key: ["stages", i])
15
- end
16
- end
17
-
18
- def fields
19
- return @fields if defined?(@fields)
20
- @fields = (doc["components"] || []).each_with_index.map do |component, i|
21
- field_class.new(component, parent: self, key: ["components", i])
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
28
-
29
- require 'ecoportal/api/v2/stage'
30
- require 'ecoportal/api/v2/field'
@@ -1,46 +0,0 @@
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 Pages
6
- extend Common::BaseClass
7
- include Enumerable
8
- include Common::DocHelpers
9
-
10
- attr_reader :client
11
-
12
- class_resolver :page_class, "Ecoportal::API::V2::Page"
13
-
14
- # @param client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
15
- # @return [People] an instance object ready to make people api requests.
16
- def initialize(client)
17
- @client = client
18
- end
19
-
20
- def get(id, stage_id: nil)
21
- if stage_id
22
- response = get_with_stage_id(id, stage_id)
23
- return page_class.new(response.body["data"])
24
- end
25
-
26
- response = client.get("/pages/#{id}")
27
- # we get a 302 back when there's stages for the page
28
- # let's follow it
29
- if response.status == 302
30
- stage_id = response.body["data"].match(/stages\/(.*)/)[1]
31
- response = get_with_stage_id(id, stage_id)
32
- end
33
- page_class.new(response.body["data"])
34
- end
35
-
36
- private
37
-
38
- def get_with_stage_id(id, stage_id)
39
- client.get("/pages/#{id}/stages/#{stage_id}")
40
- end
41
- end
42
- end
43
- end
44
- end
45
-
46
- require 'ecoportal/api/v2/page'
@@ -1,20 +0,0 @@
1
- module Ecoportal
2
- module API
3
- class V2
4
- class RegisterSearchResult < Common::BaseModel
5
- passthrough :id, :name, :state
6
-
7
- class_resolver :stage_class, "Ecoportal::API::V2::Stage"
8
-
9
- def stages
10
- return @stages if defined?(@stages)
11
- @stages = (doc["stages"] || []).each_with_index.map do |stage, i|
12
- stage_class.new(stage, parent: self, key: ["stages", i])
13
- end
14
- end
15
- end
16
- end
17
- end
18
- end
19
-
20
- require 'ecoportal/api/v2/stage'
@@ -1,65 +0,0 @@
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 Registers
6
- extend Common::BaseClass
7
- include Enumerable
8
- include Common::DocHelpers
9
-
10
- class_resolver :register_search_result_class, "Ecoportal::API::V2::RegisterSearchResult"
11
-
12
- attr_reader :client
13
-
14
- # @param client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
15
- # @return [People] an instance object ready to make people api requests.
16
- def initialize(client)
17
- @client = client
18
- end
19
-
20
- def search(register_id, options = {})
21
- # supply a query string
22
- # or a filter array (copy/paste from dev tools in the browser)
23
- options = {query: nil, filters: []}.update(options)
24
- options = {}.tap do |ret|
25
- options.each do |key, value|
26
- if key == :filters && value.any?
27
- ret[key] = {filters: value}.to_json
28
- else
29
- ret[key] = value if key
30
- end
31
- end
32
- end
33
-
34
- cursor_id = nil
35
- results = 0
36
- loop do
37
- options.update(cursor_id: cursor_id) if cursor_id
38
- response = client.get("/registers/#{register_id}/search", params: options)
39
- raise "Request failed - Status #{response.status}: #{response.body}" unless response.success?
40
-
41
- data = response.body["data"]
42
- unless (total = data["total"]) == 0
43
- results += data["results"].length
44
- percent = results * 100 / total
45
- msg = "Registers SEARCH"
46
- print "#{msg}: #{percent.round}% (of #{total})\r"
47
- $stdout.flush
48
- end
49
-
50
- data["results"].each do |result|
51
- object = register_search_result_class.new(result)
52
- yield object
53
- end
54
-
55
- # break unless (cursor_id = data["cursor_id"])
56
- break if total == results
57
- end
58
- self
59
- end
60
- end
61
- end
62
- end
63
- end
64
-
65
- require 'ecoportal/api/v2/register_search_result'
@@ -1,9 +0,0 @@
1
- module Ecoportal
2
- module API
3
- class V2
4
- class Stage < Common::BaseModel
5
- passthrough :id, :name, :state
6
- end
7
- end
8
- end
9
- end