just_giving

A ruby wrapper for the justgiving.com API (api.justgiving.com/docs)

Installation

gem install just_giving

Usage

Simple Donation Integration

Just giving provides 2 separate API's - Simple Donation Integration (SDI) for making donations and an XML API for querying and creating data.

This gem currently provides functionality to link to SDI, if you are using rails you can use view helpers like so:

<%= link_to 'Click to donate', just_giving_charity_page_url('short_name') %>
<%= link_to 'Click to donate', just_giving_charity_donation_page_url('id', 
  {:suggested_amount => 2..100000, :donation_id => 'JUSTGIVING-DONATION-ID', :amount => 2..100000, 
  :frequency => %w(single monthly), :exit_url => 'http://myredirect.com'}) %>
<%= link_to 'Click to donate', just_giving_fundraising_page_url('short_url') %>
<%= link_to 'Click to donate', just_giving_fundraising_donation_url('pageId', 
  {:suggested_amount => 2..100000, :amount => 2..100000, :exit_url => 'http://myredirect.com', 
  :donation_id => 'JUSTGIVING-DONATION-ID'}) %>)

As you can see just_giving_charity_donation_page_url and just_giving_fundraising_donation_url take and optional options hash - supply as many or as few of these as you need.

API

Configure

JustGiving::Configuration.application_id = YOUR_APP_ID

JustGiving::Configuration.ca_path = “/System/Library/OpenSSL/certs” # (defaults to “/usr/lib/ssl/certs”)

JustGiving::Configuration.environment = :production (defaults to :staging)

JustGiving::Configuration.username = 'test@example.com' # Needed for actions that require auth

JustGiving::Configuration.password = 'secret' # Needed for actions that require auth

Account calls

JustGiving::Account.new(YOUR_EMAIL).pages

JustGiving::Account.new.create({:title => 'Mr', :firstName => 'Test', :lastName => 'McTest', :address => {:line1 => 'Unit 100', :townOrCity => 'London', :country => 'UK', :postcodeOrZipcode => 'ec1r 0jh'}, :email => 'test@example.com', :password => 'password', :acceptTermsAndConditions => true})

Fundraising calls

JustGiving::Fundraising.new('short-name').donations

For further examples please check the tests

Note that a 404 will raise a JustGiving::NotFound error

A 400 response means the params supplied are wrong - this will return an errors collection with the details, eg:

response = JustGiving::Account.new('unkown@unkown.com').password_reminder

response.errors # errors array

TODO

Contributing to just_giving

Copyright © 2011 Mint Digital. See LICENSE.txt for further details.