SparkPost\Transmission::addListToRecipients PHP Method

addListToRecipients() private method

Loops through the given listName in the payload and adds all the recipients to the recipients list after removing their names.
private addListToRecipients ( array $payload, array $listName ) : array
$payload array - the request body
$listName array - the name of the array in the payload to be moved to the recipients list
return array - the modified request body
    private function addListToRecipients($payload, $listName)
    {
        $originalAddress = $this->toAddressString($payload['recipients'][0]['address']);
        foreach ($payload[$listName] as $recipient) {
            $recipient['address'] = $this->toAddressObject($recipient['address']);
            $recipient['address']['header_to'] = $originalAddress;
            // remove name from address - name is only put in the header for cc and not at all for bcc
            if (isset($recipient['address']['name'])) {
                unset($recipient['address']['name']);
            }
            array_push($payload['recipients'], $recipient);
        }
        //Delete the original object from the payload.
        unset($payload[$listName]);
        return $payload;
    }