Class: FlyingSphinx::API
- Inherits:
-
Object
- Object
- FlyingSphinx::API
- Defined in:
- lib/flying_sphinx/api.rb
Constant Summary collapse
- APIServer =
'https://flying-sphinx.com'
- APIPath =
"/api/my/app"
- APIVersion =
2
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Instance Method Summary collapse
- #get(path, data = {}) ⇒ Object
-
#initialize(identifier, api_key, adapter = Faraday.default_adapter) ⇒ API
constructor
A new instance of API.
- #post(path, data = {}) ⇒ Object
- #put(path, data = {}) ⇒ Object
Constructor Details
#initialize(identifier, api_key, adapter = Faraday.default_adapter) ⇒ API
Returns a new instance of API.
12 13 14 15 16 |
# File 'lib/flying_sphinx/api.rb', line 12 def initialize(identifier, api_key, adapter = Faraday.default_adapter) @api_key = api_key @identifier = identifier @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
10 11 12 |
# File 'lib/flying_sphinx/api.rb', line 10 def adapter @adapter end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/flying_sphinx/api.rb', line 10 def api_key @api_key end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
10 11 12 |
# File 'lib/flying_sphinx/api.rb', line 10 def identifier @identifier end |
Instance Method Details
#get(path, data = {}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/flying_sphinx/api.rb', line 18 def get(path, data = {}) log('GET', path, data) do connection.get do |request| request.url normalize_path(path), data end end end |
#post(path, data = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/flying_sphinx/api.rb', line 26 def post(path, data = {}) log('POST', path, data) do connection.post normalize_path(path), data end end |
#put(path, data = {}) ⇒ Object
32 33 34 35 36 |
# File 'lib/flying_sphinx/api.rb', line 32 def put(path, data = {}) log('PUT', path, data) do connection.put normalize_path(path), data end end |