Class: Ecoportal::API::V2::Registers

Inherits:
Object
  • Object
show all
Extended by:
Common::BaseClass
Includes:
Enumerable
Defined in:
lib/ecoportal/api/v2/registers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Schemas

Returns an instance object ready to make schema api requests.

Parameters:

  • client (Common::Client)

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



14
15
16
# File 'lib/ecoportal/api/v2/registers.rb', line 14

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



10
11
12
# File 'lib/ecoportal/api/v2/registers.rb', line 10

def client
  @client
end

Instance Method Details

#each(params: {}, &block) ⇒ Object



25
26
27
28
# File 'lib/ecoportal/api/v2/registers.rb', line 25

def each(params: {}, &block)
  return to_enum(:each) unless block
  get.each(&block)
end

#getEnumerable<Register>

Gets all the registers via api request.

Returns:

  • (Enumerable<Register>)

    an Enumerable with all schemas already wrapped as Register objects.



20
21
22
23
# File 'lib/ecoportal/api/v2/registers.rb', line 20

def get
  response = client.get("/templates")
  Common::Content::WrappedResponse.new(response, register_class, key: "registers")
end