Class: Echowrap::Client

Inherits:
Object
  • Object
show all
Includes:
API::Artist, API::Oauth, API::Playlist, API::Sandbox, API::Song, API::TasteProfile, API::Track, Configurable
Defined in:
lib/echowrap/client.rb

Constant Summary

Constants included from API::Utils

API::Utils::API_KEY_CANNOT_CALL_THIS_METHOD, API::Utils::INVALID_PARAMETER, API::Utils::MISSING_OR_INVALID_KEY, API::Utils::MISSING_PARAMETER, API::Utils::RATE_LIMIT_EXCEEDED, API::Utils::SUCCESS

Instance Attribute Summary

Attributes included from Configurable

#api_key, #connection_options, #consumer_key, #endpoint, #middleware, #shared_secret

Instance Method Summary collapse

Methods included from Configurable

#configure, #credentials?, keys, #reset!

Methods included from API::Track

#track_analysis, #track_profile, #track_upload

Methods included from API::TasteProfile

#taste_profile_ban, #taste_profile_create, #taste_profile_delete, #taste_profile_favorite, #taste_profile_feed, #taste_profile_keyvalues, #taste_profile_list, #taste_profile_play, #taste_profile_predict, #taste_profile_profile, #taste_profile_rate, #taste_profile_read, #taste_profile_similar, #taste_profile_skip, #taste_profile_status, #taste_profile_update

Methods included from API::Oauth

#oauth_timestamp

Methods included from API::Song

#song_identify, #song_profile, #song_search

Methods included from API::Sandbox

#sandbox_access, #sandbox_list

Methods included from API::Playlist

#playlist_basic, #playlist_dynamic_create, #playlist_dynamic_delete, #playlist_dynamic_feedback, #playlist_dynamic_info, #playlist_dynamic_next, #playlist_dynamic_restart, #playlist_dynamic_steer, #playlist_static

Methods included from API::Artist

#artist_biographies, #artist_blogs, #artist_extract, #artist_familiarity, #artist_hotttnesss, #artist_images, #artist_list_genres, #artist_list_terms, #artist_news, #artist_profile, #artist_reviews, #artist_search, #artist_similar, #artist_songs, #artist_suggest, #artist_terms, #artist_top_hottt, #artist_top_terms, #artist_twitter, #artist_urls, #artist_video

Constructor Details

#initialize(options = {}) ⇒ Echowrap::Client

Initializes a new Client object

Parameters:

  • options (Hash) (defaults to: {})


29
30
31
32
33
# File 'lib/echowrap/client.rb', line 29

def initialize(options={})
  Echowrap::Configurable.keys.each do |key|
    instance_variable_set(:"@#{key}", options[key] || Echowrap.instance_variable_get(:"@#{key}"))
  end
end

Instance Method Details

#get(path, params = {}) ⇒ Object

Perform an HTTP GET request



36
37
38
# File 'lib/echowrap/client.rb', line 36

def get(path, params={})
  request(:get, path, params)
end

#post(path, params = {}) ⇒ Object

Perform an HTTP POST request



41
42
43
44
# File 'lib/echowrap/client.rb', line 41

def post(path, params={})
  signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params
  request(:post, path, params, signature_params)
end