Class: Tinysou::Client

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from Search

#autocomplete, #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

#tokenObject

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