1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace CommerceLeague\ActiveCampaign\MessageQueue\Customer; |
7
|
|
|
|
8
|
|
|
use CommerceLeague\ActiveCampaign\Api\Data\CustomerInterface; |
9
|
|
|
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper; |
10
|
|
|
use Magento\Customer\Model\Customer as MagentoCustomer; |
11
|
|
|
|
12
|
|
|
class CreateMessageBuilder |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var ConfigHelper |
16
|
|
|
*/ |
17
|
|
|
private $configHelper; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var CreateMessageFactory |
|
|
|
|
21
|
|
|
*/ |
22
|
|
|
private $createMessageFactory; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param ConfigHelper $configHelper |
26
|
|
|
* @param CreateMessageFactory $createMessageFactory |
27
|
|
|
*/ |
28
|
|
|
public function __construct( |
29
|
|
|
ConfigHelper $configHelper, |
30
|
|
|
CreateMessageFactory $createMessageFactory |
31
|
|
|
) { |
32
|
|
|
$this->createMessageFactory = $createMessageFactory; |
33
|
|
|
$this->configHelper = $configHelper; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param CustomerInterface $customer |
38
|
|
|
* @param MagentoCustomer $magentoCustomer |
39
|
|
|
* @return CreateMessage |
40
|
|
|
*/ |
41
|
|
|
public function build(CustomerInterface $customer, MagentoCustomer $magentoCustomer): CreateMessage |
42
|
|
|
{ |
43
|
|
|
$request = [ |
44
|
|
|
'connectionid' => $this->configHelper->getConnectionId(), |
45
|
|
|
'externalid' => $magentoCustomer->getId(), |
46
|
|
|
'email' => $magentoCustomer->getData('email'), |
47
|
|
|
'acceptsMarketing' => 1 // TODO::check how this value could be set |
48
|
|
|
]; |
49
|
|
|
|
50
|
|
|
/** @var CreateMessage $message */ |
51
|
|
|
$message = $this->createMessageFactory->create(); |
52
|
|
|
|
53
|
|
|
$message->setEntityId((int)$customer->getId()) |
54
|
|
|
->setSerializedRequest(json_encode($request)); |
55
|
|
|
|
56
|
|
|
return $message; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths