Class: Intermix::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/intermix/client.rb

Constant Summary collapse

TABLES_PATH =

paths

'/tables'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


8
9
10
11
12
# File 'lib/intermix/client.rb', line 8

def initialize(configuration)
  raise ArgumentError, 'configuration cannot be nil.' unless configuration.present?

  @configuration = configuration
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



6
7
8
# File 'lib/intermix/client.rb', line 6

def configuration
  @configuration
end

Instance Method Details

#tables(fields = Table::FIELDS) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/intermix/client.rb', line 14

def tables(fields = Table::FIELDS)
  fields &&= Table::FIELDS
  query = "fields=#{fields.join(',')}" if fields.any?

  response = post(TABLES_PATH, query: query)

  if response.success?
    parsed_response = response.parsed_response
    parsed_response['data'].map { |entry| Intermix::Table.new(entry) }
  else
    []
  end
end