Sha256: aa855fe7c0ab2d20e3dc0c2d5b5923b03d88d06e191c67f8bef6c592e5e36277

Contents?: true

Size: 1.48 KB

Versions: 66

Compression:

Stored size: 1.48 KB

Contents

module Ecoportal
  module API
    module Common
      module Content
        # @see Ecoportal::API::Common::Client
        class Client < 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

66 entries across 66 versions & 2 rubygems

Version Path
ecoportal-api-v2-2.0.6 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-2.0.5 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-2.0.4 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-2.0.3 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-2.0.2 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-2.0.1 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-2.0.0 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-1.1.8 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-1.1.7 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-1.1.6 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-1.1.5 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-1.1.4 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-1.1.3 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-1.1.2 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-1.1.1 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-1.0.1 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-0.9.7 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-0.9.6 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-0.9.5 lib/ecoportal/api/common/content/client.rb
ecoportal-api-v2-0.9.4 lib/ecoportal/api/common/content/client.rb