Sha256: 4659e0ebd3b86061f1cc452b5eb8ac37a4fcfe37ae05ea75c45391a9b8b42007

Contents?: true

Size: 1.5 KB

Versions: 6

Compression:

Stored size: 1.5 KB

Contents

module Ecoportal
  module API
    module Common
      module Content
        # @see Ecoportal::API::Common::Client
        class Client < Ecoportal::API::Common::Client
          attr_accessor :logger

          # @note the `api_key` will be automatically added as parameter `X-ECOPORTAL-API-KEY` in the header of the http requests.
          def initialize(api_key:, version: "v2", host: "live.ecoportal.com", logger: nil)
            super(api_key: api_key, version: "v2", host: host, logger: logger)
          end

          def delete(path)
            raise "DELETE operation does not have integration for api #{@version}"
          end

          # @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.
          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

          # 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.
          def base_request
            @base_request ||= HTTP.headers("X-ECOPORTAL-API-KEY" => @api_key).accept(:json)
          end

        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ecoportal-api-v2-2.0.12 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-2.0.11 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-2.0.10 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-2.0.9 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-2.0.8 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-2.0.7 lib/ecoportal/api/common/content/client.rb