Skip to content

Commit

Permalink
Merge pull request #7 from promopult/click-23259
Browse files Browse the repository at this point in the history
 Обновил psr/http-message до v2
  • Loading branch information
gladyshev authored Feb 6, 2025
2 parents 14b5bad + ba24eb6 commit 3495ca3
Show file tree
Hide file tree
Showing 31 changed files with 107 additions and 13 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"php": "^7.4|^8.0",
"ext-json": "*",
"psr/http-client": "~1.0.1",
"psr/http-message": "~1.0.1",
"guzzlehttp/psr7": "^1.8.4|^2.4.0"
"psr/http-message": "~1.0.1|~2.0.0",
"guzzlehttp/psr7": "^1.8.4|^2.7.0"
},
"require-dev": {
"guzzlehttp/guzzle": "~7.4.5",
"phpunit/phpunit": "~9.3.8|~8.5.15",
"vimeo/psalm": "^4.15",
"guzzlehttp/guzzle": "~7.9.0",
"phpunit/phpunit": "~11.5.0|~8.5.0",
"vimeo/psalm": "^4.15|^6.4",
"squizlabs/php_codesniffer": "^3.6"
},
"autoload" : {
Expand Down
3 changes: 3 additions & 0 deletions src/Appendix/AreaCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Appendix;

/**
* @psalm-suppress UnusedClass
*/
final class AreaCode
{
public static function getAreaCodes(): array
Expand Down
3 changes: 3 additions & 0 deletions src/Appendix/CampaignOptStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace Promopult\TikTokMarketingApi\Appendix;

/**
* @psalm-suppress UnusedClass
*/
final class CampaignOptStatus
{
public const ENABLED = 'ENABLED';
Expand Down
1 change: 1 addition & 0 deletions src/Appendix/CampaignSecondaryStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Class CampaignSecondaryStatus
*
* @discard
* @psalm-suppress UnusedClass
*/
final class CampaignSecondaryStatus
{
Expand Down
3 changes: 3 additions & 0 deletions src/Appendix/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Appendix;

/**
* @psalm-suppress UnusedClass
*/
final class Currency
{
public static function getCurrencies(): array
Expand Down
3 changes: 3 additions & 0 deletions src/Appendix/Industry.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Appendix;

/**
* @psalm-suppress UnusedClass
*/
final class Industry
{
public static function getIndustries(): array
Expand Down
6 changes: 6 additions & 0 deletions src/Appendix/RegionIDs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Appendix;

/**
* @psalm-suppress UnusedClass
*/
final class RegionIDs
{
public const TYPE_DMA = 'DMA';
Expand Down Expand Up @@ -1496,6 +1499,9 @@ public static function getRegionsList(): array
foreach (self::JSON as $items) {
$ids = array_column($items, 'id');
$items_with_ids = array_combine($ids, $items);
if ($items_with_ids === false) {
throw new \RuntimeException('Regions list is empty.');
}
self::$region_cache = self::$region_cache + $items_with_ids;
}
return self::$region_cache;
Expand Down
3 changes: 3 additions & 0 deletions src/Appendix/Timezone.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Appendix;

/**
* @psalm-suppress UnusedClass
*/
final class Timezone
{
public static function getTimezones(): array
Expand Down
3 changes: 3 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* @property Service\Creatives $creatives
* @property Service\Images $images
* @property Service\Video $video
*
* * @psalm-suppress UnusedClass
*
*/
final class Client implements ServiceFactoryInterface
{
Expand Down
3 changes: 3 additions & 0 deletions src/Enumeration/AdvertiserBillingType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Enumeration;

/**
* @psalm-suppress UnusedClass
*/
final class AdvertiserBillingType
{
public const TRANS_TYPE_TRANSFER = 'TRANS_TYPE_TRANSFER'; // Transfer
Expand Down
3 changes: 3 additions & 0 deletions src/Enumeration/AdvertiserDisplayStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Enumeration;

/**
* @psalm-suppress UnusedClass
*/
final class AdvertiserDisplayStatus
{
public const SHOW_ACCOUNT_STATUS_NOT_APPROVED = 'SHOW_ACCOUNT_STATUS_NOT_APPROVED'; // Failed
Expand Down
3 changes: 3 additions & 0 deletions src/Enumeration/AdvertiserRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Enumeration;

/**
* @psalm-suppress UnusedClass
*/
final class AdvertiserRole
{
public const ROLE_ADVERTISER = 'ROLE_ADVERTISER'; // Standard advertiser (direct customer)
Expand Down
3 changes: 3 additions & 0 deletions src/Enumeration/AdvertiserStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Enumeration;

/**
* @psalm-suppress UnusedClass
*/
final class AdvertiserStatus
{
public const STATUS_DISABLE = 'STATUS_DISABLE'; // Disabled
Expand Down
3 changes: 3 additions & 0 deletions src/Enumeration/BusinessCenterStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Enumeration;

/**
* @psalm-suppress UnusedClass
*/
final class BusinessCenterStatus
{
public const REVIEWING = 'REVIEWING'; // Under review
Expand Down
3 changes: 3 additions & 0 deletions src/Enumeration/BusinessCenterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Enumeration;

/**
* @psalm-suppress UnusedClass
*/
final class BusinessCenterType
{
public const NORMAL = 'NORMAL'; // General
Expand Down
8 changes: 7 additions & 1 deletion src/Exception/TooManyJumpsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ public function getJumpResponses(): array

public function getLastResponse(): ResponseInterface
{
return end($this->jumpResponses);
$lastJump = end($this->jumpResponses);

if ($lastJump === false) {
throw new \RuntimeException('Unable to retrieve last jump.');
}

return $lastJump;
}

public function getLastResponseAsString(): string
Expand Down
14 changes: 10 additions & 4 deletions src/OAuth2Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\ClientInterface;

/**
* @psalm-suppress UnusedClass
*/
final class OAuth2Client
{
use RequestSenderTrait;
Expand Down Expand Up @@ -63,7 +66,7 @@ public function advertiserGet(

/** @var array $parsedBody */
$parsedBody = json_decode(
(string) $response->getBody(),
$response->getBody()->__toString(),
true,
JSON_THROW_ON_ERROR
);
Expand Down Expand Up @@ -103,13 +106,13 @@ public function getAccessToken(
'app_id' => $appId,
'auth_code' => $authCode,
'secret' => $secret
])
], JSON_THROW_ON_ERROR)
);

$response = $this->sendRequest($request);

/** @var array $accessToken */
$accessToken = json_decode($response->getBody()->getContents(), true, JSON_THROW_ON_ERROR);
$accessToken = json_decode($response->getBody()->__toString(), true, JSON_THROW_ON_ERROR);

if (empty($accessToken)) {
throw new MalformedResponse($request, $response);
Expand Down Expand Up @@ -147,7 +150,10 @@ public static function createAuthorizationUrl(
'redirect_uri' => $redirectUri,
];

if ($scope) {
if (
$scope !== null
&& count($scope) > 0
) {
$queryParams['scope'] = '[' . implode(',', $scope) . ']';
}

Expand Down
8 changes: 5 additions & 3 deletions src/RequestSenderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ protected function sendRequest(

$uri = current($response->getHeader('Location'));

/**
* @psalm-suppress UnusedVariable
*/
if ($uri === false) {
throw new \RuntimeException('Location header is invalid');
}

/** @psalm-suppress UnusedVariable */
$request = $request->withUri(new Uri($uri));

goto jump;
Expand Down
3 changes: 3 additions & 0 deletions src/Service/Ad.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Throwable;

/**
* @psalm-suppress UnusedClass
*/
final class Ad extends \Promopult\TikTokMarketingApi\AbstractService
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Service/AdGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Service;

/**
* @psalm-suppress UnusedClass
*/
final class AdGroup extends \Promopult\TikTokMarketingApi\AbstractService
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Service/Advertiser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Service;

/**
* @psalm-suppress UnusedClass
*/
final class Advertiser extends \Promopult\TikTokMarketingApi\AbstractService
{
/**
Expand Down
1 change: 1 addition & 0 deletions src/Service/Bc.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* place, and oversee multiple TikTok For Business accounts.
*
* @see https://ads.tiktok.com/marketing_api/docs?id=1690849685291009
* @psalm-suppress UnusedClass
*/
final class Bc extends \Promopult\TikTokMarketingApi\AbstractService
{
Expand Down
3 changes: 3 additions & 0 deletions src/Service/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Service;

/**
* @psalm-suppress UnusedClass
*/
final class Campaign extends \Promopult\TikTokMarketingApi\AbstractService
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Service/Creatives.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Promopult\TikTokMarketingApi\AbstractService;

/**
* @psalm-suppress UnusedClass
*/
final class Creatives extends AbstractService
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Service/Images.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Promopult\TikTokMarketingApi\AbstractService;

/**
* @psalm-suppress UnusedClass
*/
final class Images extends AbstractService
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Service/Leads.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Throwable;
use function json_decode;

/**
* @psalm-suppress UnusedClass
*/
final class Leads extends \Promopult\TikTokMarketingApi\AbstractService
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Service/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Service;

/**
* @psalm-suppress UnusedClass
*/
final class Pages extends \Promopult\TikTokMarketingApi\AbstractService
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Service/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Service;

/**
* @psalm-suppress UnusedClass
*/
final class Report extends \Promopult\TikTokMarketingApi\AbstractService
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Service/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Service;

/**
* @psalm-suppress UnusedClass
*/
final class Tools extends \Promopult\TikTokMarketingApi\AbstractService
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Service/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Promopult\TikTokMarketingApi\Service;

/**
* @psalm-suppress UnusedClass
*/
final class User extends \Promopult\TikTokMarketingApi\AbstractService
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Service/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Promopult\TikTokMarketingApi\AbstractService;

/**
* @psalm-suppress UnusedClass
*/
final class Video extends AbstractService
{
/**
Expand Down

0 comments on commit 3495ca3

Please sign in to comment.