class Ecoportal::API::Common::Content::Client

@see Ecoportal::API::Common::Client

Attributes

logger[RW]

Public Class Methods

new(api_key:, version: "v2", host: "live.ecoportal.com", logger: nil) click to toggle source

@note the `api_key` will be automatically added as parameter `X-ECOPORTAL-API-KEY` in the header of the http requests.

Calls superclass method
# File lib/ecoportal/api/common/content/client.rb, line 10
def initialize(api_key:, version: "v2", host: "live.ecoportal.com", logger: nil)
  super(api_key: api_key, version: "v2", host: host, logger: logger)
end

Public Instance Methods

base_request() click to toggle source

Creates a HTTP object adding the `X-ECOPORTAL-API-KEY` param to the header. @note It configures HTTP so it only allows body data in json format. @return [HTTP] HTTP object.

# File lib/ecoportal/api/common/content/client.rb, line 32
def base_request
  @base_request ||= HTTP.headers("X-ECOPORTAL-API-KEY" => @api_key).accept(:json)
end
delete(path) click to toggle source
# File lib/ecoportal/api/common/content/client.rb, line 14
def delete(path)
  raise "DELETE operation does not have integration for api #{@version}"
end
post(path, data:, params: {}) click to toggle source

@see Ecoportal::API::Common::Client#post @param params [Hash] the header paramters of the http request (not including the api key). @option params [String] :template_id original template.

# File lib/ecoportal/api/common/content/client.rb, line 21
def post(path, data:, params: {})
  instrument("POST", path, params) do
    request do |http|
      http.post(url_for(path), json: data, params: params)
    end
  end
end