Test Failed
Pull Request — master (#4)
by
unknown
09:57
created

CampaignClient::retrieveBeta()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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