-
Notifications
You must be signed in to change notification settings - Fork 0
/
SendService.php
44 lines (36 loc) · 1.19 KB
/
SendService.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Wearesho\Bobra\Cpa\SalesDoubler;
use Psr\Http\Message\RequestInterface;
use Wearesho\Bobra\Cpa;
use GuzzleHttp\Psr7;
use yii\base;
use yii\di;
/**
* Class SendService
* @package Wearesho\Bobra\Cpa\SalesDoubler
*/
class SendService extends base\BaseObject implements Cpa\Conversion\SendServiceInterface
{
use Cpa\Conversion\SendServiceTrait;
/** @var array|string|ConfigInterface definition */
public $config = [
'class' => EnvironmentConfig::class,
];
/**
* @throws base\InvalidConfigException
*/
public function init(): void
{
parent::init();
$this->config = di\Instance::ensure($this->config, ConfigInterface::class);
}
protected function getRequest(Cpa\ConversionInterface $conversion): RequestInterface
{
$clickId = $conversion->getConfig()['clickId'] ?? null;
$transId = $conversion->getId();
$token = $this->config->getToken($conversion->getProduct());
$id = $this->config->getId($conversion->getProduct());
$url = "http://rdr.salesdoubler.com.ua/in/postback/{$id}/{$clickId}?trans_id={$transId}&token={$token}";
return new Psr7\Request('get', $url);
}
}