Overview

Namespaces

  • None
  • PHP

Classes

  • Account
  • AccountContactInfo
  • AccountInfo
  • Donation
  • DonationInfo
  • Donor
  • DonorInfo
  • iGivefirst

Exceptions

  • iGivefirst_AccountInformationIncomplete
  • iGivefirst_AccountNotCreated
  • iGivefirst_AccountNotUpdated
  • iGivefirst_AuthenticationError
  • iGivefirst_DonationInformationIncomplete
  • iGivefirst_DonationNotCreated
  • iGivefirst_DonorAlreadyExists
  • iGivefirst_DonorInformationIncomplete
  • iGivefirst_DonorNotCreated
  • iGivefirst_Error
  • iGivefirst_HttpError
  • iGivefirst_ObjectAlreadyExists
  • iGivefirst_ObjectNotFound
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: /**
 4:  * Donation interface for the iGivefirst Donation API
 5:  * Allows the lookup and creation of Donations
 6:  */
 7: class Donation {
 8:     private $api;
 9:     
10:     public function __construct($api) {
11:         $this->api = $api;
12:     }
13:     
14:     /**
15:      * Create a donation with the given information
16:      * 
17:      * @param DonationInfo $donation Object containing the donation information
18:      *
19:      * @throws iGivefirst_DonationInformationIncomplete if the donation information was not complete enough
20:      * @throws iGivefirst_DonationNotCreated if the parameters were not valid
21:      * 
22:      * @returns Array a hash containing the guid of the newly created donation
23:      */
24:     public function create(DonationInfo $donation) {
25:         if (!$donation->validate()) {
26:             throw new iGivefirst_DonationInformationIncomplete();
27:         }
28:         
29:         $req = $this->api->client->post('/donation');
30:         $req->setBody(json_encode($donation), 'application/json');
31:         
32:         try {
33:             return $this->api->execute($req)->json();
34:         }
35:         catch(iGivefirst_HttpError $e) {
36:             throw new iGivefirst_DonationNotCreated($e);
37:         }
38:     }
39:      
40:     /**
41:      * Get a donation by guid
42:      * 
43:      * @params string $guid guid of the donation to look up
44:      * 
45:      * @throws iGivefirst_HttpError if an error occured
46:      * 
47:      * @returns Array a hash containing all the donation information or null
48:      */
49:     public function get($guid) {
50:         $req = $this->api->client->get('/donation/' . $guid);
51: 
52:         try {
53:             return $this->api->execute($req)->json();
54:         }
55:         catch(iGivefirst_ObjectNotFound $e) {
56:             return null;
57:         }
58:         catch(iGivefirst_HttpError $e) {
59:             throw $e;
60:         }
61:     }
62: }
63: ?>
64: 
API documentation generated by ApiGen 2.8.0