|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Konsulting\JustGivingApiSdk\ResourceClients; |
|
4
|
|
|
|
|
5
|
|
|
use Konsulting\JustGivingApiSdk\ResourceClients\Models\RegisterCampaignRequest; |
|
6
|
|
|
|
|
7
|
|
|
class CampaignClient extends BaseClient |
|
8
|
|
|
{ |
|
9
|
|
|
protected $aliases = [ |
|
10
|
|
|
'registerFundraisingPage' => 'RegisterCampaignFundraisingPage', |
|
11
|
|
|
'retrieve' => 'GetCampaignDetails', |
|
12
|
|
|
'pages' => 'GetPagesForCampaign', |
|
13
|
|
|
'create' => 'CreateCampaign', |
|
14
|
|
|
'getAllByCharityId' => 'GetCampaignsByCharityId', |
|
15
|
|
|
]; |
|
16
|
|
|
|
|
17
|
|
|
public function retrieve($charityName, $campaignName) |
|
18
|
|
|
{ |
|
19
|
|
|
return $this->get("campaigns/" . $charityName . "/" . $campaignName); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
// Add support for v2 of the API to allow retrieval of newer campaigns |
|
23
|
|
|
public function retrieveBeta($campaignGUID) |
|
24
|
|
|
{ |
|
25
|
|
|
return $this->get("campaign/". $campaignGUID); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Test context account is not authorised to create a new campaign. |
|
31
|
|
|
* |
|
32
|
|
|
* @codeCoverageIgnore |
|
33
|
|
|
*/ |
|
34
|
|
|
public function create(RegisterCampaignRequest $registerCampaignRequest) |
|
35
|
|
|
{ |
|
36
|
|
|
return $this->post('campaigns', $registerCampaignRequest); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function pages($charityShortName, $campaignShortUrl) |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->get("campaigns/" . $charityShortName . "/" . $campaignShortUrl . "/pages"); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function getAllByCharityId($charityId) |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->get('campaigns/' . $charityId); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Test context account is not authorised to create a new campaign. |
|
51
|
|
|
* |
|
52
|
|
|
* @codeCoverageIgnore |
|
53
|
|
|
*/ |
|
54
|
|
|
public function registerFundraisingPage($registerCampaignFundraisingPageRequest) |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->post('campaigns', $registerCampaignFundraisingPageRequest); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|