Skip to content

Latest commit

 

History

History
59 lines (36 loc) · 1.86 KB

README.rdoc

File metadata and controls

59 lines (36 loc) · 1.86 KB

<img src=“https://badge.fury.io/rb/deezer_client.png” alt=“Gem Version” /> <img src=“https://travis-ci.org/dwaynemac/deezer_client.png” /> <img src=“https://codeclimate.com/github/dwaynemac/deezer_client.png” /> <img src=“https://gemnasium.com/dwaynemac/deezer_client.png” alt=“Dependecies” />

Deezer

www.deezer.com

Deezer is an online music library/player. Similar to Spotify and Grooveshark. It has an API for interaction with it’s content.

DeezerClient is simply that. A Ruby wrapper around Deezer’s API using at it’s core Typhoues through our library LogicalModel

Usage

Installation

For Rails 4, in your Gemfile add: (Should work in Rails 3 too, but I haven’t tested it yet)

gem 'protected_attributes' # I'm trying to put this into them but haven't managed yet.
gem 'logical_model'        # I'm trying to put this into them but haven't managed yet.
gem 'deezer_client'

Using it

Then you can do:

track = Deezer::Track.find(67606633)
track.title # "Until Nothing Remains"

track.artist # <Deezer::Artist: ....>
track.artist.name # "Boy Sets Fire"

track.album # <Deezer::Album: ....>
track.album.title # "While a Nation Sleeps..."

Async read

This client uses Typhoeus. So you can run several requests on parallel

Deezer::Track.async_find(67606633) { |res| @track = res }
Deezer::Album.async_find(6618908) { |res| @album = res }

@track # nil
@album # nil

Deezer::ParallelRequests.run

@track # <Deezer::Track: ....>
@album # <Deezer::Album: ....>

OAuth

@your_access_toeken = # ... get_access_token ...

Deezer::User.set_api_key 'access_token', @your_access_token

# now all requests by Deezer::User will include 'access_token' parameter