Skip to content

Commit 3b56fc4

Browse files
committed
feat: Add DedicatedServer class with core management methods
This commit introduces the `DedicatedServer` class, providing key methods to manage dedicated server resources. The class includes functions for retrieving availability, creating, deleting, undeleting, and fetching details of dedicated servers. It integrates with the `Client` class for API interaction.
1 parent 915492a commit 3b56fc4

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
3+
namespace FireAPI\DedicatedServer;
4+
5+
use FireAPI\Client;
6+
use GuzzleHttp\Exception\GuzzleException;
7+
8+
class DedicatedServer
9+
{
10+
private Client $client;
11+
12+
/**
13+
* Constructor method to initialize the class with a Client instance.
14+
*
15+
* @param Client $client An instance of the Client class.
16+
* @return void
17+
*/
18+
public function __construct(Client $client)
19+
{
20+
$this->client = $client;
21+
}
22+
23+
/**
24+
* @return mixed
25+
* @throws GuzzleException
26+
*/
27+
public function getAvailable(): mixed
28+
{
29+
return $this->client->get('dedicated/available');
30+
}
31+
32+
/**
33+
* @param string $identifier
34+
* @return mixed
35+
* @throws GuzzleException
36+
*/
37+
public function checkAvailable(string $identifier): mixed
38+
{
39+
return $this->client->get("/dedicated/available/{$identifier}");
40+
}
41+
42+
/**
43+
* @param string $identifier
44+
* @param string|null $webhook
45+
* @param string|null $connect
46+
* @return mixed
47+
* @throws GuzzleException
48+
*/
49+
public function create(string $identifier, ?string $webhook = null, ?string $connect = null): mixed
50+
{
51+
return $this->client->put("/dedicated/{$identifier}/purchase", ['webhook' => $webhook, 'connect' => $connect]);
52+
}
53+
54+
/**
55+
* @param string $identifier
56+
* @return mixed
57+
* @throws GuzzleException
58+
*/
59+
public function delete(string $identifier): mixed
60+
{
61+
return $this->client->delete("/dedicated/{$identifier}/delete");
62+
}
63+
64+
/**
65+
* @param string $identifier
66+
* @return mixed
67+
* @throws GuzzleException
68+
*/
69+
public function undelete(string $identifier): mixed
70+
{
71+
return $this->client->post("/dedicated/{$identifier}/undelete");
72+
}
73+
74+
/**
75+
* @param string $identifier
76+
* @return mixed
77+
* @throws GuzzleException
78+
*/
79+
public function getInfo(string $identifier): mixed
80+
{
81+
return $this->client->get("/dedicated/{$identifier}/info");
82+
}
83+
84+
/**
85+
* @return mixed
86+
* @throws GuzzleException
87+
*/
88+
public function getList(): mixed
89+
{
90+
return $this->client->get('/dedicated/list');
91+
}
92+
}

0 commit comments

Comments
 (0)