File tree Expand file tree Collapse file tree 4 files changed +107
-0
lines changed Expand file tree Collapse file tree 4 files changed +107
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace UKFast \SDK \Licenses ;
4
+
5
+ use UKFast \SDK \Client as BaseClient ;
6
+
7
+ class Client extends BaseClient
8
+ {
9
+ protected $ basePath = 'licenses/ ' ;
10
+
11
+ /**
12
+ * @return BaseClient
13
+ */
14
+ public function licenses ()
15
+ {
16
+ return (new LicensesClient ($ this ->httpClient ))->auth ($ this ->token );
17
+ }
18
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace UKFast \SDK \Licenses \Entities ;
4
+
5
+ use UKFast \SDK \Entity ;
6
+
7
+ /**
8
+ * @property string $key
9
+ */
10
+ class Key extends Entity
11
+ {
12
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace UKFast \SDK \Licenses \Entities ;
4
+
5
+ use UKFast \SDK \Entity ;
6
+
7
+ /**
8
+ * @property int $id
9
+ * @property string $ownerId
10
+ * @property string $ownerType
11
+ * @property string $keyId
12
+ * @property string $licenseType
13
+ * @property int $resellerId
14
+ */
15
+ class License extends Entity
16
+ {
17
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace UKFast \SDK \Licenses ;
4
+
5
+ use UKFast \SDK \Entities \ClientEntityInterface ;
6
+ use UKFast \SDK \Licenses \Entities \Key ;
7
+ use UKFast \SDK \Licenses \Entities \License ;
8
+ use UKFast \SDK \Traits \PageItems ;
9
+
10
+ class LicensesClient extends Client implements ClientEntityInterface
11
+ {
12
+ use PageItems;
13
+
14
+ protected $ collectionPath = 'v1/licenses ' ;
15
+
16
+ public function loadEntity ($ data )
17
+ {
18
+ return new License (
19
+ $ this ->apiToFriendly ($ data , $ this ->getEntityMap ())
20
+ );
21
+ }
22
+
23
+ public function getEntityMap ()
24
+ {
25
+ return [
26
+ 'id ' => 'id ' ,
27
+ 'owner_id ' => 'name ' ,
28
+ 'owner_type ' => 'ownerType ' ,
29
+ 'key_id ' => 'keyId ' ,
30
+ 'license_type ' => 'licenseType ' ,
31
+ 'reseller_id ' => 'resellerId ' ,
32
+ ];
33
+ }
34
+
35
+ /**
36
+ * Revoke a license
37
+ * @param int $id
38
+ * @return bool
39
+ */
40
+ public function revoke ($ id )
41
+ {
42
+ $ response = $ this ->post ($ this ->collectionPath . '/ ' . $ id . '/revoke ' );
43
+ return $ response ->getStatusCode () == 204 ;
44
+ }
45
+
46
+ /**
47
+ * Get a license key
48
+ * @param $id
49
+ * @return Key
50
+ */
51
+ public function key ($ id )
52
+ {
53
+ $ response = $ this ->get ($ this ->collectionPath . '/ ' . $ id . '/key ' );
54
+ $ body = $ this ->decodeJson ($ response ->getBody ()->getContents ());
55
+
56
+ return new Key (
57
+ $ this ->apiToFriendly ($ body ->data , ['key ' => 'key ' ])
58
+ );
59
+ }
60
+ }
You can’t perform that action at this time.
0 commit comments