EventRequest::update()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 11
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 * Event 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\EventResponse;
11
12
/**
13
 * Class Event Request
14
 *
15
 * @package Twigger\UnionCloud\API\Events\Events
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 EventRequest extends BaseRequest implements IRequest
23
{
24
    /**
25
     * Event Request constructor.
26
     *
27
     * @param Authentication $authentication
28
     * @param Configuration $configuration
29
     */
30
    public function __construct($authentication, $configuration)
31
    {
32
        parent::__construct($authentication, $configuration, EventResponse::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
     * Create an Event
60
     * 
61
     * @param mixed[] $event Event parameters
62
     * 
63
     * @return $this|\Twigger\UnionCloud\API\Response\IResponse|\Twigger\UnionCloud\API\ResourceCollection
64
     * 
65
     * @throws \GuzzleHttp\Exception\GuzzleException
66
     * @throws \Twigger\UnionCloud\API\Exception\Request\RequestHistoryNotFound
67
     * @throws \Twigger\UnionCloud\API\Exception\Response\BaseResponseException
68
     */
69
    public function create($event)
70
    {
71
        $this->setAPIParameters(
72
            'events',
73
            'POST',
74
            $event
75
        );
76
        $this->setContentType('application/json');
77
78
        $this->call();
79
        
80
        return $this->getReturnDetails();
81
    }
82
83
    /**
84
     * Update an Event
85
     *
86
     * @param integer $eventID ID of the event to update
87
     * @param mixed[] $event Details of the event to update
88
     *
89
     * @return $this|\Twigger\UnionCloud\API\Response\IResponse|\Twigger\UnionCloud\API\ResourceCollection
90
     *
91
     * @throws \GuzzleHttp\Exception\GuzzleException
92
     * @throws \Twigger\UnionCloud\API\Exception\Request\RequestHistoryNotFound
93
     * @throws \Twigger\UnionCloud\API\Exception\Response\BaseResponseException
94
     */
95
    public function update($eventID, $event)
96
    {
97
        $this->setAPIParameters(
98
            'events/'.$eventID,
99
            'PUT',
100
            $event
101
        );
102
103
        $this->call();
104
105
        return $this->getReturnDetails();
106
    }
107
108
    /**
109
     * Cancel an Event
110
     *
111
     * @param integer $eventID ID of the event to update
112
     *
113
     * @return $this|\Twigger\UnionCloud\API\Response\IResponse|\Twigger\UnionCloud\API\ResourceCollection
114
     *
115
     * @throws \GuzzleHttp\Exception\GuzzleException
116
     * @throws \Twigger\UnionCloud\API\Exception\Request\RequestHistoryNotFound
117
     * @throws \Twigger\UnionCloud\API\Exception\Response\BaseResponseException
118
     */
119
    public function cancel($eventID)
120
    {
121
        $this->setAPIParameters(
122
            'events/'.$eventID.'/cancel',
123
            'PUT'
124
        );
125
126
        $this->call();
127
128
        return $this->getReturnDetails();
129
    }
130
131
    /**
132
     * Get all Events in the Union
133
     *
134
     * @return $this|\Twigger\UnionCloud\API\Response\IResponse|\Twigger\UnionCloud\API\ResourceCollection
135
     *
136
     * @throws \GuzzleHttp\Exception\GuzzleException
137
     * @throws \Twigger\UnionCloud\API\Exception\Request\RequestHistoryNotFound
138
     * @throws \Twigger\UnionCloud\API\Exception\Response\BaseResponseException
139
     */
140
    public function getAll()
141
    {
142
        $this->setAPIParameters(
143
            'events',
144
            'GET'
145
        );
146
147
        $this->enableMode();
148
        $this->enablePagination();
149
        $this->enableTimes();
150
151
        $this->call();
152
153
        return $this->getReturnDetails();
154
    }
155
156
    /**
157
     * Get a specific Event
158
     *
159
     * @param integer $eventID ID of the Event
160
     *
161
     * @return $this|\Twigger\UnionCloud\API\Response\IResponse|\Twigger\UnionCloud\API\ResourceCollection
162
     *
163
     * @throws \GuzzleHttp\Exception\GuzzleException
164
     * @throws \Twigger\UnionCloud\API\Exception\Request\RequestHistoryNotFound
165
     * @throws \Twigger\UnionCloud\API\Exception\Response\BaseResponseException
166
     */
167
    public function getByID($eventID)
168
    {
169
        $this->setAPIParameters(
170
            'events/'.$eventID,
171
            'GET'
172
        );
173
174
        $this->enableMode();
175
176
        $this->call();
177
178
        return $this->getReturnDetails();
179
    }
180
181
    /**
182
     * Search for an Event
183
     *
184
     * @param mixed[] $searchParameters Associative array of search parameters
185
     *
186
     * @return $this|\Twigger\UnionCloud\API\Response\IResponse|\Twigger\UnionCloud\API\ResourceCollection
187
     *
188
     * @throws \GuzzleHttp\Exception\GuzzleException
189
     * @throws \Twigger\UnionCloud\API\Exception\Request\RequestHistoryNotFound
190
     * @throws \Twigger\UnionCloud\API\Exception\Response\BaseResponseException
191
     */
192
    public function search($searchParameters)
193
    {
194
        $this->setAPIParameters(
195
            'events/search',
196
            'POST',
197
            $searchParameters
198
        );
199
200
        $this->enableMode();
201
        $this->enablePagination();
202
203
        $this->call();
204
205
        return $this->getReturnDetails();
206
    }
207
208
209
}
210