Class: Tinysou::Client
- Inherits:
-
Object
- Object
- Tinysou::Client
- Includes:
- Collections, Documents, Engines, Search
- Defined in:
- lib/tinysou/client.rb,
lib/tinysou/client/search.rb,
lib/tinysou/client/engines.rb,
lib/tinysou/client/documents.rb,
lib/tinysou/client/collections.rb
Overview
Client for the Tinysou API
Defined Under Namespace
Modules: Collections, Documents, Engines, Search
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #delete(path, params = nil) ⇒ Object
- #get(path, params = nil) ⇒ Object
-
#initialize(token) ⇒ Client
constructor
A new instance of Client.
- #post(path, data = nil) ⇒ Object
- #put(path, data = nil) ⇒ Object
Methods included from Search
Methods included from Documents
#create_document, #destroy_document, #document, #documents, #update_document
Methods included from Collections
#collection, #collections, #create_collection, #destroy_collection, #update_collection
Methods included from Engines
#create_engine, #destroy_engine, #engine, #engines, #update_engine
Constructor Details
#initialize(token) ⇒ Client
Returns a new instance of Client.
17 18 19 20 21 22 23 24 25 |
# File 'lib/tinysou/client.rb', line 17 def initialize(token) @token = token @conn = Faraday.new(url: 'http://api.tinysou.com/v1/') do |faraday| faraday.adapter Faraday.default_adapter end @headers = { 'Content-type' => 'application/json', 'Authorization' => "token #{@token}", 'User-Agent' => "Tinysou-Ruby/#{Tinysou::VERSION}" } end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
15 16 17 |
# File 'lib/tinysou/client.rb', line 15 def token @token end |
Instance Method Details
#delete(path, params = nil) ⇒ Object
39 40 41 |
# File 'lib/tinysou/client.rb', line 39 def delete(path, params = nil) request :delete, path, params, nil end |
#get(path, params = nil) ⇒ Object
27 28 29 |
# File 'lib/tinysou/client.rb', line 27 def get(path, params = nil) request :get, path, params, nil end |
#post(path, data = nil) ⇒ Object
31 32 33 |
# File 'lib/tinysou/client.rb', line 31 def post(path, data = nil) request :post, path, nil, data end |
#put(path, data = nil) ⇒ Object
35 36 37 |
# File 'lib/tinysou/client.rb', line 35 def put(path, data = nil) request :put, path, nil, data end |