-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUpdatesHelper.php
More file actions
68 lines (61 loc) · 2.08 KB
/
UpdatesHelper.php
File metadata and controls
68 lines (61 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
// Copyright (c) 2021 Harry [Majored] [hello@majored.pw]
// MIT License (https://github.com/Majored/php-bbb-api-wrapper/blob/main/LICENSE)
namespace Majored\PhpBbbApiWrapper\Helpers\Resources;
use Majored\PhpBbbApiWrapper\APIResponse;
use Majored\PhpBbbApiWrapper\APIWrapper;
/** A helper class for update-related API endpoints. */
class UpdatesHelper {
/** @var APIWrapper The current wrapper instance in use. */
private $wrapper;
/**
* Construct a new updates helper from a wrapper instance.
*
* @param APIWrapper The current wrapper instance in use.
*/
function __construct(APIWrapper $wrapper) {
$this->wrapper = $wrapper;
}
/**
* List a single page of resource updates.
*
* @param int The identifier of the resource.
* @param array An optional associated array of sort options.
*
* @return APIResponse The parsed API response.
*/
function list(int $resource_id, array $sort = []): APIResponse {
return $this->wrapper->get(sprintf("resources/%d/updates", $resource_id), $sort);
}
/**
* Fetch a resource update.
*
* @param int The identifier of the resource.
* @param int The identifier of the update.
*
* @return APIResponse The parsed API response.
*/
function fetch(int $resource_id, int $update_id): APIResponse {
return $this->wrapper->get(sprintf("resources/%d/updates/%d", $resource_id, $update_id));
}
/**
* Delete a resource update.
*
* @param int The identifier of the resource.
* @param int The identifier of the update.
*
* @return APIResponse The parsed API response.
*/
function delete(int $resource_id, int $update_id): APIResponse {
return $this->wrapper->delete(sprintf("resources/%d/updates/%d", $resource_id, $update_id));
}
/**
* Fetch the latest resource update.
*
* @param int The identifier of the resource.
* @return APIResponse The parsed API response.
*/
function latest(int $resource_id): APIResponse {
return $this->wrapper->get(sprintf("resources/%d/updates/latest", $resource_id));
}
}