ecoportal-api-v2 0.8.31 → 0.8.33

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7fdd84d3767ffc6a9a5adfe976ad4a485754c076475d01da46877aa38e01d65
4
- data.tar.gz: 8c775abd99edba549b7b8abe049ac06c631005671b972a9340795857b378d39a
3
+ metadata.gz: 7fabf2bda9e67e4cb622c1f248b736cc8fb18f50e6ca4faed446e8d653921864
4
+ data.tar.gz: eae102b95a361093fc72a39f59de097cebc99617a9b9787c6c132490887329a0
5
5
  SHA512:
6
- metadata.gz: a4cc041705a2ac1e2ebe6eaaf7cc30fe79b780a1b5dc397bb1526fe0112df0a050d07452100e0174110e5cf30271ef1b3ddbb4f8b866c66824755c6f6bd287ad
7
- data.tar.gz: 1bdb9cd3ff3cf0b64f282f4be9ec372c276c8deee7b47b8a142eab20069c2ef072966b87a1a1c9047e01a54895354bd7e2a9a404215eabf6bbc689641297b8d4
6
+ metadata.gz: f5ce62ecf9835b548b0c73d59c892d82697e3be52aadf8a7c0e60e7acd90e97ddfccd243b67bc6c6fea99504e3fc382b0a67203dd7cbad4a779990568e12d1aa
7
+ data.tar.gz: c954614084116b80c01893be0d7c8fd03b5cd276e936ff87a2be7e0e933b811aa6d4fdb7d3db2a081f7709760bdbdb15a28abd40dbde4b3c485b5aaa24a2214f
data/CHANGELOG.md CHANGED
@@ -1,27 +1,57 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [0.8.31] - 2022-08-xx
4
+ ## [0.8.34] - 2022-09-xx
5
5
 
6
6
  ### Added
7
- - `Ecoportal::API:V2::Common::Content::ClassHelpers.uid` to generate a random uid
7
+
8
+ ### Changed
9
+
10
+ ### Fixed
11
+
12
+
13
+ ## [0.8.33] - 2022-09-23
14
+
15
+ ### Changed
16
+ - `Ecoportal::API::Common::Content::DoubleModel#embeds_many`: added new_class name collision prevention
17
+
18
+ ### Fixed
19
+ - `Ecoportal::API::Common::ClassHelpers.new_class`: should accept `name` parameter to be a class itself
20
+
21
+
22
+ ## [0.8.32] - 2022-09-19
23
+
24
+ ### Added
25
+ - `Ecoportal::API::V2::Pages::PageCreateResponse` to wrap the response on creation
26
+
27
+ ### Changed
28
+ - `Ecoportal::API::V2::Pages#create` to rather return a `PageCreateResponse`
29
+
30
+ ### Fixed
31
+ - `Ecoportal::API::V2::Pages#create` to make sure new page with no changes can be created.
32
+
33
+
34
+ ## [0.8.31] - 2022-09-15
35
+
36
+ ### Added
37
+ - `Ecoportal::API::Common::Content::ClassHelpers.uid` to generate a random uid
8
38
 
9
39
  ### Changed
10
40
  - added **inheritable attributes** to
11
- - `Ecoportal::API:V2::Common::Content::ArrayModel` (:order_matteres, :uniq)
12
- - `Ecoportal::API:V2::Common::Content::CollectionModel` (klass, :order_matters, :order_key, :items_key, :new_item)
13
- - `Ecoportal::API:V2::Common::Content::DoubleModel` (:key)
14
- - moved `SecureRandom` dependency to `Ecoportal::API:V2::Common::Content::ClassHelpers`
41
+ - `Ecoportal::API::Common::Content::ArrayModel` (:order_matteres, :uniq)
42
+ - `Ecoportal::API::Common::Content::CollectionModel` (klass, :order_matters, :order_key, :items_key, :new_item)
43
+ - `Ecoportal::API::Common::Content::DoubleModel` (:key)
44
+ - moved `SecureRandom` dependency to `Ecoportal::API::Common::Content::ClassHelpers`
15
45
 
16
46
  ### Fixed
17
47
  - `Ecoportal::API::V2::Page::Component::SelectionOption#numeric!` fix conversion
18
- - `Ecoportal::API:V2::Common::Content::ClassHelpers`, `new_class`
48
+ - `Ecoportal::API::Common::Content::ClassHelpers`, `new_class`
19
49
  - **Added** parameter `namespace` (default: the class `inherits` parameter): it's purpose is to define the namespace where the new class will sit
20
50
  - **Fixed** also the namespace where the new class constant will sit (it was using always the source class `self`)
21
51
  - **Improved** `name` parameter to have a default value that is randomized. This is useful when we just want to do something like `SomeClass.new_class`, where the name of the new class doesn't really matter.
22
52
  - **Fixed** lost reference of class resolvers when using `embeds_many`
23
- - `Ecoportal::API:V2::Common::Content::ClassHelpers`, `resolve_class` accepts now a `Hash` with `key` referrer class, and `value` any of the previously accepted ones (i.e. `Symbol` or `String`). To this purpose, `source_class` parameter has been added.
24
- - This has been natively wrapped in `Ecoportal::API:V2::Common::Content::DoubleModel.embeds_many`, as it naturally shares the `class_resolver` with a third party class that loses the reference.
53
+ - `Ecoportal::API::Common::Content::ClassHelpers`, `resolve_class` accepts now a `Hash` with `key` referrer class, and `value` any of the previously accepted ones (i.e. `Symbol` or `String`). To this purpose, `source_class` parameter has been added.
54
+ - This has been natively wrapped in `Ecoportal::API::Common::Content::DoubleModel.embeds_many`, as it naturally shares the `class_resolver` with a third party class that loses the reference.
25
55
 
26
56
  ## [0.8.30] - 2022-07-11
27
57
 
@@ -72,7 +72,7 @@ module Ecoportal
72
72
  # @yieldparam child_class [Class] the new class
73
73
  # @return [Class] the new generated class
74
74
  def new_class(name = "Child#{uid}", inherits: self, namespace: inherits)
75
- name = name.to_sym.freeze
75
+ name = name.to_s.to_sym.freeze
76
76
  class_name = to_constant(name)
77
77
 
78
78
  unless target_class = resolve_class("#{namespace}::#{class_name}", exception: false)
@@ -198,7 +198,7 @@ module Ecoportal
198
198
  if enum_class
199
199
  eclass = enum_class
200
200
  elsif klass
201
- eclass = new_class(method, inherits: Common::Content::CollectionModel) do |dim_class|
201
+ eclass = new_class("#{method}::#{klass}", inherits: Common::Content::CollectionModel) do |dim_class|
202
202
  dim_class.klass = klass
203
203
  dim_class.order_matters = order_matters
204
204
  dim_class.order_key = order_key
@@ -0,0 +1,13 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Pages
5
+ # @attr_reader page_id [String] the `id` of the new ooze.
6
+ # @attr_reader active_stage_id [String] the active stage `id` of the new ooze.
7
+ class PageCreateResponse < Common::Content::DoubleModel
8
+ passthrough :page_id, :active_stage_id
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -9,6 +9,7 @@ module Ecoportal
9
9
 
10
10
  class_resolver :stages_class, "Ecoportal::API::V2::Pages::Stages"
11
11
  class_resolver :page_class, "Ecoportal::API::V2::Page"
12
+ class_resolver :create_page_response_class, "Ecoportal::API::V2::Pages::PageCreateResponse"
12
13
 
13
14
  attr_reader :client
14
15
 
@@ -75,9 +76,20 @@ module Ecoportal
75
76
  # @param from [String, Hash, Page] template or `id` of the template
76
77
  # @return [Response] an object with the api response.
77
78
  def create(doc, from:)
78
- body = get_body(doc)
79
79
  id = get_id(from)
80
- client.post("/pages", data: body, params: {template_id: id})
80
+ body = get_body(doc).tap do |hash|
81
+ unless hash["page"]
82
+ hash["page"] = {
83
+ "id" => "111111111111111111111111",
84
+ "operation" => "changed",
85
+ "data" => {"patch_ver" => 0}
86
+ }
87
+ end
88
+ end
89
+ response = client.post("/pages", data: body, params: {template_id: id})
90
+ wrapped = Common::Content::WrappedResponse.new(response, create_page_response_class)
91
+ return wrapped.result if wrapped.success?
92
+ raise "Could not create page from template #{id} - Error #{response.status}: #{response.body}"
81
93
  end
82
94
 
83
95
  private
@@ -93,3 +105,4 @@ end
93
105
 
94
106
  require 'ecoportal/api/v2/page'
95
107
  require 'ecoportal/api/v2/pages/stages'
108
+ require 'ecoportal/api/v2/pages/page_create_response'
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- GEM2_VERSION = "0.8.31"
3
+ GEM2_VERSION = "0.8.33"
4
4
  end
5
5
  end
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.31
4
+ version: 0.8.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-14 00:00:00.000000000 Z
11
+ date: 2022-09-23 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/page/stage.rb
232
232
  - lib/ecoportal/api/v2/page/stages.rb
233
233
  - lib/ecoportal/api/v2/pages.rb
234
+ - lib/ecoportal/api/v2/pages/page_create_response.rb
234
235
  - lib/ecoportal/api/v2/pages/page_stage.rb
235
236
  - lib/ecoportal/api/v2/pages/stages.rb
236
237
  - lib/ecoportal/api/v2/people.rb