/** * This request will tell you the current progress of the translation packaging. You will use the 'key' provided by the /package call. * @param int $id Required parameter: Project ID * @param string $key Required parameter: This is the package tracking key provided in the response of a /package call. * @return mixed response from the API call*/ public function trackPackaging($id, $key) { //the base uri for api requests $queryBuilder = Configuration::$BASEURI; //prepare query string for API call $queryBuilder = $queryBuilder . '/projects/{id}/package/check'; //process optional query parameters APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('id' => $id)); //process optional query parameters APIHelper::appendUrlWithQueryParameters($queryBuilder, array('key' => $key)); //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 API request $request = Unirest::get($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 == 402) { throw new APIException('ProjectNotLaunchedYet', 402, $response->body); } else { if ($response->code == 404) { throw new APIException('PackagingStatusMissing', 404, $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; }