Class: Ecoportal::API::V2::Pages::Stages
- Inherits:
-
Object
- Object
- Ecoportal::API::V2::Pages::Stages
- Extended by:
- Common::BaseClass
- Includes:
- Common::Content::DocHelpers
- Defined in:
- lib/ecoportal/api/v2/pages/stages.rb
Overview
This API Integration level has been added due to relative permissions
- a user with api access may have access to a specific
stage
but not to the fullpage
Instance Attribute Summary collapse
-
#client ⇒ Common::Client
readonly
a
Common::Client
object that holds the configuration of the api connection.
Instance Method Summary collapse
-
#get(pid:, sid:) ⇒ Ecoportal::API::V2::Stage, Ecoportal::API::V2::Pages::PageStage
Gets a stage via api.
-
#initialize(client) ⇒ Schemas
constructor
An instance object ready to make schema api requests.
-
#update(doc, pid: nil, sid:) ⇒ Response
Requests to update an existing stage via api.
Methods included from Common::Content::DocHelpers
#array_id_index, #array_id_item, #array_ids, #get_body, #get_id
Constructor Details
#initialize(client) ⇒ Schemas
Returns an instance object ready to make schema api requests.
19 20 21 |
# File 'lib/ecoportal/api/v2/pages/stages.rb', line 19 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Common::Client (readonly)
a Common::Client
object that holds the configuration of the api connection.
9 10 11 |
# File 'lib/ecoportal/api/v2/pages/stages.rb', line 9 def client @client end |
Instance Method Details
#get(pid:, sid:) ⇒ Ecoportal::API::V2::Stage, Ecoportal::API::V2::Pages::PageStage
Note:
if the request has success?
the returned object.result
gives an object with that Stage
.
Gets a stage via api.
27 28 29 30 31 32 33 34 |
# File 'lib/ecoportal/api/v2/pages/stages.rb', line 27 def get(pid:, sid:) pid = get_id(pid) response = client.get("/pages/#{CGI.escape(pid)}/stages/#{CGI.escape(sid)}/") wrapped = Common::Content::WrappedResponse.new(response, page_stage_class) return wrapped.result if wrapped.success? raise "Could not get stage {#{sid}} of page #{pid} - Error #{response.status}: #{response.body}" end |
#update(doc, pid: nil, sid:) ⇒ Response
Requests to update an existing stage via api.
39 40 41 42 43 44 |
# File 'lib/ecoportal/api/v2/pages/stages.rb', line 39 def update(doc, pid: nil, sid:) body = get_body(doc) pid = pid || get_id(doc) path = "/pages/#{CGI.escape(pid)}/stages/#{CGI.escape(sid)}/" client.patch(path, data: body) end |