Passed
Push — master ( 7fc19c...13cdec )
by Toby
04:11 queued 10s
created

ElectionVoterDemographicRequest::getByElection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 16
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 * Election Voter Demographics Request class
4
 */
5
namespace Twigger\UnionCloud\API\Request;
6
7
8
use Twigger\UnionCloud\API\Auth\Authentication;
9
use Twigger\UnionCloud\API\Configuration;
10
use Twigger\UnionCloud\API\Response\ElectionVoterDemographicResponse;
11
12
/**
13
 * Class Election Voter Demographics Request
14
 *
15
 * @package Twigger\UnionCloud\API\Elections\ElectionVoterDemographics
16
 *
17
 * @license    https://opensource.org/licenses/GPL-3.0  GNU Public License v3
18
 *
19
 * @author     Toby Twigger <[email protected]>
20
 *
21
 */
22
class ElectionVoterDemographicRequest extends BaseRequest implements IRequest
23
{
24
    /**
25
     * Election Voter Demographics Request constructor.
26
     *
27
     * @param Authentication $authentication
28
     * @param Configuration $configuration
29
     */
30
    public function __construct($authentication, $configuration)
31
    {
32
        parent::__construct($authentication, $configuration, ElectionVoterDemographicResponse::class);
33
    }
34
35
36
    /**
37
     * Gets the current instance
38
     *
39
     * @return $this
40
     *
41
     */
42
    public function getInstance()
43
    {
44
        return $this;
45
    }
46
47
48
49
    /*
50
    |--------------------------------------------------------------------------
51
    | API Endpoint Definitions
52
    |--------------------------------------------------------------------------
53
    |
54
    | Define your API endpoints below here
55
    |
56
    */
57
58
    /**
59
     * Get election voter demographics for an election
60
     *
61
     * @param integer $electionID ID of the election
62
     * @param string $voterType actual or eligible
63
     *
64
     * @return $this|\Twigger\UnionCloud\API\Response\IResponse|\Twigger\UnionCloud\API\ResourceCollection
65
     *
66
     * @throws \GuzzleHttp\Exception\GuzzleException
67
     * @throws \Twigger\UnionCloud\API\Exception\Request\RequestHistoryNotFound
68
     * @throws \Twigger\UnionCloud\API\Exception\Response\BaseResponseException
69
     */
70
    public function getByElection($electionID, $voterType='actual')
71
    {
72
        $this->setAPIParameters(
73
            'elections/'.$electionID.'/election_voters_demographics',
74
            'GET'
75
        );
76
77
        $this->addQueryParameter('voter_type', $voterType);
78
79
        $this->enableMode();
80
        $this->enablePagination();
81
        $this->enableTimes();
82
83
        $this->call();
84
85
        return $this->getReturnDetails();
86
    }
87
88
}