require 'Logger' module TunecoreDirect # = TunecoreDirect # TunecoreDirect is a REST/XML based web service API that allows Tunecore partners to "white label" the Tunecore # media distribution platform, letting you offer Tunecore's services to your customers transparently. # The web service allows a partner to: # # 1. Create/Query customer accounts # 2. Publish albums that belong to customer accounts # # To get started with the API first obtain an API key, then have a look at these three class which you will use to interact with TuneCore: # * Person # * Album # * Song # These three classes provide all the functionality you will need to easily manage your accounts and publish albums through TuneCore. Under the hood they use the # Request and Response classes to interact with the TunecoreDirect REST API. # --- # === Short Example # Set up your environment: # # require 'tunecore_direct' # TunecoreDirect::Base.tunecore_server = "http://localhost:3000" # TunecoreDirect::Base.api_key = "57247d992de24d7840a1b75dc2e5c30a" # request = TunecoreDirect::Request.new # # Create a person: # # Make a new a person object and set all the attributes # person = TunecoreDirect::Person.new( :name => "Alex Kane", # :email => "alex@gmail.com", # :phone_number => "212-555-1212", # :country => "United States", # :postal_code => "11201" ) # # Create the person on the Tunecore server # person.create # => false # # Hmm it didn't work. Let's find out why. # person.errors # => [{:message=>"can't be blank", :attribute=>"password"}] # # Doh! We forgot to set a password. # person.password = "paSSword" # person.create # => true # # It worked, and we can now get the person_id which we will use later to create albums for this person # person.person_id # => 55342 # # Get a list of your people: # # response = request.list_people # response.status # => "complete" # response.type # => "people" # response.object.first.email # => "joe1243@blow.com" # # Author:: Alex Kane (mailto:alex@tunecore.com) # Copyright:: Copyright (c) 2008 Tunecore # License:: GNU LPGPL class TunecoreDirect::Base attr_accessor :log @@tunecore_server = nil @@api_key = nil def log( method, params=nil ) @log = Logger.new(STDOUT) if @log.nil? @log.send(method, params) end def self.tunecore_server=(uri) @@tunecore_server = uri end def self.tunecore_server @@tunecore_server end def tunecore_server @@tunecore_server end def self.api_key=(key) @@api_key = key end def self.api_key @@api_key end def api_key @@api_key end def to_xml @xml end end end