Skip to content

Commit

Permalink
Remove not used import and update docblocks with relevant throws
Browse files Browse the repository at this point in the history
  • Loading branch information
Roussetos Karafyllakis committed May 13, 2024
1 parent 2ccddb9 commit 1a97a69
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/Data/CreateResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Upmind\ProvisionProviders\Seo\Data;

use Upmind\ProvisionBase\Provider\DataSet\DataSet;
use Upmind\ProvisionBase\Provider\DataSet\ResultData;
use Upmind\ProvisionBase\Provider\DataSet\Rules;

Expand Down
1 change: 0 additions & 1 deletion src/Data/LoginResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Upmind\ProvisionProviders\Seo\Data;

use Upmind\ProvisionBase\Provider\DataSet\DataSet;
use Upmind\ProvisionBase\Provider\DataSet\ResultData;
use Upmind\ProvisionBase\Provider\DataSet\Rules;

Expand Down
10 changes: 7 additions & 3 deletions src/Providers/Example/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class Provider extends Category implements ProviderInterface
{
protected Configuration $configuration;
protected Client $client;
protected Client|null $client = null;

public function __construct(Configuration $configuration)
{
Expand All @@ -42,18 +42,22 @@ public static function aboutProvider(): AboutData

/**
* @inheritDoc
*
* @throws \Upmind\ProvisionBase\Exception\ProvisionFunctionError
*/
public function create(CreateParams $params): CreateResult
{
throw $this->errorResult('Not Implemented');
$this->errorResult('Not Implemented');
}

/**
* @inheritDoc
*
* @throws \Upmind\ProvisionBase\Exception\ProvisionFunctionError
*/
public function changePackage(ChangePackageParams $params): EmptyResult
{
throw $this->errorResult('Not Implemented');
$this->errorResult('Not Implemented');
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Providers/Marketgoo/Exceptions/OperationFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Upmind\ProvisionProviders\Seo\Providers\Marketgoo\Exceptions;

use Throwable;
use Upmind\ProvisionBase\Exception\ProvisionFunctionError;

/**
Expand Down
48 changes: 48 additions & 0 deletions src/Providers/Marketgoo/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public function __construct(Configuration $configuration)
$this->configuration = $configuration;
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Upmind\ProvisionProviders\Seo\Providers\Marketgoo\Exceptions\OperationFailed
*/
public function create(CreateParams $params): CreateResult
{
$domainName = $params->domain;
Expand All @@ -61,11 +65,19 @@ public function create(CreateParams $params): CreateResult
->setMessage('Account created');
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Upmind\ProvisionProviders\Seo\Providers\Marketgoo\Exceptions\OperationFailed
*/
public function login(AccountIdentifierParams $params): LoginResult
{
return LoginResult::create()->setUrl($this->getLoginUrl($params->username));
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Upmind\ProvisionProviders\Seo\Providers\Marketgoo\Exceptions\OperationFailed
*/
public function changePackage(ChangePackageParams $params): EmptyResult
{
try {
Expand All @@ -81,6 +93,10 @@ public function changePackage(ChangePackageParams $params): EmptyResult
return EmptyResult::create()->setMessage('Account updated');
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Upmind\ProvisionProviders\Seo\Providers\Marketgoo\Exceptions\OperationFailed
*/
public function suspend(AccountIdentifierParams $params): EmptyResult
{
try {
Expand All @@ -96,6 +112,10 @@ public function suspend(AccountIdentifierParams $params): EmptyResult
return EmptyResult::create()->setMessage('Account suspended');
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Upmind\ProvisionProviders\Seo\Providers\Marketgoo\Exceptions\OperationFailed
*/
public function unsuspend(AccountIdentifierParams $params): EmptyResult
{
try {
Expand All @@ -111,6 +131,10 @@ public function unsuspend(AccountIdentifierParams $params): EmptyResult
return EmptyResult::create()->setMessage('Account unsuspended');
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Upmind\ProvisionProviders\Seo\Providers\Marketgoo\Exceptions\OperationFailed
*/
public function terminate(AccountIdentifierParams $params): EmptyResult
{
$this->deleteAccount($params->username);
Expand All @@ -133,6 +157,10 @@ protected function client(): Client
]);
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Upmind\ProvisionProviders\Seo\Providers\Marketgoo\Exceptions\OperationFailed
*/
protected function getLoginUrl(string $username): string
{
// get 5-minute ttl sso link
Expand All @@ -141,6 +169,10 @@ protected function getLoginUrl(string $username): string
return $handler->getLoginUrl();
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Upmind\ProvisionProviders\Seo\Providers\Marketgoo\Exceptions\OperationFailed
*/
private function createAccount(
string $domainName,
string $productKey,
Expand All @@ -167,6 +199,10 @@ private function createAccount(
return $handler->getAccountIdentifier('create');
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Upmind\ProvisionProviders\Seo\Providers\Marketgoo\Exceptions\OperationFailed
*/
private function upgradeAccount(string $accountId, string $productKey): void
{
$response = $this->client()->patch("accounts/{$accountId}/upgrade", [
Expand All @@ -185,20 +221,32 @@ private function upgradeAccount(string $accountId, string $productKey): void
$handler->assertSuccess('upgrade');
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Upmind\ProvisionProviders\Seo\Providers\Marketgoo\Exceptions\OperationFailed
*/
private function suspendAccount(string $accountId): void
{
$response = $this->client()->patch("accounts/{$accountId}/suspend");
$handler = new ResponseHandler($response);
$handler->assertSuccess('suspend');
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Upmind\ProvisionProviders\Seo\Providers\Marketgoo\Exceptions\OperationFailed
*/
private function resumeAccount(string $accountId): void
{
$response = $this->client()->patch("accounts/{$accountId}/resume");
$handler = new ResponseHandler($response);
$handler->assertSuccess('resume');
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Upmind\ProvisionProviders\Seo\Providers\Marketgoo\Exceptions\OperationFailed
*/
private function deleteAccount(string $accountId): void
{
$response = $this->client()->delete("accounts/{$accountId}");
Expand Down

0 comments on commit 1a97a69

Please sign in to comment.