Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/RestClientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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,
Expand Down
Loading