Sha256: 16629a73c541868b21855ccb14190594133e5609bbd9d201bd113eaebdbe22fc

Contents?: true

Size: 1.82 KB

Versions: 6

Compression:

Stored size: 1.82 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"
      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

6 entries across 6 versions & 1 rubygems

Version Path
ecoportal-api-0.9.7 lib/ecoportal/api/v1.rb
ecoportal-api-0.9.6 lib/ecoportal/api/v1.rb
ecoportal-api-0.9.5 lib/ecoportal/api/v1.rb
ecoportal-api-0.9.4 lib/ecoportal/api/v1.rb
ecoportal-api-0.9.3 lib/ecoportal/api/v1.rb
ecoportal-api-0.9.2 lib/ecoportal/api/v1.rb