rlivsey / rspreedly
- Source
- Commits
- Network (2)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
73ffe76
commit 73ffe76504a9a885b2a63a28f27a899e075615a1
tree 4d85f28b829a159f38ce257b3b58595a9ba13020
parent 6c7c4bd02400bf1238023e8fe2aa7ae28e643ce4
tree 4d85f28b829a159f38ce257b3b58595a9ba13020
parent 6c7c4bd02400bf1238023e8fe2aa7ae28e643ce4
| name | age | message | |
|---|---|---|---|
| |
.document | Wed Oct 28 12:47:18 -0700 2009 | |
| |
.gitignore | Wed Oct 28 12:47:18 -0700 2009 | |
| |
LICENSE | Wed Oct 28 12:47:18 -0700 2009 | |
| |
README.rdoc | ||
| |
Rakefile | Wed Oct 28 19:55:19 -0700 2009 | |
| |
VERSION | ||
| |
lib/ | ||
| |
rspreedly.gemspec | ||
| |
spec/ |
README.rdoc
RSpreedly
Ruby library to access the Spreedly API (all of it).
Why another one?
There are a few of these knocking about, but I couldn’t find one particular to my needs:
* Well covered with specs - currently 100% coverage * Covers the entire API, not just parts of it * Rubyish/ActiveRecord style access
Installation
It’s on Gemcutter, so as long as you’re setup to use that:
gem install rspreedly
Otherwise
gem install gemcutter
gem tumble
gem install rspreedly
Usage
Configure your API key and site name for your account:
RSpreedly::Config.setup do |config|
config.api_key = "your-api-key"
config.site_name = "your-site-name"
end
List subscribers
RSpreedly::Subscriber.find(:all).each do |subscriber|
# do something
end
CRUD access to subscribers
sub = RSpreedly::Subscriber.new(:customer_id => 42, :email => "somewhere@example.com")
sub.token => nil
sub.save
sub.token => "6af9994a57e420345897b1abb4c27a9db27fa4d0"
sub = RSpreedly::Subscriber.find(42)
sub.email = "new-email@example.com"
sub.save
sub = RSpreedly::Subscriber.find(69)
sub.destroy
Comp subscriptions
comp = RSpreedly::ComplimentarySubscription.new(:duration_quantity => 3, :duration_units => "months", :feature_level => "Pro")
sub = RSpreedly::Subscriber.find(69)
sub.comp_subscription(comp)
View all plans
plans = RSpreedly::SubscriptionPlan.find(:all)
Raise an invoice, and pay it
invoice = Invoice.new(:subscription_plan_id => 5, :subscriber => sub)
invoice.save
payment = RSpreedly::PaymentMethod::CreditCard(:card_type => 'visa', :number => '123456', ...)
invoice.pay(payment)
Error messages
invoice = RSpreedly::Invoice.new
invoice.save => false
invoice.errors => ["You must specify both the subscription plan id and subscriber information."]
See the specs and API docs at Spreedly for more details and the rest of the things it can do.
www.spreedly.com/manual/integration-reference/url-reference/
Todo
* Better specs for data we send to Spreedly. * Better docs.
Thanks
I studied the other Spreedly APIs and there may well be a line or three this library has in common with:
* http://github.com/terralien/spreedly-gem * http://github.com/erbmicha/spreedly/
Copyright
Copyright © 2009 Richard Livsey. See LICENSE for details.

