/** * Get list of searched contact list * @param string $q Required parameter: Your keyword or query. * @return string response from the API call*/ public function searchContactList($q) { //check that all required arguments are provided if (!isset($q)) { throw new \InvalidArgumentException("One or more required arguments were NULL."); } //the base uri for api requests $_queryBuilder = Configuration::$BASEURI; //prepare query string for API call $_queryBuilder = $_queryBuilder . '/search/contacts-lists'; //process optional query parameters APIHelper::appendUrlWithQueryParameters($_queryBuilder, array('q' => $q)); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl($_queryBuilder); //prepare headers $_headers = array('user-agent' => 'ClickSendSDK'); //set HTTP basic auth parameters Request::auth(Configuration::$username, Configuration::$key); //and invoke the API call request to fetch the response $response = Request::get($_queryUrl, $_headers); //Error handling using HTTP status codes if ($response->code == 400) { throw new APIException('BAD_REQUEST', 400, $response->body); } else { if ($response->code == 401) { throw new APIException('UNAUTHORIZED', 401, $response->body); } else { if ($response->code == 403) { throw new APIException('FORBIDDEN', 403, $response->body); } else { if ($response->code == 404) { throw new APIException('NOT_FOUND', 404, $response->body); } else { if ($response->code == 405) { throw new APIException('METHOD_NOT_FOUND', 405, $response->body); } else { if ($response->code == 429) { throw new APIException('TOO_MANY_REQUESTS', 429, $response->body); } else { if ($response->code == 500) { throw new APIException('INTERNAL_SERVER_ERROR', 500, $response->body); } else { if ($response->code < 200 || $response->code > 206) { //[200,206] = HTTP OK throw new APIException("HTTP Response Not OK", $response->code, $response->body); } } } } } } } } return $response->body; }
/** * Update contact * @param int $listId Required parameter: Your list id * @param int $contactId Required parameter: Your contact id * @param string|null $phoneNumber Optional parameter: Your phone number in E.164 format. * @param string|null $email Optional parameter: Your email. Must be provided if no phone number or fax number. * @param string|null $faxNumber Optional parameter: You fax number. Must be provided if no phone number or email. * @param string|null $firstName Optional parameter: Your firstname * @param string|null $lastName Optional parameter: Your lastname * @param string|null $addressLine1 Optional parameter: Example: * @param string|null $addressLine2 Optional parameter: Example: * @param string|null $addressCity Optional parameter: Example: * @param string|null $addressState Optional parameter: Example: * @param string|null $addressPostalCode Optional parameter: Example: * @param string|null $addressCountry Optional parameter: Example: * @param string|null $organizationName Optional parameter: Example: * @param string|null $custom1 Optional parameter: Example: * @param string|null $custom2 Optional parameter: Example: * @param string|null $custom3 Optional parameter: Example: * @param string|null $custom4 Optional parameter: Example: * @return string response from the API call*/ public function updateContact($listId, $contactId, $phoneNumber = NULL, $email = NULL, $faxNumber = NULL, $firstName = NULL, $lastName = NULL, $addressLine1 = NULL, $addressLine2 = NULL, $addressCity = NULL, $addressState = NULL, $addressPostalCode = NULL, $addressCountry = NULL, $organizationName = NULL, $custom1 = NULL, $custom2 = NULL, $custom3 = NULL, $custom4 = NULL) { //check that all required arguments are provided if (!isset($listId, $contactId)) { throw new \InvalidArgumentException("One or more required arguments were NULL."); } //the base uri for api requests $_queryBuilder = Configuration::$BASEURI; //prepare query string for API call $_queryBuilder = $_queryBuilder . '/lists/{list_id}/contacts/{contact_id}'; //process optional query parameters APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array('list_id' => $listId, 'contact_id' => $contactId)); //process optional query parameters APIHelper::appendUrlWithQueryParameters($_queryBuilder, array('phone_number' => $phoneNumber, 'email' => $email, 'fax_number' => $faxNumber, 'first_name' => $firstName, 'last_name' => $lastName, 'address_line_1' => $addressLine1, 'address_line_2' => $addressLine2, 'address_city' => $addressCity, 'address_state' => $addressState, 'address_postal_code' => $addressPostalCode, 'address_country' => $addressCountry, 'organization_name' => $organizationName, 'custom_1' => $custom1, 'custom_2' => $custom2, 'custom_3' => $custom3, 'custom_4' => $custom4)); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl($_queryBuilder); //prepare headers $_headers = array('user-agent' => 'ClickSendSDK'); //set HTTP basic auth parameters Request::auth(Configuration::$username, Configuration::$key); //and invoke the API call request to fetch the response $response = Request::put($_queryUrl, $_headers); //Error handling using HTTP status codes if ($response->code == 400) { throw new APIException('BAD_REQUEST', 400, $response->body); } else { if ($response->code == 401) { throw new APIException('UNAUTHORIZED', 401, $response->body); } else { if ($response->code == 403) { throw new APIException('FORBIDDEN', 403, $response->body); } else { if ($response->code == 404) { throw new APIException('NOT_FOUND', 404, $response->body); } else { if ($response->code == 405) { throw new APIException('METHOD_NOT_FOUND', 405, $response->body); } else { if ($response->code == 429) { throw new APIException('TOO_MANY_REQUESTS', 429, $response->body); } else { if ($response->code == 500) { throw new APIException('INTERNAL_SERVER_ERROR', 500, $response->body); } else { if ($response->code < 200 || $response->code > 206) { //[200,206] = HTTP OK throw new APIException("HTTP Response Not OK", $response->code, $response->body); } } } } } } } } return $response->body; }
/** * Update post return address * @param int $returnAddressId Required parameter: Example: * @param string $addressName Required parameter: Example: * @param string $addressLine1 Required parameter: Example: * @param string $addressLine2 Required parameter: Example: * @param string $addressCity Required parameter: Example: * @param string $addressState Required parameter: Example: * @param string $addressPostalCode Required parameter: Example: * @param string $addressCountry Required parameter: Example: * @return string response from the API call*/ public function updatePostReturnAddress($returnAddressId, $addressName, $addressLine1, $addressLine2, $addressCity, $addressState, $addressPostalCode, $addressCountry) { //check that all required arguments are provided if (!isset($returnAddressId, $addressName, $addressLine1, $addressLine2, $addressCity, $addressState, $addressPostalCode, $addressCountry)) { throw new \InvalidArgumentException("One or more required arguments were NULL."); } //the base uri for api requests $_queryBuilder = Configuration::$BASEURI; //prepare query string for API call $_queryBuilder = $_queryBuilder . '/post/return-addresses/{return_address_id}'; //process optional query parameters APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array('return_address_id' => $returnAddressId)); //process optional query parameters APIHelper::appendUrlWithQueryParameters($_queryBuilder, array('address_name' => $addressName, 'address_line_1' => $addressLine1, 'address_line_2' => $addressLine2, 'address_city' => $addressCity, 'address_state' => $addressState, 'address_postal_code' => $addressPostalCode, 'address_country' => $addressCountry)); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl($_queryBuilder); //prepare headers $_headers = array('user-agent' => 'ClickSendSDK'); //set HTTP basic auth parameters Request::auth(Configuration::$username, Configuration::$key); //and invoke the API call request to fetch the response $response = Request::put($_queryUrl, $_headers); //Error handling using HTTP status codes if ($response->code == 400) { throw new APIException('BAD_REQUEST', 400, $response->body); } else { if ($response->code == 401) { throw new APIException('UNAUTHORIZED', 401, $response->body); } else { if ($response->code == 403) { throw new APIException('FORBIDDEN', 403, $response->body); } else { if ($response->code == 404) { throw new APIException('NOT_FOUND', 404, $response->body); } else { if ($response->code == 405) { throw new APIException('METHOD_NOT_FOUND', 405, $response->body); } else { if ($response->code == 429) { throw new APIException('TOO_MANY_REQUESTS', 429, $response->body); } else { if ($response->code == 500) { throw new APIException('INTERNAL_SERVER_ERROR', 500, $response->body); } else { if ($response->code < 200 || $response->code > 206) { //[200,206] = HTTP OK throw new APIException("HTTP Response Not OK", $response->code, $response->body); } } } } } } } } return $response->body; }
/** * Reseller Account * @param string $clientUserId Required parameter: Example: * @param string $username Required parameter: Example: * @param string $password Required parameter: Example: * @param string $userEmail Required parameter: Example: * @param string $userPhone Required parameter: Example: * @param string $userFirstName Required parameter: Example: * @param string $userLastName Required parameter: Example: * @param string $accountName Required parameter: Example: * @param string $country Required parameter: Example: * @return string response from the API call*/ public function updateResellerAccount($clientUserId, $username, $password, $userEmail, $userPhone, $userFirstName, $userLastName, $accountName, $country) { //check that all required arguments are provided if (!isset($clientUserId, $username, $password, $userEmail, $userPhone, $userFirstName, $userLastName, $accountName, $country)) { throw new \InvalidArgumentException("One or more required arguments were NULL."); } //the base uri for api requests $_queryBuilder = Configuration::$BASEURI; //prepare query string for API call $_queryBuilder = $_queryBuilder . '/reseller/accounts/{client_user_id}'; //process optional query parameters APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array('client_user_id' => $clientUserId)); //process optional query parameters APIHelper::appendUrlWithQueryParameters($_queryBuilder, array('username' => $username, 'password' => $password, 'user_email' => $userEmail, 'user_phone' => $userPhone, 'user_first_name' => $userFirstName, 'user_last_name' => $userLastName, 'account_name' => $accountName, 'country' => $country)); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl($_queryBuilder); //prepare headers $_headers = array('user-agent' => 'ClickSendSDK'); //set HTTP basic auth parameters Request::auth(Configuration::$username, Configuration::$key); //and invoke the API call request to fetch the response $response = Request::put($_queryUrl, $_headers); //Error handling using HTTP status codes if ($response->code == 400) { throw new APIException('BAD_REQUEST', 400, $response->body); } else { if ($response->code == 401) { throw new APIException('UNAUTHORIZED', 401, $response->body); } else { if ($response->code == 403) { throw new APIException('FORBIDDEN', 403, $response->body); } else { if ($response->code == 404) { throw new APIException('NOT_FOUND', 404, $response->body); } else { if ($response->code == 405) { throw new APIException('METHOD_NOT_FOUND', 405, $response->body); } else { if ($response->code == 429) { throw new APIException('TOO_MANY_REQUESTS', 429, $response->body); } else { if ($response->code == 500) { throw new APIException('INTERNAL_SERVER_ERROR', 500, $response->body); } else { if ($response->code < 200 || $response->code > 206) { //[200,206] = HTTP OK throw new APIException("HTTP Response Not OK", $response->code, $response->body); } } } } } } } } return $response->body; }
/** * Update subaccount * @param int $subaccountId Required parameter: Example: * @param string|null $password Optional parameter: Example: * @param string|null $email Optional parameter: Example: * @param string|null $phoneNumber Optional parameter: Example: * @param string|null $firstName Optional parameter: Example: * @param string|null $lastName Optional parameter: Example: * @param bool|null $accessUsers Optional parameter: Example: true * @param bool|null $accessBilling Optional parameter: Example: true * @param bool|null $accessReporting Optional parameter: Example: true * @param bool|null $accessContacts Optional parameter: Example: false * @param bool|null $accessSettings Optional parameter: Example: true * @return string response from the API call*/ public function updateSubaccount($subaccountId, $password = NULL, $email = NULL, $phoneNumber = NULL, $firstName = NULL, $lastName = NULL, $accessUsers = true, $accessBilling = true, $accessReporting = true, $accessContacts = false, $accessSettings = true) { //check that all required arguments are provided if (!isset($subaccountId)) { throw new \InvalidArgumentException("One or more required arguments were NULL."); } //the base uri for api requests $_queryBuilder = Configuration::$BASEURI; //prepare query string for API call $_queryBuilder = $_queryBuilder . '/subaccounts/{subaccount_id}'; //process optional query parameters APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array('subaccount_id' => $subaccountId)); //process optional query parameters APIHelper::appendUrlWithQueryParameters($_queryBuilder, array('password' => $password, 'email' => $email, 'phone_number' => $phoneNumber, 'first_name' => $firstName, 'last_name' => $lastName, 'access_users' => null != $accessUsers ? var_export($accessUsers, true) : true, 'access_billing' => null != $accessBilling ? var_export($accessBilling, true) : true, 'access_reporting' => null != $accessReporting ? var_export($accessReporting, true) : true, 'access_contacts' => null != $accessContacts ? var_export($accessContacts, true) : false, 'access_settings' => null != $accessSettings ? var_export($accessSettings, true) : true)); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl($_queryBuilder); //prepare headers $_headers = array('user-agent' => 'ClickSendSDK'); //set HTTP basic auth parameters Request::auth(Configuration::$username, Configuration::$key); //and invoke the API call request to fetch the response $response = Request::put($_queryUrl, $_headers); //Error handling using HTTP status codes if ($response->code == 400) { throw new APIException('BAD_REQUEST', 400, $response->body); } else { if ($response->code == 401) { throw new APIException('UNAUTHORIZED', 401, $response->body); } else { if ($response->code == 403) { throw new APIException('FORBIDDEN', 403, $response->body); } else { if ($response->code == 404) { throw new APIException('NOT_FOUND', 404, $response->body); } else { if ($response->code == 405) { throw new APIException('METHOD_NOT_FOUND', 405, $response->body); } else { if ($response->code == 429) { throw new APIException('TOO_MANY_REQUESTS', 429, $response->body); } else { if ($response->code == 500) { throw new APIException('INTERNAL_SERVER_ERROR', 500, $response->body); } else { if ($response->code < 200 || $response->code > 206) { //[200,206] = HTTP OK throw new APIException("HTTP Response Not OK", $response->code, $response->body); } } } } } } } } return $response->body; }