Class: Felis::API

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/felis/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ API

Returns a new instance of API.


9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/felis/api.rb', line 9

def initialize(options = {})
  @base_uri = options.fetch(:base_uri, "https://api.e2ma.net")
  @account_id = options.fetch(:account_id, ENV['EMMA_ACCOUNT_ID'] || nil)
  @private_key = options.fetch(:private_key, ENV['EMMA_PRIVATE_KEY'] || nil)
  @public_key = options.fetch(:public_key, ENV['EMMA_PUBLIC_KEY'] || nil)
  @debug = options.fetch(:debug, false)
  @timeout = options.fetch(:timeout, 30)
  
  @defaults = { basic_auth: { username: @public_key, password: @private_key } }
  
  setup_base_uri
end

Instance Attribute Details

#account_idObject

Returns the value of attribute account_id.


7
8
9
# File 'lib/felis/api.rb', line 7

def 
  @account_id
end

#base_uriObject

Returns the value of attribute base_uri.


7
8
9
# File 'lib/felis/api.rb', line 7

def base_uri
  @base_uri
end

#debugObject

Returns the value of attribute debug.


7
8
9
# File 'lib/felis/api.rb', line 7

def debug
  @debug
end

#private_keyObject

Returns the value of attribute private_key.


7
8
9
# File 'lib/felis/api.rb', line 7

def private_key
  @private_key
end

#public_keyObject

Returns the value of attribute public_key.


7
8
9
# File 'lib/felis/api.rb', line 7

def public_key
  @public_key
end

#timeoutObject

Returns the value of attribute timeout.


7
8
9
# File 'lib/felis/api.rb', line 7

def timeout
  @timeout
end

Instance Method Details

#delete(path, query = {}) ⇒ Object

HTTP DELETE Request


38
39
40
# File 'lib/felis/api.rb', line 38

def delete(path, query = {})
  request(:delete, path, query)
end

#get(path, query = {}) ⇒ Object

HTTP GET Request


23
24
25
# File 'lib/felis/api.rb', line 23

def get(path, query = {})
  request(:get, path, query)
end

#post(path, params = {}) ⇒ Object

HTTP POST Request


28
29
30
# File 'lib/felis/api.rb', line 28

def post(path, params = {})
  request(:post, path, params)
end

#put(path, params = {}) ⇒ Object

HTTP PUT Request


33
34
35
# File 'lib/felis/api.rb', line 33

def put(path, params = {})
  request(:put, path, params)
end