Class: Elemeno::Client
- Inherits:
-
Object
- Object
- Elemeno::Client
- Defined in:
- lib/elemeno.rb
Constant Summary collapse
- @@singleBase =
'singles/'
- @@collectionBase =
'collections/'
Instance Method Summary collapse
- #getCollection(collectionSlug) ⇒ Object
- #getCollectionItem(collectionSlug, itemSlug, options = nil) ⇒ Object
- #getCollectionItems(collectionSlug, options = nil) ⇒ Object
- #getCollections(options = nil) ⇒ Object
- #getSingle(singleSlug) ⇒ Object
- #getSingles(options = nil) ⇒ Object
-
#initialize(api_key) ⇒ Client
constructor
A new instance of Client.
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, = nil) return get(@@collectionBase + collectionSlug + '/items/' + itemSlug, getQuery(, ['sort'])) end |
#getCollectionItems(collectionSlug, options = nil) ⇒ Object
69 70 71 |
# File 'lib/elemeno.rb', line 69 def getCollectionItems(collectionSlug, = nil) return get(@@collectionBase + collectionSlug + '/items', getQuery(, ['filters', 'sort'])) end |
#getCollections(options = nil) ⇒ Object
61 62 63 |
# File 'lib/elemeno.rb', line 61 def getCollections( = nil) return get(@@collectionBase, getQuery(, ['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( = nil) return get(@@singleBase, getQuery(, ['sort'])) end |