diff --git a/README.md b/README.md index c3df2d9..999a0cc 100644 --- a/README.md +++ b/README.md @@ -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; ``` diff --git a/src/Customer.php b/src/Customer.php index b8975cb..a2d0e27 100644 --- a/src/Customer.php +++ b/src/Customer.php @@ -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 ]); } } diff --git a/src/Database.php b/src/Database.php index c30e816..bf319ad 100644 --- a/src/Database.php +++ b/src/Database.php @@ -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 ]); } } \ No newline at end of file diff --git a/src/Databases.php b/src/Databases.php index 818ae5c..d755c3b 100644 --- a/src/Databases.php +++ b/src/Databases.php @@ -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, ]); } } \ No newline at end of file diff --git a/src/Domain.php b/src/Domain.php index 545edff..aa7faaa 100644 --- a/src/Domain.php +++ b/src/Domain.php @@ -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 ]); } } \ No newline at end of file diff --git a/src/Domains.php b/src/Domains.php index b25ddb1..3b8df89 100644 --- a/src/Domains.php +++ b/src/Domains.php @@ -14,7 +14,7 @@ class Domains public function create(string $domain, bool $letsencrypt = false): array { return $this->customer->server->request('Domains.add', [ - 'loginname' => $this->customer->loginname, + 'customerid' => $this->customer->id, 'domain' => $domain, 'letsencrypt' => $letsencrypt, 'isemaildomain' => true, @@ -26,9 +26,9 @@ class Domains { return $this->customer->server->request('Domains.listing', [ 'sql_search' => [ - 'loginname' => [ + 'customerid' => [ 'op' => '=', - 'value' => $this->customer->loginname, + 'value' => $this->customer->id, ] ], ]); diff --git a/src/Email.php b/src/Email.php index 857629c..037338f 100644 --- a/src/Email.php +++ b/src/Email.php @@ -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 ]); } } \ No newline at end of file diff --git a/src/EmailAccount.php b/src/EmailAccount.php index 86ed5d8..fb23bfb 100644 --- a/src/EmailAccount.php +++ b/src/EmailAccount.php @@ -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, ]) ); } diff --git a/src/EmailAccounts.php b/src/EmailAccounts.php index e15652a..d9dcdd5 100644 --- a/src/EmailAccounts.php +++ b/src/EmailAccounts.php @@ -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, ]); diff --git a/src/Emails.php b/src/Emails.php index a189798..1ffa39c 100644 --- a/src/Emails.php +++ b/src/Emails.php @@ -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, ]); } } \ No newline at end of file diff --git a/src/Ftp.php b/src/Ftp.php index 7fc0bd7..04a72cd 100644 --- a/src/Ftp.php +++ b/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 ]); } } diff --git a/src/Ftps.php b/src/Ftps.php index 5aa064c..5c5a197 100644 --- a/src/Ftps.php +++ b/src/Ftps.php @@ -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, ]); } } \ No newline at end of file diff --git a/src/Server.php b/src/Server.php index 59d952e..b8b2302 100644 --- a/src/Server.php +++ b/src/Server.php @@ -55,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); } }