HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/farmfun.komma.pro/app/Komma/Mailchimp/Types/ListMember.php
<?php

namespace App\Komma\Mailchimp\Types;

use Illuminate\Contracts\Support\Arrayable;

final class ListMember implements Arrayable
{
    /** @var string */
    private $emailAddress;

    /** @var string */
    private $status;

    /** @var array */
    private $mergeFields = [];

    /** @var array */
    private $tags = [
        'Reserveringssysteem',
    ];

    const STATUS_SUBSCRIBED = 'subscribed';

    const STATUS_UNSUBSCRIBED = 'unsubscribed';

    const STATUS_CLEANED = 'cleaned';

    const STATUS_PENDING = 'pending';

    const STATUS_TRANSACTIONAL = 'transactional';

    public function __construct(string $emailAddress, string $status = self::STATUS_SUBSCRIBED)
    {
        $this->emailAddress = $emailAddress;
        $this->status = $status;
    }

    public function addFirstName(string $firstName)
    {
        $this->mergeFields['FNAME'] = $firstName;
    }

    public function addLastName(string $lastName)
    {
        $this->mergeFields['LNAME'] = $lastName;
    }

    public function addField(string $key, string $value)
    {
        $this->mergeFields[$key] = $value;
    }

    public function addTag(string $tag)
    {
        $this->tags[] = $tag;
    }

    public function clearTag()
    {
        $this->tags = [];
    }

    public function toArray()
    {
        $array = [
            'email_address' => $this->emailAddress,
            'status' => $this->status,
            'tags' => $this->tags,
        ];

        if (count($this->mergeFields) >= 1) {
            $array['merge_fields'] = $this->mergeFields;
        }

        return $array;
    }
}