Sha256: db69642ce062a0e6080b547f75ffcb93025d7dd88ed3d69cc9cf0a8a5cbc121d

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

module Ecoportal
  module API
    # @attr_reader client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
    # @attr_reader logger [Logger] the logger.
    class V2
      extend Common::BaseClass
      include Common::Logging

      VERSION = "v2"

      class_resolver :registers_class, "Ecoportal::API::V2::Registers"
      class_resolver :pages_class,     "Ecoportal::API::V2::Pages"

      attr_reader :client, :logger

      # Creates an `V2` object to scope version specific api requests.
      # @param api_key [String] the key version to stablish the api connection.
      # @param host [String] api server domain.
      # @param logger [Logger] an object with `Logger` interface to generate logs.
      def initialize(api_key, host: "live.ecoportal.com", logger: default_logger)
        @logger = logger
        @client = Common::Content::Client.new(
          api_key: api_key,
          host:    host,
          version: self.class::VERSION,
          logger:  @logger
        )
      end

      # Obtain specific object for schema api requests.
      # @return [Registers] an instance object ready to make registers api requests.
      def registers
        registers_class.new(client)
      end

      # Obtain specific object for pages api requests.
      # @return [Pages] an instance object ready to make pages api requests.
      def pages
        pages_class.new(client)
      end

    end
  end
end

require 'ecoportal/api/v2/registers'
require 'ecoportal/api/v2/pages'
#require 'ecoportal/api/v2/stages'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ecoportal-api-oozes-0.5.5 lib/ecoportal/api/v2.rb