diff --git a/src/Domains/Registrar/Adapter/NameCom.php b/src/Domains/Registrar/Adapter/NameCom.php index 02e5ce9..7833825 100644 --- a/src/Domains/Registrar/Adapter/NameCom.php +++ b/src/Domains/Registrar/Adapter/NameCom.php @@ -10,6 +10,7 @@ use Utopia\Domains\Registrar\Exception\InvalidAuthCodeException; use Utopia\Domains\Registrar\Exception\InvalidContactException; use Utopia\Domains\Registrar\Exception\AuthException; +use Utopia\Domains\Registrar\Exception\InvalidPeriodException; use Utopia\Domains\Registrar\Exception\PriceNotFoundException; use Utopia\Domains\Registrar\Exception\DomainNotFoundException; use Utopia\Domains\Registrar\Exception\RateLimitException; @@ -34,6 +35,7 @@ class NameCom extends Adapter public const ERROR_INVALID_CONTACT = 'invalid value for'; public const ERROR_INVALID_DOMAIN = 'Invalid Domain Name'; public const ERROR_INVALID_DOMAINS = 'None of the submitted domains are valid'; + public const ERROR_INVALID_YEARS = 'Invalid value for years'; public const ERROR_UNSUPPORTED_TLD = 'unsupported tld'; public const ERROR_TLD_NOT_SUPPORTED = 'TLD not supported'; public const ERROR_UNSUPPORTED_TRANSFER = 'do not support transfers for'; @@ -47,6 +49,7 @@ class NameCom extends Adapter self::ERROR_NOT_FOUND => 404, self::ERROR_DOMAIN_TAKEN => null, self::ERROR_INVALID_AUTH_CODE => null, + self::ERROR_INVALID_YEARS => 400, self::ERROR_INVALID_CONTACT => null, self::ERROR_INVALID_DOMAIN => null, self::ERROR_INVALID_DOMAINS => null, @@ -415,6 +418,9 @@ public function getPrice(string $domain, int $periodYears = 1, string $regType = case self::ERROR_INVALID_DOMAIN: throw new PriceNotFoundException($message, $code, $e); + case self::ERROR_INVALID_YEARS: + throw new InvalidPeriodException($message, $code, $e); + default: throw new DomainsException($message, $code, $e); } diff --git a/src/Domains/Registrar/Exception/InvalidPeriodException.php b/src/Domains/Registrar/Exception/InvalidPeriodException.php new file mode 100644 index 0000000..1424fbd --- /dev/null +++ b/src/Domains/Registrar/Exception/InvalidPeriodException.php @@ -0,0 +1,9 @@ +markTestSkipped('Name.com for some reason always returning 404 (Not Found) for transfer status check. Investigate later.'); } + + public function testGetPriceWithInvalidPeriod(): void + { + $domain = $this->generateRandomString() . '.ai'; + + $this->expectException(InvalidPeriodException::class); + $this->expectExceptionMessage('Failed to get price for domain: ' . $domain . ' - Invalid value for years for this domain'); + + $this->registrar->getPrice($domain, 1); + } }