Giter Club home page Giter Club logo

rspreedly's Introduction

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 => "[email protected]")
sub.token => nil
sub.save 
sub.token => "6af9994a57e420345897b1abb4c27a9db27fa4d0"

sub = RSpreedly::Subscriber.find(42)
sub.email = "[email protected]"
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 = RSpreedly::Invoice.new(:subscription_plan_id => 5, :subscriber => sub)
invoice.save

payment = RSpreedly::PaymentMethod::CreditCard.new(: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 © 2009 Richard Livsey. See LICENSE for details.

rspreedly's People

Contributors

rlivsey avatar andrewtimberlake avatar imajes avatar kevinansfield avatar

Stargazers

George Drummond avatar

Watchers

George Drummond avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.