|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Konsulting\JustGivingApiSdk\ResourceClients; |
|
4
|
|
|
|
|
5
|
|
|
use Konsulting\JustGivingApiSdk\ResourceClients\Models\AddImageRequest; |
|
6
|
|
|
use Konsulting\JustGivingApiSdk\ResourceClients\Models\AddVideoRequest; |
|
7
|
|
|
use Konsulting\JustGivingApiSdk\ResourceClients\Models\FundraisingPage; |
|
8
|
|
|
use Konsulting\JustGivingApiSdk\ResourceClients\Models\StoryUpdateRequest; |
|
9
|
|
|
use Konsulting\JustGivingApiSdk\ResourceClients\Models\UpdateFundraisingPageAttributionRequest; |
|
10
|
|
|
|
|
11
|
|
|
class FundraisingClient extends BaseClient |
|
12
|
|
|
{ |
|
13
|
|
|
protected $aliases = [ |
|
14
|
|
|
'urlCheck' => 'FundraisingPageUrlCheck', |
|
15
|
|
|
'suggestShortNames' => 'SuggestPageShortNames', |
|
16
|
|
|
'register' => 'RegisterFundraisingPage', |
|
17
|
|
|
'getByShortName' => 'GetFundraisingPageDetails', |
|
18
|
|
|
'getAllPages' => 'GetFundraisingPages', |
|
19
|
|
|
'getDonations' => 'GetFundraisingPageDonations', |
|
20
|
|
|
'getUpdates' => 'PageUpdates', |
|
21
|
|
|
'getUpdatesById' => 'PageUpdateById', |
|
22
|
|
|
'addPostToPageUpdate' => 'PageUpdatesAddPost', |
|
23
|
|
|
'deletePageUpdate' => 'DeleteFundraisingPageUpdates', |
|
24
|
|
|
'deleteAttribution' => 'DeleteFundraisingPageAttribution', |
|
25
|
|
|
'updateAttribution' => 'UpdateFundraisingPageAttribution', |
|
26
|
|
|
'appendToAttribution' => 'AppendToFundraisingPageAttribution', |
|
27
|
|
|
'getAttribution' => 'GetFundraisingPageAttribution', |
|
28
|
|
|
'uploadImage' => 'UploadImage', |
|
29
|
|
|
'uploadDefaultImage' => 'UploadDefaultImage', |
|
30
|
|
|
'addImage' => 'AddImageToFundraisingPage', |
|
31
|
|
|
'getImages' => 'GetImagesForFundraisingPage', |
|
32
|
|
|
'addVideo' => 'AddVideoToFundraisingPage', |
|
33
|
|
|
'getVideos' => 'GetVideosForFundraisingPage', |
|
34
|
|
|
'cancel' => 'CancelFundraisingPage', |
|
35
|
|
|
]; |
|
36
|
|
|
|
|
37
|
2 |
|
public function urlCheck($pageShortName) |
|
38
|
|
|
{ |
|
39
|
2 |
|
return $this->head("fundraising/pages/" . $pageShortName); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
1 |
|
public function suggestShortNames($preferredName) |
|
43
|
|
|
{ |
|
44
|
1 |
|
return $this->get("fundraising/pages/suggest?preferredName=" . urlencode($preferredName)); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
7 |
|
public function register(FundraisingPage $pageCreationRequest) |
|
48
|
|
|
{ |
|
49
|
7 |
|
return $this->put("fundraising/pages", $pageCreationRequest); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
2 |
|
public function getByShortName($pageShortName) |
|
53
|
|
|
{ |
|
54
|
2 |
|
return $this->get("fundraising/pages/" . $pageShortName); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
1 |
|
public function getAllPages() |
|
58
|
|
|
{ |
|
59
|
1 |
|
return $this->get("fundraising/pages"); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
1 |
|
public function getDonations($pageShortName, $pageSize = 50, $pageNumber = 0) |
|
63
|
|
|
{ |
|
64
|
1 |
|
return $this->get("fundraising/pages/" . $pageShortName . "/donations" . "?PageSize=" . $pageSize . "&PageNum=" . $pageNumber); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Cannot find any test donations with a third party reference. |
|
69
|
|
|
* |
|
70
|
|
|
* @codeCoverageIgnore |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getDonationsByReference($pageShortName, $reference) |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->get("fundraising/pages/" . $pageShortName . "/donations/ref/" . $reference); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
1 |
|
public function UpdateStory($pageShortName, $storyUpdate) |
|
78
|
|
|
{ |
|
79
|
1 |
|
$storyUpdateRequest = new StoryUpdateRequest(); |
|
80
|
1 |
|
$storyUpdateRequest->storySupplement = $storyUpdate; |
|
81
|
|
|
|
|
82
|
1 |
|
return $this->post("fundraising/pages/" . $pageShortName, $storyUpdateRequest); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
1 |
|
public function getUpdates($pageShortName) |
|
86
|
|
|
{ |
|
87
|
1 |
|
return $this->get("fundraising/pages/" . $pageShortName . "/updates/"); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
1 |
|
public function getUpdatesById($pageShortName, $updateId) |
|
91
|
|
|
{ |
|
92
|
1 |
|
return $this->get("fundraising/pages/" . $pageShortName . "/updates/" . $updateId); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
2 |
|
public function addPostToPageUpdate($pageShortName, $addPostToPageUpdateRequest) |
|
96
|
|
|
{ |
|
97
|
2 |
|
return $this->post("fundraising/pages/" . $pageShortName . "/updates/", $addPostToPageUpdateRequest); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
1 |
|
public function deletePageUpdate($pageShortName, $updateId) |
|
101
|
|
|
{ |
|
102
|
1 |
|
return $this->delete("fundraising/pages/" . $pageShortName . "/updates/" . $updateId); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
1 |
|
public function deleteAttribution($pageShortName) |
|
106
|
|
|
{ |
|
107
|
1 |
|
return $this->delete("fundraising/pages/" . $pageShortName . "/attribution"); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
3 |
|
public function updateAttribution($pageShortName, UpdateFundraisingPageAttributionRequest $updateAttributionRequest) |
|
111
|
|
|
{ |
|
112
|
3 |
|
return $this->put("fundraising/pages/" . $pageShortName . "/attribution", $updateAttributionRequest); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
1 |
|
public function appendToAttribution($pageShortName, $appendToAttributionRequest) |
|
116
|
|
|
{ |
|
117
|
1 |
|
return $this->post("fundraising/pages/" . $pageShortName . "/attribution", $appendToAttributionRequest); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
3 |
|
public function getAttribution($pageShortName) |
|
121
|
|
|
{ |
|
122
|
3 |
|
return $this->get("fundraising/pages/" . $pageShortName . "/attribution"); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
1 |
|
public function uploadImage($pageShortName, $caption, $filename, $imageContentType = null) |
|
126
|
|
|
{ |
|
127
|
1 |
|
$url = "fundraising/pages/" . $pageShortName . "/images?caption=" . urlencode($caption); |
|
128
|
|
|
|
|
129
|
1 |
|
return $this->postFile($url, $filename, $imageContentType); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
1 |
|
public function uploadDefaultImage($pageShortName, $filename, $imageContentType = null) |
|
133
|
|
|
{ |
|
134
|
1 |
|
$url = "fundraising/pages/" . $pageShortName . "/images/default"; |
|
135
|
|
|
|
|
136
|
1 |
|
return $this->postFile($url, $filename, $imageContentType); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
2 |
|
public function addImage($pageShortName, AddImageRequest $addImageRequest) |
|
140
|
|
|
{ |
|
141
|
2 |
|
return $this->put("fundraising/pages/" . $pageShortName . "/images", $addImageRequest); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
2 |
|
public function getImages($pageShortName) |
|
145
|
|
|
{ |
|
146
|
2 |
|
return $this->get("fundraising/pages/" . $pageShortName . "/images"); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
1 |
|
public function deleteImage($pageShortName, $imageName) |
|
150
|
|
|
{ |
|
151
|
1 |
|
return $this->delete("fundraising/pages/" . $pageShortName . "/images/" . $imageName); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
1 |
|
public function addVideo($pageShortName, AddVideoRequest $addVideoRequest) |
|
155
|
|
|
{ |
|
156
|
1 |
|
return $this->put("fundraising/pages/" . $pageShortName . "/videos", $addVideoRequest); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
1 |
|
public function getVideos($pageShortName) |
|
160
|
|
|
{ |
|
161
|
1 |
|
return $this->get("fundraising/pages/" . $pageShortName . "/videos"); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
1 |
|
public function cancel($pageShortName) |
|
165
|
|
|
{ |
|
166
|
1 |
|
return $this->delete("fundraising/pages/" . $pageShortName); |
|
167
|
|
|
} |
|
168
|
|
|
} |
|
169
|
|
|
|