Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 97 lines (60 sloc) 2.461 kB
b9b9214 @rlivsey initial 0.0.1 version
authored
1 = RSpreedly
2f8aa97 @rlivsey Initial commit to rspreedly.
authored
2
b9b9214 @rlivsey initial 0.0.1 version
authored
3 Ruby library to access the Spreedly API (all of it).
4
5 == Why another one?
6
7 There are a few of these knocking about, but I couldn't find one particular to my needs:
8
45f095a @rlivsey minor tweaks to get 100% spec coverage
authored
9 * Well covered with specs - currently 100% coverage
b9b9214 @rlivsey initial 0.0.1 version
authored
10 * Covers the entire API, not just parts of it
11 * Rubyish/ActiveRecord style access
12
af866af @rlivsey added installation notes
authored
13 == Installation
14
15 It's on Gemcutter, so as long as you're setup to use that:
16
17 gem install rspreedly
18
19 Otherwise
20
21 gem install gemcutter
22 gem tumble
23 gem install rspreedly
24
b9b9214 @rlivsey initial 0.0.1 version
authored
25 == Usage
26
27 Configure your API key and site name for your account:
28
29 RSpreedly::Config.setup do |config|
30 config.api_key = "your-api-key"
31 config.site_name = "your-site-name"
32 end
33
34 List subscribers
35
36 RSpreedly::Subscriber.find(:all).each do |subscriber|
37 # do something
38 end
39
40 CRUD access to subscribers
41
42 sub = RSpreedly::Subscriber.new(:customer_id => 42, :email => "somewhere@example.com")
43 sub.token => nil
44 sub.save
45 sub.token => "6af9994a57e420345897b1abb4c27a9db27fa4d0"
46
47 sub = RSpreedly::Subscriber.find(42)
48 sub.email = "new-email@example.com"
49 sub.save
50
51 sub = RSpreedly::Subscriber.find(69)
52 sub.destroy
53
54 Comp subscriptions
55
56 comp = RSpreedly::ComplimentarySubscription.new(:duration_quantity => 3, :duration_units => "months", :feature_level => "Pro")
57 sub = RSpreedly::Subscriber.find(69)
58 sub.comp_subscription(comp)
59
60 View all plans
61
62 plans = RSpreedly::SubscriptionPlan.find(:all)
63
64 Raise an invoice, and pay it
65
83d43af @imajes lets fix the docs too
imajes authored
66 invoice = RSpreedly::Invoice.new(:subscription_plan_id => 5, :subscriber => sub)
b9b9214 @rlivsey initial 0.0.1 version
authored
67 invoice.save
68
83d43af @imajes lets fix the docs too
imajes authored
69 payment = RSpreedly::PaymentMethod::CreditCard.new(:card_type => 'visa', :number => '123456', ...)
b9b9214 @rlivsey initial 0.0.1 version
authored
70 invoice.pay(payment)
71
e5dd36b @rlivsey Make errors returned from Spreedly available in an #errors array
authored
72 Error messages
73
74 invoice = RSpreedly::Invoice.new
75 invoice.save => false
76 invoice.errors => ["You must specify both the subscription plan id and subscriber information."]
77
b9b9214 @rlivsey initial 0.0.1 version
authored
78 See the specs and API docs at Spreedly for more details and the rest of the things it can do.
79
80 https://www.spreedly.com/manual/integration-reference/url-reference/
81
82 == Todo
83
84 * Better specs for data we send to Spreedly.
85 * Better docs.
86
87 == Thanks
88
89 I studied the other Spreedly APIs and there may well be a line or three this library has in common with:
90
91 * http://github.com/terralien/spreedly-gem
92 * http://github.com/erbmicha/spreedly/
2f8aa97 @rlivsey Initial commit to rspreedly.
authored
93
94 == Copyright
95
96 Copyright (c) 2009 Richard Livsey. See LICENSE for details.
Something went wrong with that request. Please try again.