Class: Felis::API
Instance Attribute Summary collapse
-
#account_id ⇒ Object
Returns the value of attribute account_id.
-
#base_uri ⇒ Object
Returns the value of attribute base_uri.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#private_key ⇒ Object
Returns the value of attribute private_key.
-
#public_key ⇒ Object
Returns the value of attribute public_key.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#delete(path, query = {}) ⇒ Object
HTTP DELETE Request.
-
#get(path, query = {}) ⇒ Object
HTTP GET Request.
-
#initialize(options = {}) ⇒ API
constructor
A new instance of API.
-
#post(path, params = {}) ⇒ Object
HTTP POST Request.
-
#put(path, params = {}) ⇒ Object
HTTP PUT Request.
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( = {}) @base_uri = .fetch(:base_uri, "https://api.e2ma.net") @account_id = .fetch(:account_id, ENV['EMMA_ACCOUNT_ID'] || nil) @private_key = .fetch(:private_key, ENV['EMMA_PRIVATE_KEY'] || nil) @public_key = .fetch(:public_key, ENV['EMMA_PUBLIC_KEY'] || nil) @debug = .fetch(:debug, false) @timeout = .fetch(:timeout, 30) @defaults = { basic_auth: { username: @public_key, password: @private_key } } setup_base_uri end |
Instance Attribute Details
#account_id ⇒ Object
Returns the value of attribute account_id.
7 8 9 |
# File 'lib/felis/api.rb', line 7 def account_id @account_id end |
#base_uri ⇒ Object
Returns the value of attribute base_uri.
7 8 9 |
# File 'lib/felis/api.rb', line 7 def base_uri @base_uri end |
#debug ⇒ Object
Returns the value of attribute debug.
7 8 9 |
# File 'lib/felis/api.rb', line 7 def debug @debug end |
#private_key ⇒ Object
Returns the value of attribute private_key.
7 8 9 |
# File 'lib/felis/api.rb', line 7 def private_key @private_key end |
#public_key ⇒ Object
Returns the value of attribute public_key.
7 8 9 |
# File 'lib/felis/api.rb', line 7 def public_key @public_key end |
#timeout ⇒ Object
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 |