Skip to content

Commit

Permalink
Codestyle, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Gladyshev committed Jan 6, 2021
1 parent 712f3d8 commit 2398445
Show file tree
Hide file tree
Showing 42 changed files with 379 additions and 444 deletions.
56 changes: 0 additions & 56 deletions CHANGELOG

This file was deleted.

7 changes: 3 additions & 4 deletions examples/agency_clients.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

require '../vendor/autoload.php';

$credentials = \Gladyshev\Yandex\Direct\AgencyCredentials::buildForSandbox(
$credentials = \Gladyshev\Yandex\Direct\Credentials::agencySandbox(
getenv('_TOKEN_'),
getenv('_MASTER_TOKEN_'),
getenv('_CLIENT_LOGIN_')
getenv('_MASTER_TOKEN_')
);

$client = new \Gladyshev\Yandex\Direct\Client(
Expand All @@ -14,7 +13,7 @@
);

$resp = $client->agencyClients->get(
['Archived' => 'YES'],
['Archived' => 'NO'],
['Login']
);

Expand Down
2 changes: 1 addition & 1 deletion examples/reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require '../vendor/autoload.php';

$credentials = \Gladyshev\Yandex\Direct\ClientCredentials::buildForSandbox(
$credentials = \Gladyshev\Yandex\Direct\Credentials::clientSandbox(
getenv('_TOKEN_'),
getenv('_MASTER_TOKEN_')
);
Expand Down
2 changes: 1 addition & 1 deletion examples/simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require '../vendor/autoload.php';

$credentials = \Gladyshev\Yandex\Direct\ClientCredentials::buildForSandbox(
$credentials = \Gladyshev\Yandex\Direct\Credentials::clientSandbox(
getenv('_TOKEN_'),
getenv('_MASTER_TOKEN_')
);
Expand Down
4 changes: 2 additions & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<arg name="colors"/>

<!-- inherit rules from: PSR-2 -->
<rule ref="PSR2">
<rule ref="PSR12">
<exclude name="PSR1.Classes.ClassDeclaration"/>
<exclude name="PSR1.Files.SideEffects"/>
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace"/>
<exclude name="Generic.Files.LineLength"/>
</rule>

<!-- Paths to check -->
<file>src</file>
<file>src/</file>

<!-- Exclude -->
<exclude-pattern>*/vendor/*</exclude-pattern>
Expand Down
27 changes: 14 additions & 13 deletions src/AbstractService.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Gladyshev\Yandex\Direct;
Expand Down Expand Up @@ -30,16 +31,6 @@ public function __construct(
$this->httpClient = $httpClient;
}

public function getName(): string
{
return $this->serviceName;
}

public function getCredentials(): \Gladyshev\Yandex\Direct\CredentialsInterface
{
return $this->credentials;
}

public function call(array $params = []): array
{
$request = new \GuzzleHttp\Psr7\Request(
Expand All @@ -54,12 +45,22 @@ public function call(array $params = []): array
return $this->handleResponse($request, $response);
}

protected function getServiceName(): string
{
return $this->serviceName;
}

protected function getCredentials(): \Gladyshev\Yandex\Direct\CredentialsInterface
{
return $this->credentials;
}

/**
* @return string
*/
protected function getUri() : string
protected function getUri(): string
{
return $this->getCredentials()->getBaseUrl() . '/json/v5/' . mb_strtolower($this->getName());
return $this->getCredentials()->getBaseUrl() . '/json/v5/' . mb_strtolower($this->getServiceName());
}

/**
Expand Down Expand Up @@ -91,7 +92,7 @@ protected function getHeaders(): array
protected function getBody(array $params): string
{
if (empty($params['params'])) {
$params = new \StdClass;
$params = new \StdClass();
} else {
$params['params'] = array_filter($params['params']);
}
Expand Down
101 changes: 0 additions & 101 deletions src/AgencyCredentials.php

This file was deleted.

1 change: 1 addition & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Gladyshev\Yandex\Direct;
Expand Down
114 changes: 0 additions & 114 deletions src/ClientCredentials.php

This file was deleted.

Loading

0 comments on commit 2398445

Please sign in to comment.