mirror of
https://github.com/envoyr/php-froxlor-client.git
synced 2026-04-28 04:06:19 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
563ecefe71
|
|||
|
66778ea7c4
|
|||
|
d37c0ad55b
|
|||
| 63d68d8921 | |||
| 6f2b651a70 | |||
| a5f3d3d0fd |
@@ -1,5 +1,8 @@
|
||||
# PHP Froxlor API Client
|
||||
|
||||
> [!WARNING]
|
||||
> We have changed the way we get the object. Now you have to use the `id` instead of the `name` to get, change or delete the object.
|
||||
|
||||
API Wrapper for Froxlor.
|
||||
|
||||
## Installation
|
||||
@@ -43,8 +46,8 @@ $response = $froxlor
|
||||
|
||||
```php
|
||||
$response = $froxlor
|
||||
->customer('example')
|
||||
->email('hello@example.com')
|
||||
->customer(1)
|
||||
->email(1)
|
||||
->attributes;
|
||||
```
|
||||
|
||||
|
||||
@@ -9,15 +9,15 @@ class Customer
|
||||
public Domains $domains;
|
||||
public Ftps $ftps;
|
||||
public Emails $emails;
|
||||
public string $loginname;
|
||||
public string $id;
|
||||
public Server $server;
|
||||
|
||||
public function __construct(Server $server, string $loginname)
|
||||
public function __construct(Server $server, string $id)
|
||||
{
|
||||
$this->server = $server;
|
||||
$this->loginname = $loginname;
|
||||
$this->id = $id;
|
||||
$this->attributes = $this->server->request('Customers.get', [
|
||||
'loginname' => $this->loginname
|
||||
'id' => $this->id
|
||||
]);
|
||||
|
||||
$this->databases = $this->databases();
|
||||
@@ -46,30 +46,30 @@ class Customer
|
||||
return new Emails($this);
|
||||
}
|
||||
|
||||
public function database(string $dbname): Database
|
||||
public function database(string $id): Database
|
||||
{
|
||||
return new Database($this, $dbname);
|
||||
return new Database($this, $id);
|
||||
}
|
||||
|
||||
public function domain(string $domainname): Domain
|
||||
public function domain(string $id): Domain
|
||||
{
|
||||
return new Domain($this, $domainname);
|
||||
return new Domain($this, $id);
|
||||
}
|
||||
|
||||
public function email(string $emailaddr): Email
|
||||
public function email(string $id): Email
|
||||
{
|
||||
return new Email($this, $emailaddr);
|
||||
return new Email($this, $id);
|
||||
}
|
||||
|
||||
public function ftp(string $username): Ftp
|
||||
public function ftp(string $id): Ftp
|
||||
{
|
||||
return new Ftp($this, $username);
|
||||
return new Ftp($this, $id);
|
||||
}
|
||||
|
||||
public function deactivated(bool $deactivated): array
|
||||
{
|
||||
return $this->server->request('Customers.update', [
|
||||
'loginname' => $this->loginname,
|
||||
'id' => $this->id,
|
||||
'deactivated' => $deactivated
|
||||
]);
|
||||
}
|
||||
@@ -79,7 +79,7 @@ class Customer
|
||||
return $this->server->request(
|
||||
'Customers.update',
|
||||
array_merge($attributes, [
|
||||
'loginname' => $this->loginname
|
||||
'id' => $this->id
|
||||
])
|
||||
);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ class Customer
|
||||
public function delete(): array
|
||||
{
|
||||
return $this->server->request('Customers.delete', [
|
||||
'loginname' => $this->loginname
|
||||
'id' => $this->id
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,15 +5,15 @@ namespace Envoyr\Froxlor;
|
||||
class Database
|
||||
{
|
||||
public array $attributes;
|
||||
public string $dbname;
|
||||
public string $id;
|
||||
public Customer $customer;
|
||||
|
||||
public function __construct(Customer $customer, string $dbname)
|
||||
public function __construct(Customer $customer, string $id)
|
||||
{
|
||||
$this->customer = $customer;
|
||||
$this->dbname = $dbname;
|
||||
$this->id = $id;
|
||||
$this->attributes = $this->customer->server->request('Mysqls.get', [
|
||||
'dbname' => $this->dbname
|
||||
'id' => $this->id
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ class Database
|
||||
return $this->customer->server->request(
|
||||
'Mysqls.update',
|
||||
array_merge($attributes, [
|
||||
'loginname' => $this->customer->loginname,
|
||||
'dbname' => $this->dbname,
|
||||
'customerid' => $this->customer->id,
|
||||
'id' => $this->id,
|
||||
])
|
||||
);
|
||||
}
|
||||
@@ -31,8 +31,8 @@ class Database
|
||||
public function delete(): array
|
||||
{
|
||||
return $this->customer->server->request('Mysqls.delete', [
|
||||
'loginname' => $this->customer->loginname,
|
||||
'dbname' => $this->dbname
|
||||
'customerid' => $this->customer->id,
|
||||
'id' => $this->id
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ class Databases
|
||||
string $suffix = null
|
||||
): array {
|
||||
return $this->customer->server->request('Mysqls.add', [
|
||||
'loginname' => $this->customer->loginname,
|
||||
'customerid' => $this->customer->id,
|
||||
'mysql_password' => $password,
|
||||
'description' => $description,
|
||||
'sendinfomail' => $mail,
|
||||
@@ -29,7 +29,7 @@ class Databases
|
||||
public function list(): array
|
||||
{
|
||||
return $this->customer->server->request('Mysqls.listing', [
|
||||
'loginname' => $this->customer->loginname,
|
||||
'customerid' => $this->customer->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,14 @@ class Domain
|
||||
{
|
||||
public array $attributes;
|
||||
public Customer $customer;
|
||||
public string $domainname;
|
||||
public string $id;
|
||||
|
||||
public function __construct(Customer $customer, string $domainname)
|
||||
public function __construct(Customer $customer, string $id)
|
||||
{
|
||||
$this->domainname = $domainname;
|
||||
$this->id = $id;
|
||||
$this->customer = $customer;
|
||||
$this->attributes = $this->customer->server->request('Domains.get', [
|
||||
'domainname' => $this->domainname
|
||||
'id' => $this->id
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class Domain
|
||||
return $this->customer->server->request(
|
||||
'Domains.update',
|
||||
array_merge($attributes, [
|
||||
'domainname' => $this->domainname,
|
||||
'id' => $this->id,
|
||||
])
|
||||
);
|
||||
}
|
||||
@@ -30,7 +30,7 @@ class Domain
|
||||
public function delete(): array
|
||||
{
|
||||
return $this->customer->server->request('Domains.delete', [
|
||||
'domainname' => $this->domainname
|
||||
'id' => $this->id
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -11,14 +11,21 @@ class Domains
|
||||
$this->customer = $customer;
|
||||
}
|
||||
|
||||
public function create(string $domain, bool $letsencrypt = false): array
|
||||
public function create(
|
||||
string $domain,
|
||||
bool $letsencrypt = false,
|
||||
?string $description = null,
|
||||
bool $isemaildomain = true,
|
||||
bool $caneditdomain = true
|
||||
): array
|
||||
{
|
||||
return $this->customer->server->request('Domains.add', [
|
||||
'loginname' => $this->customer->loginname,
|
||||
'customerid' => $this->customer->id,
|
||||
'domain' => $domain,
|
||||
'letsencrypt' => $letsencrypt,
|
||||
'isemaildomain' => true,
|
||||
'caneditdomain' => true,
|
||||
'isemaildomain' => $isemaildomain,
|
||||
'caneditdomain' => $caneditdomain,
|
||||
'description' => $description,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -26,9 +33,9 @@ class Domains
|
||||
{
|
||||
return $this->customer->server->request('Domains.listing', [
|
||||
'sql_search' => [
|
||||
'loginname' => [
|
||||
'c.customerid' => [
|
||||
'op' => '=',
|
||||
'value' => $this->customer->loginname,
|
||||
'value' => $this->customer->id,
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -6,15 +6,15 @@ class Email
|
||||
{
|
||||
public array $attributes;
|
||||
public EmailAccounts $email_accounts;
|
||||
public string $emailaddr;
|
||||
public string $id;
|
||||
public Customer $customer;
|
||||
|
||||
public function __construct(Customer $customer, string $emailaddr)
|
||||
public function __construct(Customer $customer, string $id)
|
||||
{
|
||||
$this->customer = $customer;
|
||||
$this->emailaddr = $emailaddr;
|
||||
$this->id = $id;
|
||||
$this->attributes = $this->customer->server->request('Emails.get', [
|
||||
'emailaddr' => $this->emailaddr
|
||||
'id' => $this->id
|
||||
]);
|
||||
|
||||
$this->email_accounts = $this->email_accounts();
|
||||
@@ -35,8 +35,8 @@ class Email
|
||||
return $this->customer->server->request(
|
||||
'Emails.update',
|
||||
array_merge($attributes, [
|
||||
'loginname' => $this->customer->loginname,
|
||||
'emailaddr' => $this->emailaddr,
|
||||
'customerid' => $this->customer->id,
|
||||
'id' => $this->id,
|
||||
])
|
||||
);
|
||||
}
|
||||
@@ -44,8 +44,8 @@ class Email
|
||||
public function delete(): array
|
||||
{
|
||||
return $this->customer->server->request('Emails.delete', [
|
||||
'loginname' => $this->customer->loginname,
|
||||
'emailaddr' => $this->emailaddr
|
||||
'customerid' => $this->customer->id,
|
||||
'id' => $this->id
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,8 @@ class EmailAccount
|
||||
public function delete()
|
||||
{
|
||||
$this->email->customer->server->request('EmailAccounts.delete', [
|
||||
'loginname' => $this->email->customer->loginname,
|
||||
'emailaddr' => $this->email->emailaddr,
|
||||
'customerid' => $this->email->customer->id,
|
||||
'id' => $this->email->id,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ class EmailAccount
|
||||
return $this->email->customer->server->request(
|
||||
'EmailAccounts.update',
|
||||
array_merge($attributes, [
|
||||
'loginname' => $this->email->customer->loginname,
|
||||
'emailaddr' => $this->email->emailaddr,
|
||||
'customerid' => $this->email->customer->id,
|
||||
'id' => $this->email->id,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ class EmailAccounts
|
||||
public function create(string $email_password, bool $sendinfomail = false): array
|
||||
{
|
||||
return $this->email->customer->server->request('EmailAccounts.add', [
|
||||
'loginname' => $this->email->customer->loginname,
|
||||
'emailaddr' => $this->email->emailaddr,
|
||||
'customerid' => $this->email->customer->id,
|
||||
'id' => $this->email->id,
|
||||
'email_password' => $email_password,
|
||||
'sendinfomail' => $sendinfomail,
|
||||
]);
|
||||
|
||||
@@ -14,7 +14,7 @@ class Emails
|
||||
public function create(string $email_part, string $domain, string $description = null): array
|
||||
{
|
||||
return $this->customer->server->request('Emails.add', [
|
||||
'loginname' => $this->customer->loginname,
|
||||
'customerid' => $this->customer->id,
|
||||
'email_part' => $email_part,
|
||||
'domain' => $domain,
|
||||
'description' => $description,
|
||||
@@ -24,7 +24,7 @@ class Emails
|
||||
public function list(): array
|
||||
{
|
||||
return $this->customer->server->request('Emails.listing', [
|
||||
'loginname' => $this->customer->loginname,
|
||||
'customerid' => $this->customer->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
18
src/Ftp.php
18
src/Ftp.php
@@ -5,16 +5,16 @@ namespace Envoyr\Froxlor;
|
||||
class Ftp
|
||||
{
|
||||
public array $attributes;
|
||||
public string $username;
|
||||
public string $id;
|
||||
public Customer $customer;
|
||||
|
||||
public function __construct(Customer $customer, string $username)
|
||||
public function __construct(Customer $customer, string $id)
|
||||
{
|
||||
$this->customer = $customer;
|
||||
$this->username = $username;
|
||||
$this->id = $id;
|
||||
$this->attributes = $this->customer->server->request('Ftps.get', [
|
||||
'loginname' => $this->customer->loginname,
|
||||
'username' => $this->username
|
||||
'customerid' => $this->customer->id,
|
||||
'id' => $this->id
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ class Ftp
|
||||
return $this->customer->server->request(
|
||||
'Ftps.update',
|
||||
array_merge($attributes, [
|
||||
'loginname' => $this->customer->loginname,
|
||||
'username' => $this->username,
|
||||
'customerid' => $this->customer->id,
|
||||
'id' => $this->id,
|
||||
])
|
||||
);
|
||||
}
|
||||
@@ -32,8 +32,8 @@ class Ftp
|
||||
public function delete(): array
|
||||
{
|
||||
return $this->customer->server->request('Ftps.delete', [
|
||||
'loginname' => $this->customer->loginname,
|
||||
'username' => $this->username
|
||||
'customerid' => $this->customer->id,
|
||||
'id' => $this->id
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class Ftps
|
||||
public function create(string $password, string $path = '/', string $description = null, bool $mail = false): array
|
||||
{
|
||||
return $this->customer->server->request('Ftps.add', [
|
||||
'loginname' => $this->customer->loginname,
|
||||
'customerid' => $this->customer->id,
|
||||
'ftp_password' => $password,
|
||||
'path' => $path,
|
||||
'ftp_description' => $description,
|
||||
@@ -25,7 +25,7 @@ class Ftps
|
||||
public function list(): array
|
||||
{
|
||||
return $this->customer->server->request('Ftps.listing', [
|
||||
'loginname' => $this->customer->loginname,
|
||||
'customerid' => $this->customer->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -36,18 +36,15 @@ class Server
|
||||
}
|
||||
|
||||
$payload = [
|
||||
'header' => [
|
||||
'apikey' => $this->apiKey,
|
||||
'secret' => $this->apiSecret,
|
||||
],
|
||||
'body' => [
|
||||
'command' => $command,
|
||||
'params' => $attributes
|
||||
]
|
||||
'command' => $command,
|
||||
'params' => $attributes
|
||||
];
|
||||
|
||||
$token = base64_encode(sprintf('%s:%s', $this->apiKey, $this->apiSecret));
|
||||
|
||||
$response = $this->client->post("api.php", [
|
||||
'headers' => [
|
||||
'Authorization' => 'Basic ' . $token,
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
'body' => json_encode($payload)
|
||||
@@ -58,8 +55,8 @@ class Server
|
||||
return $payload['data'];
|
||||
}
|
||||
|
||||
public function customer(string $loginname): Customer
|
||||
public function customer(string $id): Customer
|
||||
{
|
||||
return new Customer($this, $loginname);
|
||||
return new Customer($this, $id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user