<?php

include '../bootstrap.php';
try {
    $instance = new interact();
    $instance->debug = true;
    $instance->intitializeSoapClient($config_file['location']['wsdl'], $config_file['location']['endpoint']);
    if ($instance->login($config_file['auth_regular']['login'], $config_file['auth_regular']['pass'])) {
        $retrieve_obj = new retrieveListMembers();
        $int_obj = new InteractObject();
        $int_obj->setFolderName("Mason");
        $int_obj->setObjectName("masonList1");
        $retrieve_obj->setFieldListParam(array("RIID_", "EMAIL_ADDRESS_", "FIRST_NAME"));
        $retrieve_obj->setIdsToRetrieve(array("*****@*****.**"));
        $retrieve_obj->setListParam($int_obj);
        $retrieve_obj->setQueryColumn(QueryColumn::EMAIL2);
        $results = $instance->execute($retrieve_obj);
        // do something with results?
        print_r($results);
        $instance->logout();
    } else {
        die("Login failed, no reason to go on...");
    }
} catch (SoapFault $fault) {
    print_r($fault);
} catch (Exception $exception) {
    print_r($exception);
}
        $records[] = $record_1;
        $records[] = $record_2;
        $merge_obj->setRecordDataParam($fieldNames, $records);
        $merge_result_ids = $instance->execute($merge_obj);
        // Now we make a secondary merge call to opt out the newly inserted record....
        // for brevity i will reuse some of the variables above
        /*
        $fieldNames2 = array( "EMAIL_ADDRESS_", "EMAIL_PERMISSION_STATUS_", "CITY_" );
        
        $record_2 = new Record();
        $record_2->setFieldValues( array( "*****@*****.**", "OPTOUT") );
        $records2[] = $record_2;
        
        $merge_obj->setRecordDataParam( $fieldNames2, $records2 );
        $merge_result_ids_2 = $instance->execute( $merge_obj );
        */
        // Now lets use retrieveListMembers to confirm that the change took place
        // The email permission status should be "O" which is optout
        $retrieve_obj = new retrieveListMembers();
        $retrieve_obj->setFieldListParam($fieldNames);
        $retrieve_obj->setIdsToRetrieve(array("*****@*****.**", "*****@*****.**"));
        $retrieve_obj->setListParam($interact_object);
        $retrieve_obj->setQueryColumn("EMAIL_ADDRESS");
        $retrieve_results = $instance->execute($retrieve_obj);
        $instance->logout();
    }
} catch (SoapFault $fault) {
    print_r($fault);
} catch (Exception $exception) {
    print_r($exception);
}