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:  * Holds information about a donation
  5:  */
  6: class DonationInfo {
  7:     public $dateCreated;
  8:     public $amount;
  9:     public $sponsorMatchingPercentage;
 10:     public $nonProfitCampaignGuid;
 11:     public $publisherCampaignGuid;
 12:     public $sponsorCampaignGuid;
 13:     public $publisherGuid;
 14:     public $donorAccountGuid;
 15:     public $donorGuid;
 16:     public $publisherTransactionId;
 17:     
 18:     /**
 19:      * Construct a DonationInfo object with a given set of properties
 20:      * Required properties are amount, nonProfitCampaignGuid, publisherCampaignGuid, donorAccountGuid, donorGuid
 21:      * 
 22:      * @params Array $properties optionally takes a hash of donor information
 23:      */
 24:     public function __construct($properties=array()) {
 25:         $this->dateCreated = gmdate('Y-m-d\\TG:i:s\\Z', time());
 26:         $this->bind($properties);
 27:     }
 28:     
 29:     /**
 30:      * Set donation information from amount and guids
 31:      *
 32:      * @params string amount in dollars "40.00"
 33:      * @params string nonProfitCampaignGuid guid of the nonprofit campaign chosen
 34:      * @params string publisherCampaignGuid guid of the publisher campaign associated with donation
 35:      * @params string donorAccountGuid guid of the donor account
 36:      * @params string donorGuid guid of the donor itself
 37:      */
 38:     public function setDonation($amount, $nonProfitCampaignGuid, $publisherCampaignGuid, $donorAccountGuid, $donorGuid) {
 39:         $this->amount = $amount;
 40:         $this->nonProfitCampaignGuid = $nonProfitCampaignGuid;
 41:         $this->publisherCampaignGuid = $publisherCampaignGuid;
 42:         $this->donorAccountGuid = $donorAccountGuid;
 43:         $this->donorGuid = $donorGuid;
 44:     }
 45:     
 46:     /**
 47:      * Merge in properties from a given array
 48:      * 
 49:      * @params Array $properties array to merge properties in from
 50:      */
 51:     public function bind($properties=array()) {
 52:         foreach ($properties as $key => $value) {
 53:             $this->$key = $value;
 54:         }
 55:     }
 56:     
 57:     public function validate() {
 58:         return !empty($this->amount) &&
 59:                !empty($this->nonProfitCampaignGuid) &&
 60:                !empty($this->publisherCampaignGuid) &&
 61:                !empty($this->donorAccountGuid) &&
 62:                !empty($this->donorGuid);
 63:     }
 64: }
 65: 
 66: /**
 67:  * Holds information about a donor
 68:  */
 69: class DonorInfo {
 70:     // REQUIRED: the Donor's username
 71:     public $username;
 72:     // REQUIRED: the Donor's screen name (can be the same as username)
 73:     public $screenName;
 74:     public $sharePersonalInfo;
 75:     public $firstName;
 76:     public $lastName;
 77:     public $billingAddress1;
 78:     public $billingAddress2;
 79:     public $city;
 80:     public $state;
 81:     public $zip;
 82:     public $country;
 83:     public $cellPhoneNumber;
 84:     public $homePhoneNumber;
 85:     public $workPhoneNumber;
 86:     
 87:     /**
 88:      * Construct a DonorInfo object with a given set of properties
 89:      * Required properties are username, screenName
 90:      * 
 91:      * @params Array $properties optionally takes a hash of donor information
 92:      */
 93:     public function __construct($properties=array()) {
 94:         $this->bind($properties);
 95:     }
 96:     
 97:     /**
 98:      * Sets the user information for this DonorInfo object
 99:      * 
100:      * @params string $username the username for this Donor
101:      * @params string $screenname The screen name for this Donor, can be the username
102:      */
103:     public function setUser($username, $screenname=null) {
104:         if ($screenname == null) $screenname = $username;
105:         
106:         $this->username = $username;
107:         $this->screenName = $screenname;
108:     }
109:     
110:     /**
111:      * Merge in properties from a given array
112:      * 
113:      * @params Array $properties array to merge properties in from
114:      */
115:     public function bind($properties=array()) {
116:         foreach ($properties as $key => $value) {
117:             $this->$key = $value;
118:         }
119:     }
120:     
121:     public function validate() {
122:         return !empty($this->screenName) &&
123:                !empty($this->username);
124:     }
125: }
126: 
127: /**
128:  * Holds Account contact information for POST and PUT calls
129:  */
130: class AccountContactInfo { 
131:     public $billingAddress1;
132:     public $billingAddress2;
133:     public $billingCity;
134:     public $billingState;
135:     public $billingZip;
136:     public $billingCountry;
137:     
138:     /**
139:      * Merge in properties from a given array
140:      * 
141:      * @params Array $properties array to merge properties in from
142:      */
143:     public function bind($properties=array()) {
144:         foreach ($properties as $key => $value) {
145:             $this->$key = $value;
146:         }
147:     }
148: }
149: 
150: /**
151:  * Holds Account information for POST and PUT calls
152:  */
153: class AccountInfo {
154:     public $donorGuid;
155:     public $paymentMethod;
156:     public $creditCardNumber;
157:     public $cwCode;
158:     public $expirationMonth;
159:     public $expirationYear;
160:     public $accountNumber;
161:     public $routingNumber;
162:     public $accountHolderName;
163:     // AccountContactInfo object
164:     public $contactInfo;
165:     
166:     /**
167:      * Construct an AccountInfo object with a given set of properties
168:      * Required properties are donorGuid, paymentMethod, and either creditCardNumber or accountNumber
169:      * 
170:      * @params Array $properties optionally takes a hash of account and contact information
171:      */
172:     public function __construct($properties=array()) {
173:         $this->contactInfo = new AccountContactInfo();
174:         $this->bind($properties);
175:         $this->contactInfo->bind($properties);
176:     }
177:     
178:     /**
179:      * Sets the donor information for this AccountInfo and any contactInfo supplied
180:      * 
181:      * @params string $donorGuid guid of an existing donor
182:      * @params Array $contactInfo billing information for this account
183:      */
184:     public function setDonorInformation($donorGuid, $contactInfo=array()) {
185:         $this->donorGuid = $donorGuid;
186:         $this->contactInfo->bind($contactInfo);
187:     }
188:     
189:     /**
190:      * Set this AccountInfo object to point to a credit card
191:      * 
192:      * @params string $ccnum credit card number
193:      * @params string $cwcode CW code
194:      * @params string $expirationMonth expiration month
195:      * @params string $expirationYear expiration year
196:      */
197:     public function setCreditCard($ccnum, $cwcode, $expirationMonth, $expirationYear) {
198:         $this->paymentMethod = 'creditCard';
199:         $this->creditCardNumber = $ccnum;
200:         $this->cwCode = $cwcode;
201:         $this->expirationMonth = $expirationMonth;
202:         $this->expirationYear = $expirationYear;
203:     }
204:     
205:     /**
206:      * Set this AccountInfo object to point to ACH
207:      * 
208:      * @params string $account account number
209:      * @params string $routing routing number
210:      * @params string $accountName account holder name
211:      */
212:     public function setACH($account, $routing, $accountName) {
213:         $this->paymentMethod = 'ach';
214:         $this->accountNumber = $account;
215:         $this->routingNumber = $routing;
216:         $this->accountHolderName = $accountName;
217:     }
218:     
219:     /**
220:      * Merge in properties from a given array
221:      * 
222:      * @params Array $properties array to merge properties in from
223:      */
224:     public function bind($properties=array()) {
225:         foreach ($properties as $key => $value) {
226:             $this->$key = $value;
227:         }
228:     }
229:     
230:     public function validate() {
231:         return !empty($this->donorGuid) &&
232:                !empty($this->paymentMethod) &&
233:                !empty($this->contactInfo->billingAddress1) &&
234:                !empty($this->contactInfo->billingState);
235:     }
236: }
237: ?>
238: 
API documentation generated by ApiGen 2.8.0