ecoportal-api-v2 2.0.0 → 2.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -2
- data/lib/ecoportal/api/v2/page.rb +1 -0
- data/lib/ecoportal/api/v2/pages/page_stage/task.rb +63 -0
- data/lib/ecoportal/api/v2/pages/page_stage/tasks.rb +69 -0
- data/lib/ecoportal/api/v2/pages/page_stage.rb +10 -4
- data/lib/ecoportal/api/v2/pages/stages.rb +3 -4
- data/lib/ecoportal/api/v2/pages.rb +6 -0
- data/lib/ecoportal/api/v2_version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97b022ff724f1d1d3f80b357d482e54ebba3750751de3771097840c1a9a1e697
|
4
|
+
data.tar.gz: f587813ad0917441c55c1a5dde359ca5e12070ee22d899f5a41646fa63af40dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d4e4f6c25ab85c7c8c0a119fdab33b107b519022c66ce57c2159e1de89cb73e200243e59105adc7c50d0dd3a718367ecbc9d47e8fda5766d6ab33c3a09ed3cd
|
7
|
+
data.tar.gz: d8230c7c42ff3f358d9b33a8a81d194f8aba30149089c5201f5bf21a905028195503e8a0530a6a99e4c1ce4f828f4ea5e4b691b4528a569e20fb362c6884f84e
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,26 @@
|
|
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
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
## [2.0.5] - 2024-08-07
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
|
17
|
+
- Use correct endpoint to update page-stages
|
18
|
+
|
19
|
+
## [2.0.4] - 2024-08-07
|
20
|
+
|
21
|
+
### Added
|
22
|
+
|
23
|
+
- Ability to `submit!` and `sign_off!`
|
24
|
+
|
5
25
|
## [2.0.0] - 2024-08-01
|
6
26
|
|
7
27
|
### Added
|
@@ -14,8 +34,6 @@ All notable changes to this project will be documented in this file.
|
|
14
34
|
|
15
35
|
- require `ruby 3`
|
16
36
|
|
17
|
-
### Fixed
|
18
|
-
|
19
37
|
## [1.1.8] - 2024-03-23
|
20
38
|
|
21
39
|
### Changed
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Pages
|
5
|
+
class PageStage
|
6
|
+
class Task < Common::Content::DoubleModel
|
7
|
+
passkey :id
|
8
|
+
passforced :patch_ver, default: 0
|
9
|
+
|
10
|
+
passthrough :name
|
11
|
+
passthrough :user_lookups, :user_ids
|
12
|
+
passthrough :strategies, :scheduled_callbacks
|
13
|
+
passboolean :historic
|
14
|
+
|
15
|
+
passboolean :complete, :completable
|
16
|
+
passdate :due, :complete_at
|
17
|
+
passthrough :complete_by_id, :completed_by_name
|
18
|
+
|
19
|
+
passthrough :last_strategy
|
20
|
+
passboolean :is_retry, :rejected
|
21
|
+
passthrough :retry_reason
|
22
|
+
passthrough :rejected_by, :rejected_by_name, :rejected_notes
|
23
|
+
passdate :rejected_at
|
24
|
+
|
25
|
+
passboolean :escalated
|
26
|
+
passdate :escalated_at
|
27
|
+
|
28
|
+
passboolean :submitted
|
29
|
+
passthrough :type
|
30
|
+
passthrough :view_type
|
31
|
+
|
32
|
+
def ooze
|
33
|
+
self._parent.ooze
|
34
|
+
end
|
35
|
+
|
36
|
+
def fill_in?
|
37
|
+
type == 'complete_page'
|
38
|
+
end
|
39
|
+
|
40
|
+
def review?
|
41
|
+
type == 'review_page'
|
42
|
+
end
|
43
|
+
|
44
|
+
def complete!
|
45
|
+
return mark_as_submit if fill_in?
|
46
|
+
return mark_as_sign_off if review?
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def mark_as_submit
|
52
|
+
doc['submitted'] = true
|
53
|
+
end
|
54
|
+
|
55
|
+
def mark_as_sign_off
|
56
|
+
doc['sign_off'] = true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Pages
|
5
|
+
class PageStage
|
6
|
+
class Tasks < Common::Content::CollectionModel
|
7
|
+
class_resolver :task_class, "Ecoportal::API::V2::Pages::PageStage::Task"
|
8
|
+
|
9
|
+
self.klass = :task_class
|
10
|
+
|
11
|
+
def ooze
|
12
|
+
self._parent.ooze
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Ecoportal::API::V2::Pages::PageStage::Task]
|
16
|
+
def get_by_id(id)
|
17
|
+
self.find do |task|
|
18
|
+
task.id == id
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Array<Ecoportal::API::V2::Pages::PageStage::Task>]
|
23
|
+
def get_by_type(type)
|
24
|
+
select do |task|
|
25
|
+
task.type == type
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Array<Ecoportal::API::V2::Pages::PageStage::Task>]
|
30
|
+
def open(&block)
|
31
|
+
reject(&:complete).tap do |res|
|
32
|
+
res.each(&block)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Array<Ecoportal::API::V2::Pages::PageStage::Task>]
|
37
|
+
def complete(&block)
|
38
|
+
select(&:complete).tap do |res|
|
39
|
+
res.each(&block)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [Array<Ecoportal::API::V2::Pages::PageStage::Task>]
|
44
|
+
def fill_in(active: :unused, &block)
|
45
|
+
target = self
|
46
|
+
target = open if active == true
|
47
|
+
target = complete if active == false
|
48
|
+
|
49
|
+
target.select(&:fill_in?).tap do |res|
|
50
|
+
res.each(&block)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# @return [Array<Ecoportal::API::V2::Pages::PageStage::Task>]
|
55
|
+
def review(active: :unused, &block)
|
56
|
+
target = self
|
57
|
+
target = open if active == true
|
58
|
+
target = complete if active == false
|
59
|
+
|
60
|
+
target.select(&:review?).tap do |res|
|
61
|
+
res.each(&block)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -8,6 +8,9 @@ module Ecoportal
|
|
8
8
|
passthrough :task_priority, :state, :status
|
9
9
|
passthrough :votes_enabled, :upvotes, :downvotes
|
10
10
|
|
11
|
+
class_resolver :tasks_class, "Ecoportal::API::V2::Pages::PageStage::Tasks"
|
12
|
+
embeds_many :tasks, enum_class: :tasks_class
|
13
|
+
|
11
14
|
#embeds_many :permits, klass: "Ecoportal::API::V2::Page::Permit"
|
12
15
|
passarray :force_errors, :subtags, order_matters: false
|
13
16
|
|
@@ -64,16 +67,19 @@ module Ecoportal
|
|
64
67
|
end
|
65
68
|
|
66
69
|
def mark_as_submit
|
67
|
-
|
68
|
-
doc["type"] = "complete_page"
|
70
|
+
tasks.fill_in(active: true).each(&:complete!)
|
69
71
|
end
|
72
|
+
alias_method :submit!, :mark_as_submit
|
70
73
|
|
71
74
|
def mark_as_sign_off
|
72
|
-
|
73
|
-
doc["type"] = "review_page"
|
75
|
+
tasks.review(active: true).each(&:complete!)
|
74
76
|
end
|
77
|
+
alias_method :sign_off!, :mark_as_sign_off
|
75
78
|
end
|
76
79
|
end
|
77
80
|
end
|
78
81
|
end
|
79
82
|
end
|
83
|
+
|
84
|
+
require 'ecoportal/api/v2/pages/page_stage/task'
|
85
|
+
require 'ecoportal/api/v2/pages/page_stage/tasks'
|
@@ -40,12 +40,11 @@ module Ecoportal
|
|
40
40
|
# @param stage_id [String] the `id` of the target **stage**.
|
41
41
|
# @return [Response] an object with the api response.
|
42
42
|
def update(doc, id: nil, stage_id:)
|
43
|
-
body
|
44
|
-
id
|
45
|
-
path
|
43
|
+
body = get_body(doc)
|
44
|
+
id ||= get_id(doc)
|
45
|
+
path = "/pages/#{CGI.escape(id)}/stages/#{CGI.escape(stage_id)}/"
|
46
46
|
client.patch(path, data: body)
|
47
47
|
end
|
48
|
-
|
49
48
|
end
|
50
49
|
end
|
51
50
|
end
|
@@ -57,11 +57,17 @@ module Ecoportal
|
|
57
57
|
# @param doc [Hash, Page] data that at least contains an `id` (internal or external) of the target page.
|
58
58
|
# @return [Ecoportal::API::Common::Response] an object with the api response.
|
59
59
|
def update(doc)
|
60
|
+
if doc.is_a?(Ecoportal::API::V2::Pages::PageStage)
|
61
|
+
stage_id = doc.current_stage_id
|
62
|
+
return stages.update(doc, stage_id: stage_id)
|
63
|
+
end
|
64
|
+
|
60
65
|
body = get_body(doc) # , level: "page"
|
61
66
|
# Launch only if there are changes
|
62
67
|
raise "Missing page object" unless body && body["page"]
|
63
68
|
|
64
69
|
id = get_id(doc)
|
70
|
+
|
65
71
|
client.patch("/pages/#{CGI.escape(id)}", data: body)
|
66
72
|
end
|
67
73
|
|
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: 2.0.
|
4
|
+
version: 2.0.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: 2024-08-
|
11
|
+
date: 2024-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -230,6 +230,8 @@ files:
|
|
230
230
|
- lib/ecoportal/api/v2/pages.rb
|
231
231
|
- lib/ecoportal/api/v2/pages/page_create_response.rb
|
232
232
|
- lib/ecoportal/api/v2/pages/page_stage.rb
|
233
|
+
- lib/ecoportal/api/v2/pages/page_stage/task.rb
|
234
|
+
- lib/ecoportal/api/v2/pages/page_stage/tasks.rb
|
233
235
|
- lib/ecoportal/api/v2/pages/stages.rb
|
234
236
|
- lib/ecoportal/api/v2/people.rb
|
235
237
|
- lib/ecoportal/api/v2/registers.rb
|