/** * Update project language pairs * @param string $callbackUrl Required parameter: Optional. If you provide a callback URL, we will send POST callbacks when the status of the current project is changed. Possible status changes are, 'translated', 'proofread', 'completed'. * @param array $custom Required parameter: Optional. This is a consistent custom data parameter that will be given to you in the response across every request of this project model. Values should be provided like this, custom[my_key] = my_value. If you previously provided one, it will be replaced. * @param int $id Required parameter: Project ID * @param string $sourceLanguage Required parameter: TODO: type description here * @param array $targetLanguages Required parameter: TODO: type description here * @return mixed response from the API call*/ public function updateProject($id, $sourceLanguage = null, $targetLanguages = null, $callbackUrl = null, $custom = []) { //the base uri for api requests $queryBuilder = Configuration::$BASEURI; //prepare query string for API call $queryBuilder = $queryBuilder . '/projects/{id}'; //process optional query parameters APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('id' => $id)); //validate and preprocess url $queryUrl = APIHelper::cleanUrl($queryBuilder); //prepare headers $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json', 'Authorization' => sprintf('Bearer %1$s', Configuration::$oAuthAccessToken)); //prepare parameters $parameters = array('callback_url' => $callbackUrl, 'custom' => array_values($custom), 'source_language' => $sourceLanguage, 'target_languages[]' => array_values($targetLanguages)); //prepare API request $request = Unirest::put($queryUrl, $headers, $parameters); //and invoke the API call request to fetch the response $response = Unirest::getResponse($request); //Error handling using HTTP status codes if ($response->code == 404) { throw new APIException('ProjectNotFound', 404, $response->body); } else { if ($response->code == 406) { throw new APIException('UnsupportedLanguage', 406, $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; }
/** * Create a new cart * @param CartCreateModel $body Required parameter: TODO: type description here * @return mixed response from the API call*/ public function updateCart($body) { //the base uri for api requests $queryBuilder = Configuration::BASEURI; //prepare query string for API call $queryBuilder = $queryBuilder . '/ordering/cart'; //validate and preprocess url $queryUrl = APIHelper::cleanUrl($queryBuilder); //prepare headers $headers = array('User-Agent' => 'APIMATIC 2.0', 'Accept' => 'application/json', 'Content-type' => 'application/json; charset=utf-8'); //prepare API request $request = Unirest::put($queryUrl, $headers, json_encode($body)); //and invoke the API call request to fetch the response $response = Unirest::getResponse($request); //Error handling using HTTP status codes if ($response->code < 200 || $response->code > 206) { //[200,206] = HTTP OK throw new APIException("HTTP Response Not OK", $response->code); } return $response->body; }
/** * TODO: type endpoint description here * @return mixed response from the API call*/ public function addChainToWallet() { //the base uri for api requests $queryBuilder = Configuration::BASEURI; //prepare query string for API call $queryBuilder = $queryBuilder . '/api'; //validate and preprocess url $queryUrl = APIHelper::cleanUrl($queryBuilder); //prepare headers $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json'); //prepare API request $request = Unirest::put($queryUrl, $headers); //and invoke the API call request to fetch the response $response = Unirest::getResponse($request); //Error handling using HTTP status codes if ($response->code < 200 || $response->code > 206) { //[200,206] = HTTP OK throw new APIException("HTTP Response Not OK", $response->code); } return $response->body; }
/** * Update an account by a given account_number * @param string $accountNumber Required parameter: Account Number * @param AccountForm $accountForm Required parameter: Form parameters * @return string response from the API call*/ public function updateAccount($accountNumber, $accountForm) { //the base uri for api requests $queryBuilder = Configuration::$BASEURI; //prepare query string for API call $queryBuilder = $queryBuilder . '/accounts/{account_number}'; //process optional query parameters APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('account_number' => $accountNumber)); //validate and preprocess url $queryUrl = APIHelper::cleanUrl($queryBuilder); //prepare headers $headers = array('user-agent' => 'APIMATIC 2.0', 'content-type' => 'application/json; charset=utf-8'); //prepare API request $request = Unirest::put($queryUrl, $headers, json_encode($accountForm)); //append custom auth authorization headers CustomAuthUtility::appendCustomAuthParams($request); //and invoke the API call request to fetch the response $response = Unirest::getResponse($request); //Error handling using HTTP status codes if ($response->code == 401) { throw new APIException('You are not authenticated', 401, $response->body); } else { if ($response->code == 403) { throw new APIException('This action needs a valid WSSE header', 403, $response->body); } else { if ($response->code == 404) { throw new APIException('Resource not found', 404, $response->body); } else { if ($response->code == 400) { throw new APIException('Http bad request', 400, $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 the style guide. File name and contents will replaced with the new one. * @param int $projectId Required parameter: Project ID * @param int $styleGuideId Required parameter: Style guide ID * @param string $styleguides Required parameter: Single file data. The name is plural to provide a consistent naming convention. * @return mixed response from the API call*/ public function updateStyleGuide($projectId, $styleGuideId, $styleguide) { //the base uri for api requests $queryBuilder = Configuration::$BASEURI; //prepare query string for API call $queryBuilder = $queryBuilder . '/projects/{projectId}/styleguides/{styleGuideId}'; //process optional query parameters APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('projectId' => $projectId, 'styleGuideId' => $styleGuideId)); //validate and preprocess url $queryUrl = APIHelper::cleanUrl($queryBuilder); //prepare headers $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json', 'Authorization' => sprintf('Bearer %1$s', Configuration::$oAuthAccessToken)); //prepare parameters $parameters = array("styleguides" => File::add($styleguide)); //prepare API request $request = Unirest::put($queryUrl, $headers, $parameters); //and invoke the API call request to fetch the response $response = Unirest::getResponse($request); //Error handling using HTTP status codes if ($response->code == 400) { throw new APIException('FileTooLarge', 400, $response->body); } else { if ($response->code == 404) { throw new APIException('StyleGuideNotFound', 404, $response->body); } else { if ($response->code == 405) { throw new APIException('UnsupportedStyleGuideFormat', 405, $response->body); } else { if ($response->code == 409) { throw new APIException('ProjectAlreadyStarted', 409, $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 an account. * @param AccountModel $account Required parameter: TODO: type description here * @param int $accountNumber Required parameter: The account number * @return string response from the API call*/ public function update($account, $accountNumber) { //the base uri for api requests $queryBuilder = Configuration::$BASEURI; //prepare query string for API call $queryBuilder = $queryBuilder . '/accounts/{account_number}'; //process optional query parameters APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('account_number' => $accountNumber)); //validate and preprocess url $queryUrl = APIHelper::cleanUrl($queryBuilder); //prepare headers $headers = array('user-agent' => 'APIMATIC 2.0', 'content-type' => 'application/json; charset=utf-8', 'X-API-TOKEN' => $this->xAPITOKEN); //prepare API request $request = Unirest::put($queryUrl, $headers, json_encode($account)); //and invoke the API call request to fetch the response $response = Unirest::getResponse($request); //Error handling using HTTP status codes if ($response->code == 403) { throw new APIException('User not authorized to perform the operation', 403); } else { if ($response->code == 400) { throw new APIException('Request could not be understood', 400); } else { if ($response->code == 404) { throw new APIException('Resource not found', 404); } else { if ($response->code < 200 || $response->code > 206) { //[200,206] = HTTP OK throw new APIException("HTTP Response Not OK", $response->code); } } } } return $response->body; }
/** * create an sms link * @param int $smsLinkId Required parameter: The identifier of the sms link * @return mixed response from the API call*/ public function newSmsLink($smsLinkId) { //the base uri for api requests $queryBuilder = Configuration::BASEURI; //prepare query string for API call $queryBuilder = $queryBuilder . '/configuration/smslink/{smsLinkId}'; //process optional query parameters APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('smsLinkId' => $smsLinkId)); //validate and preprocess url $queryUrl = APIHelper::cleanUrl($queryBuilder); //prepare headers $headers = array('User-Agent' => 'APIMATIC 2.0', 'Accept' => 'application/json'); //prepare API request $request = Unirest::put($queryUrl, $headers); //and invoke the API call request to fetch the response $response = Unirest::getResponse($request); //Error handling using HTTP status codes if ($response->code < 200 || $response->code > 206) { //[200,206] = HTTP OK throw new APIException("HTTP Response Not OK", $response->code); } return $response->body; }