forked from deboorn/Fellowship-One-API-Helper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
132 lines (110 loc) · 3.4 KB
/
Copy pathindex.php
File metadata and controls
132 lines (110 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/*
* Simple example of how to use. Currently only the login and two simple requests are implemented.
* However, this should be enouph to jump start your 2nd party code. Will post more as developed.
*
* REQUIRES PHP 5 WITH CURL
*
*/
require('FellowshipOne.php');
$settings = array(
'key'=>'yourkeyhere',
'secret'=>'yoursecrethere',
'username'=>'yourusernamehere',
'password'=>'yourpasswordhere',
'baseUrl'=>'https://yourchurchcodehere.staging.fellowshiponeapi.com',
'debug'=>false,
);
$f1 = new FellowshipOne($settings);
if(($r = $f1->login()) === false){
die("Failed to loign");
}
echo "<pre>";
//uncomment any of the items below for demos
//note: you may want to cache your general information to reduce load on F1 API
//var_dump($f1->givingContributionTypes);
//var_dump($f1->givingAccountTypes);
//var_dump($f1->givingFundTypes);
//var_dump($f1->givingFunds);
//var_dump($f1->peopleHouseholdMemberTypes);
/*
//example of household search
$householdId = null;
if(($r = $f1->getHouseholdsByName("Doe")) !== null){
foreach($r['results']['household'] as $household){
//perform logic here
//var_dump($household['@id']);
$householdId = $household['@id'];
break;
}
}
*/
//example of finding a certain contribution type id
/*
//note: you should store this for future reference to reduce load on F1 API
$cTypes = $f1->givingContributionTypes;
$ccTypeId = null;
foreach($cTypes['contributionTypes']['contributionType'] as $cType){
if($cType['name']=="Credit Card"){
$ccTypeId = $cType['@id'];
break;
}
}
*/
//example of finding a certain giving fund id
/*
//note: you should store this for future reference to reduce load on F1 API
$gFunds = $f1->givingFunds;
$onlineGivingFundId = null;
foreach($gFunds['funds']['fund'] as $gFund){
if($gFund['name'] == "To Be Categorized - Online Giving"){
$onlineGivingFundId = $gFund['@id'];
break;
}
}
*/
//example of creating (saving) new contribution receipt (uses examples above)
/*
//fetch new contribution receipt model from F1 API
$model = $f1->contributionReceiptModel;
//set attributes of new contribution receipt
$model['contributionReceipt']['fund']['@id'] = (int) $onlineGivingFundId;
$today = new DateTime('now');//set received date to now
$model['contributionReceipt']['receivedDate'] = $today->format(DATE_ATOM);
$model['contributionReceipt']['contributionType']['@id'] = (int) $ccTypeId;
$model['contributionReceipt']['amount'] = (float) 25.25;
$model['contributionReceipt']['household']['@id'] = (int) $householdId;
$r = $f1->createContributionReceipt($model);
if($r){
var_dump($r['contributionReceipt']['@id']);
}
*/
//example of create new household
/*
$household = array(
"householdName" => "John Doe",
"householdSortName" => "Doe",
"householdFirstName" => "John",
);
$model = $f1->householdModel;
//var_dump($model);//see model structor
$model['household']['householdName'] = "John Doe";
$model['household']['householdSortName'] = "Doe";
$model['household']['householdFirstName'] = "John";
$r = $f1->createHousehold($model);
if($r){
var_dump($r['household']['@id']);
}
*/
//example of people search
/*
$r = $f1->searchPeople(array(//search attributes
"searchFor"=>"Doe",
"address"=>"12 Widget Place",
));
if($r && $r['results']['@count']>0){
foreach($r['results']['person'] as $person){
var_dump($person['firstName']);
}
}
*/