1
|
|
|
<?php
|
2
|
|
|
/**
|
3
|
|
|
* Election 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\ElectionResponse;
|
11
|
|
|
|
12
|
|
|
/**
|
13
|
|
|
* Class Election Request
|
14
|
|
|
*
|
15
|
|
|
* @package Twigger\UnionCloud\API\Elections\Elections
|
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 ElectionRequest extends BaseRequest implements IRequest
|
23
|
|
|
{
|
24
|
|
|
/**
|
25
|
|
|
* Election Request constructor.
|
26
|
|
|
*
|
27
|
|
|
* @param Authentication $authentication
|
28
|
|
|
* @param Configuration $configuration
|
29
|
|
|
*/
|
30
|
|
|
public function __construct($authentication, $configuration)
|
31
|
|
|
{
|
32
|
|
|
parent::__construct($authentication, $configuration, ElectionResponse::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
|
|
|
/**
|
60
|
|
|
* Get all elections
|
61
|
|
|
*
|
62
|
|
|
* @return $this|\Twigger\UnionCloud\API\Response\IResponse|\Twigger\UnionCloud\API\ResourceCollection
|
63
|
|
|
*
|
64
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
65
|
|
|
* @throws \Twigger\UnionCloud\API\Exception\Request\RequestHistoryNotFound
|
66
|
|
|
* @throws \Twigger\UnionCloud\API\Exception\Response\BaseResponseException
|
67
|
|
|
*/
|
68
|
|
|
public function getAll()
|
69
|
|
|
{
|
70
|
|
|
$this->setAPIParameters(
|
71
|
|
|
'elections',
|
72
|
|
|
'GET'
|
73
|
|
|
);
|
74
|
|
|
|
75
|
|
|
$this->enableMode();
|
76
|
|
|
$this->enablePagination();
|
77
|
|
|
$this->enableTimes();
|
78
|
|
|
|
79
|
|
|
$this->call();
|
80
|
|
|
|
81
|
|
|
return $this->getReturnDetails();
|
82
|
|
|
}
|
83
|
|
|
|
84
|
|
|
/**
|
85
|
|
|
* Get a specific election
|
86
|
|
|
*
|
87
|
|
|
* @param integer $electionID ID of the election
|
88
|
|
|
* @return $this|\Twigger\UnionCloud\API\Response\IResponse|\Twigger\UnionCloud\API\ResourceCollection
|
89
|
|
|
*
|
90
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
91
|
|
|
* @throws \Twigger\UnionCloud\API\Exception\Request\RequestHistoryNotFound
|
92
|
|
|
* @throws \Twigger\UnionCloud\API\Exception\Response\BaseResponseException
|
93
|
|
|
*/
|
94
|
|
|
public function getByID($electionID)
|
95
|
|
|
{
|
96
|
|
|
$this->setAPIParameters(
|
97
|
|
|
'elections/'.$electionID,
|
98
|
|
|
'GET'
|
99
|
|
|
);
|
100
|
|
|
|
101
|
|
|
$this->enableMode();
|
102
|
|
|
|
103
|
|
|
$this->call();
|
104
|
|
|
|
105
|
|
|
return $this->getReturnDetails();
|
106
|
|
|
}
|
107
|
|
|
|
108
|
|
|
} |