/** * log a subscription request to the database * @param string $recipientEmail the email address of the recipient * @param string $recipientName the name of the recipient * @param array $fields set of fields (answers) to assign to the user record * @param string $listId unique identifier for the list * @param string $clientId unique identifier for the client making the request * @return null */ public function log($recipientEmail, $recipientName, $fields, $listId, $clientId) { $logged = $this->repo->store(["list_id" => $listId, "client_id" => $clientId, "recipient_email" => $recipientEmail, "recipient_name" => $recipientName, "fields" => json_encode($fields), "requested" => getDateTime()]); if (!$logged) { return apiErrorResponse('badRequest', ['errors' => "There was a problem with the request."]); } Event::fire('RequestWasLogged'); return apiSuccessResponse('ok'); }
/** * Update the details of a list with supplied data * @param array $updates the details * @return API response */ public function updateList(array $data) { if (!is_array($data) or !isset($data["listId"]) or !isset($data["listName"])) { return apiErrorResponse('failedDependency', []); } $lister = new Lister($this, $data["listId"]); # create the basic array needed by the campaign monitor API $listData = ["Title" => $data["listName"]]; # add in the default values for new lists as required by the CM API $core = array_merge($listData, $this->coreValues); # send it $response = $lister->updateList($core); if ($response->http_status_code == 200) { return apiSuccessResponse('ok', $response); } return apiErrorResponse('badRequest', ['errors' => $response->response->Message]); }
/** * create a new list * @return mixed */ public function createList() { # check to see if we have the required fields if (!isset($_POST['listName'])) { return apiErrorResponse('insufficientArguments'); } # make the call to create the form $result = $this->mailer->createList($_POST['listName']); # if we get a successful response back from the Mail API if ($result->http_status_code == 201) { return apiSuccessResponse('ok', ['listId' => $result->response]); } # otherwise its failed for some reason. So report it return apiErrorResponse('unprocessable', ['furtherResponseCode' => $result->response->Code, 'furtherResponseMsg' => $result->response->Message]); }