Sha256: 56c5800e552959c2dbe13825490e62dadaaaf52bb227e3e73e045290d682d04e

Contents?: true

Size: 1.83 KB

Versions: 7

Compression:

Stored size: 1.83 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 V1
      extend Common::BaseClass
      include Common::Logging

      VERSION = "v1".freeze

      class_resolver :people_class, "Ecoportal::API::V1::People"
      class_resolver :person_schemas_class, "Ecoportal::API::V1::PersonSchemas"

      attr_reader :client, :logger

      # Creates an `V1` object to scope version specific api requests.
      # @note
      #   - The const `VERSION` determineds the api version that client will query against.
      #   - This means that each sublcass of `V1` should define their own `VERSION` constant.
      # @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.
      # @return [V1] an object with the api version suit.
      def initialize(api_key, host: "live.ecoportal.com", logger: default_logger)
        @logger = logger
        @client = Common::Client.new(
          api_key: api_key,
          host:    host,
          version: self.class::VERSION,
          logger:  @logger
        )
      end

      # Obtain specific object for people api requests.
      # @return [People] an instance object ready to make people api requests.
      def people
        people_class.new(client)
      end

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

require 'ecoportal/api/v1/person_schemas'
require 'ecoportal/api/v1/people'

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ecoportal-api-0.10.8 lib/ecoportal/api/v1.rb
ecoportal-api-0.10.7 lib/ecoportal/api/v1.rb
ecoportal-api-0.10.6 lib/ecoportal/api/v1.rb
ecoportal-api-0.10.5 lib/ecoportal/api/v1.rb
ecoportal-api-0.10.4 lib/ecoportal/api/v1.rb
ecoportal-api-0.10.1 lib/ecoportal/api/v1.rb
ecoportal-api-0.10.0 lib/ecoportal/api/v1.rb