• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

grueneschweiz / mailchimpservice / 17108989360

20 Aug 2025 08:00PM UTC coverage: 68.598% (-1.6%) from 70.247%
17108989360

push

github

Michael-Schaer
[FEAT] Sync from mailchimp to crm in specific cases

197 of 333 new or added lines in 10 files covered. (59.16%)

4 existing lines in 2 files now uncovered.

959 of 1398 relevant lines covered (68.6%)

11.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

40.0
/app/Synchronizer/MailchimpToCrmSynchronizer.php
1
<?php
2

3
namespace App\Synchronizer;
4

5
use App\Http\CrmClient;
6
use App\Http\MailChimpClient;
7
use App\Synchronizer\Mapper\Mapper;
8
use App\Synchronizer\Config;
9
use App\Synchronizer\LogTrait;
10

11
/**
12
 * Abstract base class for synchronizer implementations
13
 */
14
abstract class MailchimpToCrmSynchronizer
15
{
16
    use LogTrait;
17

18
    /**
19
     * @var Config
20
     */
21
    protected $config;
22

23
    /**
24
     * @var string
25
     */
26
    protected $configName;
27

28
    /**
29
     * @var MailChimpClient
30
     */
31
    protected $mcClient;
32

33
    /**
34
     * @var CrmClient
35
     */
36
    protected $crmClient;
37

38
    /**
39
     * @var Mapper
40
     */
41
    protected $mapper;
42

43
    /**
44
     * MailchimpToCrmSynchronizer constructor.
45
     *
46
     * @param string $configFileName file name of the config file
47
     *
48
     * @throws \App\Exceptions\ConfigException
49
     * @throws \Exception
50
     */
51
    public function __construct(string $configFileName)
52
    {
53
        $this->config = new Config($configFileName);
1✔
54
        $this->configName = $configFileName;
×
55

NEW
56
        $this->initializeClients();
×
57
    }
58

59
    /**
60
     * Initialize the clients based on configuration
61
     *
62
     * @throws \App\Exceptions\ConfigException
63
     */
64
    protected function initializeClients(): void
65
    {
NEW
66
        $crmCred = $this->config->getCrmCredentials();
×
NEW
67
        $this->crmClient = new CrmClient($crmCred['clientId'], $crmCred['clientSecret'], $crmCred['url']);
×
68

NEW
69
        $this->mcClient = new MailChimpClient($this->config->getMailchimpCredentials()['apikey'], $this->config->getMailchimpListId());
×
NEW
70
        $this->initializeMapper();
×
71
    }
72

73
    /**
74
     * Initialize the mapper with field mappings from config
75
     */
76
    protected function initializeMapper(): void
77
    {
78
        $this->mapper = new Mapper($this->config->getFieldMaps());
13✔
79
    }
80

81
    /**
82
     * Log webhook events with consistent formatting
83
     *
84
     * @param string $method The log level (debug, info, error, etc.)
85
     * @param string $webhook The webhook type
86
     * @param string $record The record identifier
87
     * @param string $message The log message
88
     * @param mixed $crmId The CRM ID (can be string or int)
89
     */
90
    protected function logWebhook(string $method, string $webhook, string $record, string $message, $crmId = -1): void
91
    {
92
        $crmIdParam = $crmId !== -1 && $crmId !== '' ? " crmId=\"$crmId\" " : " ";
7✔
93
        $this->log($method, $message, "webhook=\"$webhook\" record=\"$record\"$crmIdParam");
7✔
94
    }
95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc