Skip to content

Commit 28d5fe4

Browse files
committed
Addition of new license issuing/modifying semantics
1 parent 9ebf3e5 commit 28d5fe4

File tree

1 file changed

+44
-9
lines changed

1 file changed

+44
-9
lines changed

src/helpers/resources/LicensesHelper.php

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,43 +54,78 @@ function fetchByMember(int $resource_id, int $member_id): APIResponse {
5454
}
5555

5656
/**
57-
* Issue a new resource license.
57+
* Issue a new permanent resource license.
58+
*
59+
* @param int The identifier of the resource.
60+
* @param int The identifier of the member.
61+
* @param bool Whether or not the license should be active.
62+
*
63+
* @return APIResponse The parsed API response.
64+
*/
65+
function issuePermanent(int $resource_id, int $member_id, bool $active): APIResponse {
66+
$body = [
67+
"purchaser_id" => $member_id,
68+
"permanent" => true,
69+
"active" => $active
70+
];
71+
72+
return $this->wrapper->post(sprintf("resources/%d/licenses", $resource_id), $body);
73+
}
74+
75+
/**
76+
* Issue a new temporary resource license.
5877
*
5978
* @param int The identifier of the resource.
6079
* @param int The identifier of the member.
6180
* @param int The start date of the license as a UNIX timestamp.
6281
* @param int The end date of the license as a UNIX timestamp.
63-
* @param bool Whether or not the license should be active.
6482
*
6583
* @return APIResponse The parsed API response.
6684
*/
67-
function issue(int $resource_id, int $member_id, int $start_date, int $end_date, bool $active): APIResponse {
85+
function issueTemporary(int $resource_id, int $member_id, int $start_date, int $end_date): APIResponse {
6886
$body = [
6987
"purchaser_id" => $member_id,
88+
"permanent" => false,
7089
"start_date" => $start_date,
71-
"end_date" => $end_date,
72-
"active" => $active
90+
"end_date" => $end_date
7391
];
7492

7593
return $this->wrapper->post(sprintf("resources/%d/licenses", $resource_id), $body);
7694
}
7795

7896
/**
79-
* Modify an existing resource license.
97+
* Modify a permanent license (and convert to permanent if currently temporary).
98+
*
99+
* @param int The identifier of the resource.
100+
* @param int The identifier of the license.
101+
* @param bool Whether or not the license should be active, or null if unchanged.
102+
*
103+
* @return APIResponse The parsed API response.
104+
*/
105+
function modifyPermanent(int $resource_id, int $license_id, bool $active): APIResponse {
106+
$body = [
107+
"permanent" => false,
108+
"active" => $active
109+
];
110+
111+
return $this->wrapper->patch(sprintf("resources/%d/licenses/%d", $resource_id, $license_id), $body);
112+
}
113+
114+
/**
115+
* Modify a temporary license (and convert to temporary if currently permanent).
80116
*
81117
* @param int The identifier of the resource.
82118
* @param int The identifier of the license.
83119
* @param int The start date of the license as a UNIX timestamp, or null if unchanged.
84120
* @param int The end date of the license as a UNIX timestamp, or null if unchanged.
85-
* @param bool Whether or not the license should be active, or null if unchanged.
86121
*
87122
* @return APIResponse The parsed API response.
88123
*/
89-
function modify(int $resource_id, int $license_id, int $start_date, int $end_date, bool $active): APIResponse {
124+
function modifyTemporary(int $resource_id, int $license_id, int $start_date, int $end_date): APIResponse {
90125
$body = [
126+
"permanent" => false,
91127
"start_date" => $start_date,
92128
"end_date" => $end_date,
93-
"active" => $active
94129
];
95130

96131
return $this->wrapper->patch(sprintf("resources/%d/licenses/%d", $resource_id, $license_id), $body);

0 commit comments

Comments
 (0)