Class: Ecoportal::API::V1

Inherits:
Object
  • Object
show all
Extended by:
Common::BaseClass
Includes:
Common::Logging
Defined in:
lib/ecoportal/api/v1.rb,
lib/ecoportal/api/v1/people.rb,
lib/ecoportal/api/v1/person.rb,
lib/ecoportal/api/v1/job_status.rb,
lib/ecoportal/api/v1/schema_field.rb,
lib/ecoportal/api/v1/person_schema.rb,
lib/ecoportal/api/v1/person_details.rb,
lib/ecoportal/api/v1/person_schemas.rb,
lib/ecoportal/api/v1/schema_field_value.rb

Direct Known Subclasses

Internal

Defined Under Namespace

Classes: JobStatus, People, Person, PersonDetails, PersonSchema, PersonSchemas, SchemaField, SchemaFieldValue

Constant Summary collapse

VERSION =
"v1".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common::BaseClass

class_resolver, redef_without_warning, resolve_class

Constructor Details

#initialize(api_key, host: "live.ecoportal.com", logger: default_logger) ⇒ V1

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.

Creates an V1 object to scope version specific api requests.

Parameters:

  • api_key (String)

    the key version to stablish the api connection.

  • host (String) (defaults to: "live.ecoportal.com")

    api server domain.

  • logger (Logger) (defaults to: default_logger)

    an object with Logger interface to generate logs.



24
25
26
27
28
29
30
31
32
# File 'lib/ecoportal/api/v1.rb', line 24

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

Instance Attribute Details

#clientCommon::Client (readonly)

a Common::Client object that holds the configuration of the api connection.

Returns:



5
6
7
# File 'lib/ecoportal/api/v1.rb', line 5

def client
  @client
end

#loggerLogger (readonly)

the logger.

Returns:

  • (Logger)

    the current value of logger



5
6
7
# File 'lib/ecoportal/api/v1.rb', line 5

def logger
  @logger
end

Instance Method Details

#peoplePeople

Obtain specific object for people api requests.

Returns:

  • (People)

    an instance object ready to make people api requests.



36
37
38
# File 'lib/ecoportal/api/v1.rb', line 36

def people
  people_class.new(client)
end

#person_schemasPersonSchemas

Obtain specific object for schema api requests.

Returns:

  • (PersonSchemas)

    an instance object ready to make schema api requests.



42
43
44
# File 'lib/ecoportal/api/v1.rb', line 42

def person_schemas
  person_schemas_class.new(client)
end