Class: NexosisApi::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Datasets, Imports, Sessions
Defined in:
lib/nexosis_api/client.rb,
lib/nexosis_api/client/imports.rb,
lib/nexosis_api/client/datasets.rb,
lib/nexosis_api/client/sessions.rb
more...

Overview

Primary entry point to working with Nexosis API

Defined Under Namespace

Modules: Datasets, Imports, Sessions

Instance Method Summary collapse

Methods included from Imports

#import_from_s3, #list_imports, #retrieve_import

Methods included from Datasets

#create_dataset_csv, #create_dataset_json, #get_dataset, #get_dataset_csv, #list_datasets, #remove_dataset

Methods included from Sessions

#create_forecast_session, #create_impact_session, #estimate_forecast_session, #estimate_impact_session, #get_session, #get_session_results, #list_sessions, #remove_session, #remove_sessions

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)
[View source]

32
33
34
35
36
37
38
# File 'lib/nexosis_api/client.rb', line 32

def initialize(options = {})
    raise ArgumentError, 'api_key was not defined' unless options[:api_key].nil? == false
    @api_key = options[:api_key]
    self.class.base_uri options[:base_uri] unless options[:base_uri].nil?
    @headers = {"api-key" => @api_key, "content-type" => "application/json"}
		    @options = {:headers => @headers, :format => :json}
end

Instance Method Details

#get_account_balanceString

Gets the current account balance.

Examples:

Get account balance

client.

Returns:

  • (String)

    a string with the numeric balance and currency identifier postfix - 10.0 USD

[View source]

45
46
47
48
49
# File 'lib/nexosis_api/client.rb', line 45

def ()
    session_url = '/sessions'
			response = self.class.get(session_url,@options)
			response.headers["nexosis-account-balance"]
end