class Ecoportal::API::V2::Pages::Stages
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 full `page`
@attr_reader client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
Attributes
Public Class Methods
@param client [Common::Client] a `Common::Client` object that holds the configuration of the api connection. @return [Schemas] an instance object ready to make schema api requests.
# File lib/ecoportal/api/v2/pages/stages.rb, line 19 def initialize(client) @client = client end
Public Instance Methods
Gets a stage via api. @note if the request has `success?` the returned `object.result` gives an object with that `Stage`. @param pid [String, Hash, Stage] the `id` of the target page. @param sid [String] the `id` of the target stage. @return [Ecoportal::API::V2::Stage, Ecoportal::API::V2::Pages::PageStage] the target stage.
# File lib/ecoportal/api/v2/pages/stages.rb, line 28 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
Requests to update an existing stage via api. @param doc [Hash, Stage] data that at least contains an `id` (internal or external) of the target stage. @param pid [String, nil] the `id` of the target page. @param sid [String] the `id` of the target stage. @return [Response] an object with the api response.
# File lib/ecoportal/api/v2/pages/stages.rb, line 42 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