diff --git a/src/RestClientBuilder.php b/src/RestClientBuilder.php index e80edb8..68546c3 100644 --- a/src/RestClientBuilder.php +++ b/src/RestClientBuilder.php @@ -56,6 +56,12 @@ final class RestClientBuilder { + public const SUGGEST_ADDRESSES_CLIENT = 'SUGGEST-ADDRESSES-CLIENT'; + public const SUGGEST_ORGANIZATION_CLIENT = 'SUGGEST-ORGANIZATION-CLIENT'; + public const SUGGEST_FULLNAME_CLIENT = 'SUGGEST-FULLNAME-CLIENT'; + public const CLEAN_ADDRESSES_CLIENT = 'CLEAN-ADDRESSES-CLIENT'; + public const CLEAN_FULLNAME_CLIENT = 'CLEAN-FULLNAME-CLIENT'; + private PsrHttpClient $client; private Serializer $serializer; @@ -200,7 +206,7 @@ public function withClient(PsrHttpClient $client): self */ public function createCleanFullNameClient(string $url = 'https://cleaner.dadata.ru'): CleanFullNameClient { - $new = $this->withSource('CLEAN-FULLNAME-CLIENT'); + $new = $this->withSource(self::CLEAN_FULLNAME_CLIENT); return new RestCleanFullNameClient( $new->serializer, @@ -214,11 +220,11 @@ public function createCleanFullNameClient(string $url = 'https://cleaner.dadata. /** * @param non-empty-string $url */ - public function createSuggestAddressClient(string $url = 'https://suggestions.dadata.ru'): SuggestAddressClient + public function createSuggestFullNameClient(string $url = 'https://suggestions.dadata.ru'): RestSuggestFullNameClient { - $new = $this->withSource('SUGGEST-ADDRESSES-CLIENT'); + $new = $this->withSource(self::SUGGEST_FULLNAME_CLIENT); - return new RestSuggestAddressClient( + return new RestSuggestFullNameClient( $new->serializer, new HttpClient( new ConfigurationClient($new->apiKey, $new->secretKey, $url), @@ -230,11 +236,11 @@ public function createSuggestAddressClient(string $url = 'https://suggestions.da /** * @param non-empty-string $url */ - public function createSuggestOrganizationClient(string $url = 'https://suggestions.dadata.ru'): SuggestOrganizationClient + public function createSuggestAddressClient(string $url = 'https://suggestions.dadata.ru'): SuggestAddressClient { - $new = $this->withSource('SUGGEST-ORGANIZATION-CLIENT'); + $new = $this->withSource(self::SUGGEST_ADDRESSES_CLIENT); - return new RestSuggestOrganizationClient( + return new RestSuggestAddressClient( $new->serializer, new HttpClient( new ConfigurationClient($new->apiKey, $new->secretKey, $url), @@ -246,11 +252,11 @@ public function createSuggestOrganizationClient(string $url = 'https://suggestio /** * @param non-empty-string $url */ - public function createSuggestFullNameClient(string $url = 'https://suggestions.dadata.ru'): RestSuggestFullNameClient + public function createSuggestOrganizationClient(string $url = 'https://suggestions.dadata.ru'): SuggestOrganizationClient { - $new = $this->withSource('SUGGEST-FULLNAME-CLIENT'); + $new = $this->withSource(self::SUGGEST_ORGANIZATION_CLIENT); - return new RestSuggestFullNameClient( + return new RestSuggestOrganizationClient( $new->serializer, new HttpClient( new ConfigurationClient($new->apiKey, $new->secretKey, $url), @@ -264,7 +270,7 @@ public function createSuggestFullNameClient(string $url = 'https://suggestions.d */ public function createCleanAddressClient(string $url = 'https://cleaner.dadata.ru'): CleanAddressClient { - $new = $this->withSource('CLEAN-ADDRESSES-CLIENT'); + $new = $this->withSource(self::CLEAN_ADDRESSES_CLIENT); return new RestCleanAddressClient( $new->serializer,