public function updateSubscriber(
        string $email,
        string $firstName = null,
        string $lastName = null,
        $interests = null,
        array $extras = []
    ) : bool {
        $data = array_merge([
            'status_if_new' => 'subscribed',
            'email_address' => $email
        ], $extras);
        $mergeFields = [];
        if ($firstName !== null) {
            $mergeFields['FNAME'] = $firstName;
        }
        if ($lastName !== null) {
            $mergeFields['LNAME'] = $lastName;
        }

        if (count($mergeFields) > 0) {
            $data['merge_fields'] = (object) $mergeFields;
        }
        if ($interests !== null) {
            $data['interests'] = (object) $interests;
        }

        $result = $this->api->put('lists/'.$this->id().'/members/'.$this->support->hashEmail($email), $data);

        return $result->has('id') && strlen($result->get('id')) > 0;
    }
public function updateSubscriber(
        string $email,
        string $firstName = null,
        string $lastName = null,
        $interests = null,
        array $extras = []
    ) : bool {
        $data = array_merge([
            'status_if_new' => 'subscribed',
            'email_address' => $email
        ], $extras);
        $mergeFields = [];
        if ($firstName !== null) {
            $mergeFields['FNAME'] = $firstName;
        }
        if ($lastName !== null) {
            $mergeFields['LNAME'] = $lastName;
        }

        if (count($mergeFields) > 0) {
            $data['merge_fields'] = (object) $mergeFields;
        }
        if ($interests !== null) {
            $data['interests'] = (object) $interests;
        }

        $result = $this->api->put('lists/'.$this->id().'/members/'.$this->support->hashEmail($email), $data);

        return $result->has('id') && strlen($result->get('id')) > 0;
    }
public function updateSubscriber ( string $ email , string $ firstName = null , string $ lastName = null , $ interests = null , array $ extras = [ ] ) : bool { $ data = array_merge ( [ 'status_if_new' => 'subscribed' , 'email_address' => $ email ] , $ extras ) ; $ mergeFields = [ ] ; if ( $ firstName !== null ) { $ mergeFields [ 'FNAME' ] = $ firstName ; } if ( $ lastName !== null ) { $ mergeFields [ 'LNAME' ] = $ lastName ; } if ( count ( $ mergeFields ) > 0 ) { $ data [ 'merge_fields' ] = ( object ) $ mergeFields ; } if ( $ interests !== null ) { $ data [ 'interests' ] = ( object ) $ interests ; } $ result = $ this -> api -> put ( 'lists/' . $ this -> id ( ) . '/members/' . $ this -> support -> hashEmail ( $ email ) , $ data ) ; return $ result -> has ( 'id' ) && strlen ( $ result -> get ( 'id' ) ) > 0 ; }
Updates a subscriber if the email address is already
on the list, or create the subscriber

@param string        $email
@param string        $firstName
@param string        $lastName
@param array|object  $interests  Properties/Keys are interest ids and values are boolean
@param array         $extras     Additional fields to be passed to the Mailchimp API

@link https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#edit-put_lists_list_id_members_subscriber_hash

@throws EmailAddressNotSubscribed
@throws \Exception
Updates a subscriber if the email address is already on the list or create the subscriber