class FiftyFifty
Public Class Methods
new(api_key)
click to toggle source
# File lib/fiftyfifty.rb, line 11 def initialize(api_key) @api_key = api_key self.class.base_uri "5050.gd/api/#{@api_key}" end
Public Instance Methods
campaigner_details(campaigner_id)
click to toggle source
Show details for a specific campaigner.
# File lib/fiftyfifty.rb, line 54 def campaigner_details(campaigner_id) return get("/campaigners/#{campaigner_id}") end
campaigners()
click to toggle source
List all campaigners currently running projects on 50/50.
# File lib/fiftyfifty.rb, line 49 def campaigners return get("/campaigners/list") end
get(url)
click to toggle source
Get’s response for a URL request. If the status is 400, raise a BadRequest
exception, otherwise, return the associated data
# File lib/fiftyfifty.rb, line 60 def get(url) response = Hashie::Mash.new(self.class.get(url)) if response.status == 400 raise BadRequest else return response.data end end
project_details(project_id)
click to toggle source
Show details for specific project.
# File lib/fiftyfifty.rb, line 26 def project_details(project_id) return get("/projects/#{project_id}") end
project_donations(project_id)
click to toggle source
List donations for a specific project.
# File lib/fiftyfifty.rb, line 31 def project_donations(project_id) return get("/projects/#{project_id}/donations") end
project_pledges(project_id)
click to toggle source
List of users who have pledged to take part in a specific project.
# File lib/fiftyfifty.rb, line 43 def project_pledges(project_id) return get("/projects/#{project_id}/pledges") end
projects()
click to toggle source
Lists all current 50/50 projects.
# File lib/fiftyfifty.rb, line 21 def projects return get("/projects/list") end
register_project_donation(project_id, amount)
click to toggle source
Notify us of a new donation, i.e. one that you may have received in person, or from another online payment mechanism. Your API key must be associated with the requested project for this to be successful.
# File lib/fiftyfifty.rb, line 38 def register_project_donation(project_id, amount) return get("/projects/#{project_id}/donations/notify/#{amount}") end
statistics()
click to toggle source
# File lib/fiftyfifty.rb, line 16 def statistics return get("/statistics") end