|
5 | 5 | namespace Setono\MetaConversionsApi\Client; |
6 | 6 |
|
7 | 7 | use Buzz\Client\Curl; |
8 | | -use Composer\InstalledVersions; |
| 8 | +use FacebookAds\ApiConfig; |
9 | 9 | use Nyholm\Psr7\Factory\Psr17Factory; |
10 | 10 | use Psr\Http\Client\ClientInterface as HttpClientInterface; |
11 | 11 | use Psr\Http\Message\RequestFactoryInterface; |
|
16 | 16 | use Psr\Log\NullLogger; |
17 | 17 | use Setono\MetaConversionsApi\Event\Event; |
18 | 18 | use Setono\MetaConversionsApi\Exception\ClientException; |
19 | | -use Webmozart\Assert\Assert; |
20 | 19 |
|
21 | 20 | final class Client implements ClientInterface, LoggerAwareInterface |
22 | 21 | { |
@@ -60,7 +59,7 @@ public function sendEvent(Event $event): void |
60 | 59 |
|
61 | 60 | $request = $requestFactory->createRequest( |
62 | 61 | 'POST', |
63 | | - sprintf('https://graph.facebook.com/%s/%s/events', self::getEndpointVersion(), $pixel->id), |
| 62 | + sprintf('https://graph.facebook.com/%s/%s/events', sprintf('v%s', ApiConfig::APIVersion), $pixel->id), |
64 | 63 | ) |
65 | 64 | ->withHeader('Content-Type', 'application/x-www-form-urlencoded') |
66 | 65 | ->withHeader('Accept', 'application/json') |
@@ -162,14 +161,4 @@ public function setLogger(LoggerInterface $logger): void |
162 | 161 | { |
163 | 162 | $this->logger = $logger; |
164 | 163 | } |
165 | | - |
166 | | - private static function getEndpointVersion(): string |
167 | | - { |
168 | | - $version = InstalledVersions::getVersion('facebook/php-business-sdk'); |
169 | | - Assert::notNull($version); |
170 | | - |
171 | | - [$major, $minor] = explode('.', $version, 3); |
172 | | - |
173 | | - return sprintf('v%s.%s', $major, $minor); |
174 | | - } |
175 | 164 | } |
0 commit comments