• 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

23.08
/app/Http/Controllers/RestApi/RestController.php
1
<?php
2

3
namespace App\Http\Controllers\RestApi;
4

5
use App\MailchimpEndpoint;
6
use App\Synchronizer\MailchimpToCrmWebhookSynchronizer;
7
use App\Synchronizer\WebsiteToMailchimpSynchronizer;
8
use Illuminate\Http\Request;
9
use Illuminate\Http\JsonResponse;
10
use App\Exceptions\MailchimpClientException;
11
use App\Exceptions\EmailComplianceException;
12
use App\Exceptions\InvalidEmailException;
13
use App\Exceptions\MemberDeleteException;
14
use App\Exceptions\ConfigException;
15
use App\Exceptions\ParseCrmDataException;
16

17
class RestController
18
{
19
    public function handlePost(Request $request, string $secret)
20
    {
21
        $endpoint = MailchimpEndpoint::where('secret', $secret)->first();
1✔
22

23
        if (!$endpoint) {
1✔
24
            abort(401, 'Invalid secret.');
1✔
25
        }
26

NEW
27
        $sync = new MailchimpToCrmWebhookSynchronizer($endpoint->config);
×
NEW
28
        $sync->handleMailchimpUpdate($request->post());
×
29
    }
30

31
    /**
32
     * To add a webhook in Mailchimp, Mailchimp must be able to make a successful GET request to the given address.
33
     *
34
     * @param string $secret
35
     */
36
    public function handleGet(string $secret)
37
    {
38
        /** @var MailchimpEndpoint|null $endpoint */
39
        $endpoint = MailchimpEndpoint::where('secret', $secret)->first();
×
40

41
        if (!$endpoint) {
×
42
            abort(401, 'Invalid secret.');
×
43
        }
44
    }
45

46
    /**
47
     * Add a new contact to Mailchimp from the website (using CRM-mapping)
48
     *
49
     * @param Request $request
50
     * @param string $secret
51
     */
52
    public function addContact(Request $request, string $secret)
53
    {
54
        /** @var MailchimpEndpoint|null $endpoint */
55
        $endpoint = MailchimpEndpoint::where('secret', $secret)->first();
×
56

57
        if (!$endpoint) {
×
58
            abort(401, 'Invalid secret.');
×
59
        }
60

61
        $sync = new WebsiteToMailchimpSynchronizer($endpoint->config);
×
62
        $sync->syncSingle($request->post());
×
63
    }
64
}
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