Class: Elemeno::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/elemeno.rb

Constant Summary collapse

@@singleBase =
'singles/'
@@collectionBase =
'collections/'

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
16
# File 'lib/elemeno.rb', line 11

def initialize(api_key)
	@conn = Faraday.new(:url => 'https://api.elemeno.io/v1/', :headers => {'Authorization' => api_key}) do |conn|
		conn.use Faraday::Response::RaiseError
		conn.use Faraday::Adapter::NetHttp
	end
end

Instance Method Details

#getCollection(collectionSlug) ⇒ Object



65
66
67
# File 'lib/elemeno.rb', line 65

def getCollection(collectionSlug)
	return get(@@collectionBase + collectionSlug)
end

#getCollectionItem(collectionSlug, itemSlug, options = nil) ⇒ Object



73
74
75
# File 'lib/elemeno.rb', line 73

def getCollectionItem(collectionSlug, itemSlug, options = nil)
	return get(@@collectionBase + collectionSlug + '/items/' + itemSlug, getQuery(options, ['sort']))
end

#getCollectionItems(collectionSlug, options = nil) ⇒ Object



69
70
71
# File 'lib/elemeno.rb', line 69

def getCollectionItems(collectionSlug, options = nil)
	return get(@@collectionBase + collectionSlug + '/items', getQuery(options, ['filters', 'sort']))
end

#getCollections(options = nil) ⇒ Object



61
62
63
# File 'lib/elemeno.rb', line 61

def getCollections(options = nil)
	return get(@@collectionBase, getQuery(options, ['sort']))
end

#getSingle(singleSlug) ⇒ Object



57
58
59
# File 'lib/elemeno.rb', line 57

def getSingle(singleSlug)
	return get(@@singleBase + singleSlug)
end

#getSingles(options = nil) ⇒ Object



53
54
55
# File 'lib/elemeno.rb', line 53

def getSingles(options = nil)
	return get(@@singleBase, getQuery(options, ['sort']))
end