ecoportal-api-v2 0.8.10 → 0.8.11
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -1
- data/lib/ecoportal/api/v2/page.rb +4 -0
- data/lib/ecoportal/api/v2/pages/page_stage.rb +6 -0
- data/lib/ecoportal/api/v2/pages.rb +6 -2
- data/lib/ecoportal/api/v2/registers/search_results.rb +13 -0
- data/lib/ecoportal/api/v2/registers.rb +13 -0
- data/lib/ecoportal/api/v2_version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d906a6021cc5fab91f2b2d8f32084d61449eab23b8162ade9e01308bdce3584
|
4
|
+
data.tar.gz: fe195a200860d2696acfc465accb16ee8758f5dfc00d9cbeffed836d654c1f8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74b45e1025b675e5675a0d6822fcefee7c464ae0759deb0da1004913793cef32bd2ad14f3656ab5b2177ae80bd5ac79fe9451e74ff9faefac24179f8ba9b621c
|
7
|
+
data.tar.gz: 8cab8147deaa80f9d3cd6dd5b31a42d0ba018001ca825e76a9a388999daef2ff686240c546255e6b8ac1785b1b7236ff4c124761b66d7cc414fef3c018480019
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,22 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [0.8.
|
4
|
+
## [0.8.11] - 2021-08-27
|
5
|
+
|
6
|
+
### Added
|
7
|
+
- `Ecoportal::API::V2::Page#stages?`
|
8
|
+
- `Ecoportal::API::V2::Pages::PageStage#current_stage_id`
|
9
|
+
- `Ecoportal::API::V2::Registers#search` added option keyed parameter `:only_first`
|
10
|
+
- which will make the method return the first `Ecoportal::API::V2::Registers::SearchResults`
|
11
|
+
- This has been **added** with the aim of knowing how many results out of how many entries.
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
- `Ecoportal::API::V2::Pages::PageStage#update` won't update unless there's something to update.
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
18
|
+
|
19
|
+
## [0.8.10] - 2021-08-22
|
5
20
|
|
6
21
|
### Added
|
7
22
|
- `Ecoportal::API::Common::Content::CollectionModel#[]` now supports position as well
|
@@ -9,6 +9,12 @@ module Ecoportal
|
|
9
9
|
|
10
10
|
embeds_many :permits, klass: "Ecoportal::API::V2::Page::Permit"
|
11
11
|
passarray :force_errors, :subtags, order_matters: false
|
12
|
+
|
13
|
+
# `id` of the stage we got the data of.
|
14
|
+
def current_stage_id
|
15
|
+
doc.dig("active_stage", "id") || doc["current_stage_id"]
|
16
|
+
end
|
17
|
+
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
@@ -47,12 +47,16 @@ module Ecoportal
|
|
47
47
|
end
|
48
48
|
|
49
49
|
# Requests to update an existing page via api.
|
50
|
+
# @note It won't launch the update unless there are changes
|
50
51
|
# @param doc [Hash, Page] data that at least contains an `id` (internal or external) of the target page.
|
51
52
|
# @return [Response] an object with the api response.
|
52
53
|
def update(doc)
|
53
54
|
body = get_body(doc) # , level: "page"
|
54
|
-
|
55
|
-
|
55
|
+
# Launch only if there are changes
|
56
|
+
if body && body["page"]
|
57
|
+
id = get_id(doc)
|
58
|
+
client.patch("/pages/#{CGI.escape(id)}", data: body)
|
59
|
+
end
|
56
60
|
end
|
57
61
|
|
58
62
|
# Gets a `new` non-existing page via api with all the ids initialized.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Registers
|
5
|
+
class SearchResults < Common::Content::DoubleModel
|
6
|
+
passthrough :total, :total_before_filtering
|
7
|
+
passarray :tags, order_matters: false
|
8
|
+
embeds_many :results, klass: "Ecoportal::API::V2::Registers::PageResult"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -9,6 +9,7 @@ module Ecoportal
|
|
9
9
|
|
10
10
|
class_resolver :register_class, "Ecoportal::API::V2::Registers::Register"
|
11
11
|
class_resolver :register_search_result_class, "Ecoportal::API::V2::Registers::PageResult"
|
12
|
+
class_resolver :register_search_results, "Ecoportal::API::V2::Registers::SearchResults"
|
12
13
|
|
13
14
|
attr_reader :client
|
14
15
|
|
@@ -35,7 +36,12 @@ module Ecoportal
|
|
35
36
|
# @param options [Hash] the search options
|
36
37
|
# @option options [Hash<Symbol, String>] :query plain search (like the search box in register).
|
37
38
|
# @option options [Hash<Symbol, Array<Object>>] :filters the set of filters.
|
39
|
+
# @option options [Boolean] if `true`, it only performs the first search and results `Ecoportal::API::V2::Registers::SearchResults`.
|
40
|
+
# @yield [result] something to do with search page-result.
|
41
|
+
# @yieldparam result [Ecoportal::V2::Registers::PageResult] a page result.
|
42
|
+
# @return [Ecoportal::API::V2::Registers, Ecoportal::API::V2::Registers::SearchResults]
|
38
43
|
def search(register_id, options = {})
|
44
|
+
only_first = options.delete(:only_first)
|
39
45
|
# supply a query string
|
40
46
|
# or a filter array (copy/paste from dev tools in the browser)
|
41
47
|
options = {query: nil, filters: []}.update(options)
|
@@ -49,6 +55,12 @@ module Ecoportal
|
|
49
55
|
end
|
50
56
|
end
|
51
57
|
|
58
|
+
if only_first
|
59
|
+
response = client.get("/registers/#{register_id}/search", params: options)
|
60
|
+
raise "Request failed - Status #{response.status}: #{response.body}" unless response.success?
|
61
|
+
return register_search_results.new(response.body["data"])
|
62
|
+
end
|
63
|
+
|
52
64
|
cursor_id = nil
|
53
65
|
results = 0
|
54
66
|
loop do
|
@@ -87,3 +99,4 @@ require 'ecoportal/api/v2/registers/register'
|
|
87
99
|
require 'ecoportal/api/v2/registers/stage_result'
|
88
100
|
require 'ecoportal/api/v2/registers/stages_result'
|
89
101
|
require 'ecoportal/api/v2/registers/page_result'
|
102
|
+
require 'ecoportal/api/v2/registers/search_results'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecoportal-api-v2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.11
|
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-08-
|
11
|
+
date: 2021-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -231,6 +231,7 @@ files:
|
|
231
231
|
- lib/ecoportal/api/v2/registers.rb
|
232
232
|
- lib/ecoportal/api/v2/registers/page_result.rb
|
233
233
|
- lib/ecoportal/api/v2/registers/register.rb
|
234
|
+
- lib/ecoportal/api/v2/registers/search_results.rb
|
234
235
|
- lib/ecoportal/api/v2/registers/stage_result.rb
|
235
236
|
- lib/ecoportal/api/v2/registers/stages_result.rb
|
236
237
|
- lib/ecoportal/api/v2/registers/template.rb
|