class Intermix::Client
Constants
- TABLES_PATH
paths
Attributes
configuration[R]
Public Class Methods
new(configuration)
click to toggle source
# File lib/intermix/client.rb, line 8 def initialize(configuration) raise ArgumentError, 'configuration cannot be nil.' unless configuration.present? @configuration = configuration end
Public Instance Methods
tables(fields = Table::FIELDS)
click to toggle source
# 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
Private Instance Methods
headers()
click to toggle source
# File lib/intermix/client.rb, line 36 def headers { 'Authorization' => "Token #{@configuration.api_token}" } end
post(path, query: nil)
click to toggle source
# File lib/intermix/client.rb, line 30 def post(path, query: nil) uri = "#{@configuration.base_uri}#{path}?" + query HTTParty.post(uri, headers: headers) end