Skip to content

Commit

Permalink
feat: add support for access_key
Browse files Browse the repository at this point in the history
  • Loading branch information
darthsoup committed Apr 19, 2022
1 parent 4e643d8 commit e0fb23c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/whmcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@
'url' => env('WHMCS_API_URL', 'https://url.to.whmcs.tld/whmcs'),
'username' => env('WHMCS_USERNAME', 'YOUR_USERNAME'),
'password' => env('WHMCS_PASSWORD', 'YOUR_PASSWORD'),
'access_key' => env('WHMCS_ACCESSKEY')
],

'secondary' => [
'method' => env('WHMCS_AUTH_TYPE', 'token'),
'url' => env('WHMCS_API_URL', 'https://url.to.whmcs.tld/whmcs'),
'identifier' => env('WHMCS_API_IDENTIFIER', 'YOUR_API_IDENTIFIER'),
'secret' => env('WHMCS_API_SECRET', 'YOUR_API_SECRET'),
'access_key' => env('WHMCS_API_ACCESSKEY')
]
]
];
5 changes: 5 additions & 0 deletions src/Auth/Method/PasswordAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use DarthSoup\Whmcs\Auth\AbstractAuth;
use DarthSoup\WhmcsApi\Client;
use Illuminate\Support\Arr;
use InvalidArgumentException;

class PasswordAuth extends AbstractAuth
Expand All @@ -29,6 +30,10 @@ public function authenticate(array $config): Client
Client::AUTH_LOGIN_CREDENTIALS
);

if (Arr::has($config, 'access_key') && null !== $config['access_key']) {
$this->client->accessKey($config['access_key']);
}

return $this->client;
}
}
5 changes: 5 additions & 0 deletions src/Auth/Method/TokenAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use DarthSoup\Whmcs\Auth\AbstractAuth;
use DarthSoup\WhmcsApi\Client;
use Illuminate\Support\Arr;
use InvalidArgumentException;

class TokenAuth extends AbstractAuth
Expand All @@ -29,6 +30,10 @@ public function authenticate(array $config): Client
Client::AUTH_API_CREDENTIALS
);

if (Arr::has($config, 'access_key') && null !== $config['access_key']) {
$this->client->accessKey($config['access_key']);
}

return $this->client;
}
}
2 changes: 1 addition & 1 deletion src/WhmcsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function getBuilder(array $config): Builder

return $builder;
}

protected function getClient(Builder $builder): Client
{
return new Client($builder);
Expand Down

0 comments on commit e0fb23c

Please sign in to comment.