Class: TunecoreDirect::Base

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

Overview

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 => "[email protected]", 
                                    :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.get_people
response.status
=> "complete"
response.type
=> "people"
response.object.first.email
=> "[email protected]"
Author

Alex Kane ([email protected])

Copyright

Copyright © 2008 Tunecore

License

GNU LPGPL

Direct Known Subclasses

Album, Artwork, Person, Request, Response, Song

Constant Summary collapse

@@tunecore_server =
nil
@@api_key =
nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#logObject

Returns the value of attribute log.



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

def log
  @log
end

Class Method Details

.api_keyObject



81
82
83
# File 'lib/tunecore_direct/base.rb', line 81

def self.api_key
  @@api_key
end

.api_key=(key) ⇒ Object



77
78
79
# File 'lib/tunecore_direct/base.rb', line 77

def self.api_key=(key)
  @@api_key = key
end

.tunecore_serverObject



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

def self.tunecore_server
  @@tunecore_server
end

.tunecore_server=(uri) ⇒ Object



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

def self.tunecore_server=(uri)
  @@tunecore_server = uri
end

Instance Method Details

#api_keyObject



85
86
87
# File 'lib/tunecore_direct/base.rb', line 85

def api_key
  @@api_key
end

#to_xmlObject



89
90
91
# File 'lib/tunecore_direct/base.rb', line 89

def to_xml
  @xml
end

#tunecore_serverObject



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

def tunecore_server
  @@tunecore_server
end