@@ 14-47 (lines=34) @@ | ||
11 | /** |
|
12 | * Removes a member from the Mailchip list |
|
13 | */ |
|
14 | class RemoveMailchimpMember implements SelfHandling, ShouldQueue |
|
15 | { |
|
16 | use InteractsWithQueue, SerializesModels; |
|
17 | ||
18 | /** |
|
19 | * The old email that needs to be replaced with the new one on the member |
|
20 | * |
|
21 | * @var string |
|
22 | */ |
|
23 | private $email; |
|
24 | ||
25 | /** |
|
26 | * Create a new job instance. |
|
27 | * |
|
28 | * @param string $email |
|
29 | */ |
|
30 | public function __construct($email) |
|
31 | { |
|
32 | $this->email = $email; |
|
33 | } |
|
34 | ||
35 | /** |
|
36 | * Execute the job. |
|
37 | */ |
|
38 | public function handle() |
|
39 | { |
|
40 | // The Job only executes if the apiKey is set! This works sort of an |
|
41 | // on/off switch |
|
42 | if (!empty(config('diegocaprioli.larachimp.larachimp.api_key'))) { |
|
43 | $manager = App::make(MailchimpManager::class); |
|
44 | $manager->removeListMember($this->email); |
|
45 | } |
|
46 | } |
|
47 | } |
|
48 |
@@ 16-49 (lines=34) @@ | ||
13 | * email does not exist yet on the list, it creates it. If it exists already, |
|
14 | * it syncs up the subscribers status (Subscribed / Unsubscribed) |
|
15 | */ |
|
16 | class SyncMailchimpMember implements SelfHandling, ShouldQueue |
|
17 | { |
|
18 | use InteractsWithQueue, SerializesModels; |
|
19 | ||
20 | /** |
|
21 | * An instance object that can be synced as a Mailchimp List member. |
|
22 | * |
|
23 | * @var \DiegoCaprioli\Larachimp\Models\LarachimpListMember |
|
24 | */ |
|
25 | private $member; |
|
26 | ||
27 | /** |
|
28 | * Create a new job instance. |
|
29 | * |
|
30 | * @param \DiegoCaprioli\Larachimp\Models\LarachimpListMember $member |
|
31 | */ |
|
32 | public function __construct(LarachimpListMember $member) |
|
33 | { |
|
34 | $this->member = $member; |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * Execute the job. |
|
39 | */ |
|
40 | public function handle() |
|
41 | { |
|
42 | // The Job only executes if the apiKey is set! This works sort of an |
|
43 | // on/off switch |
|
44 | if (!empty(config('diegocaprioli.larachimp.larachimp.api_key'))) { |
|
45 | $manager = App::make(MailchimpManager::class); |
|
46 | $manager->syncMember($this->member); |
|
47 | } |
|
48 | } |
|
49 | } |
|
50 |