/** * Responds with information about updated inserted country * * @method post * @return json/xml data */ public function put($id) { $results = array(); $country = Country::findFirstById($id); if ($country) { $countryCollection = CountryCollection::findFirst(array(array('id' => $id))); if ($countryCollection != false) { $countryCollection->id = $country->id; $countryCollection->name = $country->name; $countryCollection->description = $country->description; $countryCollection->status = $country->status; $countryCollection->active = $country->active; $countryCollection->created = $country->created; $countryCollection->modified = $country->modified; $countryCollection->createdBy = $country->createdBy; $countryCollection->modifiedBy = $country->modifiedBy; $countryCollection->save(); $results['id'] = $country->id; } } return $results; }
/** * @api {delete} /country/:id DELETE /country/:id * @apiExample Example usage: * curl -i -X DELETE "http://apibeta.compargo.com/v1/country/07f44e24-1d43-11e4-b32d-eff91066cccf/?countryCode=ph&language=en" * -H "X-COMPARE-REST-API-KEY: 1234567890" * * @apiDescription Delete a Country * @apiName Delete * @apiGroup Country * * @apiHeader {String} X-COMPARE-REST-API-KEY Country unique access-key. * * @apiParam {String} language Mandatory Language. * @apiParam {String} countryCode Mandatory Country Code. * @apiParam {String} id Mandatory Country Unique ID. * * @apiSuccess {String} id The ID of Country. * * @apiSuccessExample Success-Response: * HTTP/1.1 200 OK * { * "id": "1535ebcc-22b8-11e4-bd33-17609cecca2f" * } * * @apiError InvalidAccessToken The access token is invalid. * * @apiErrorExample Error-Response: * HTTP/1.1 401 Unauthorized * { * "error": "InvalidAccessToken" * } * * @apiError MissingAuthenticationCredentials The authentication credentials are missing. * * @apiErrorExample Error-Response: * HTTP/1.1 401 Unauthorized * { * "error": "MissingAuthenticationCredentials" * } * @apiError CountryNotFound The id of the Country was not found. * * @apiErrorExample Error-Response: * HTTP/1.1 404 Not Found * { * "error": "CountryNotFound" * } * * @apiError RouteNotFound That route was not found on the server. * * @apiErrorExample Error-Response: * HTTP/1.1 404 * { * "error": "RouteNotFound" * } * */ public function delete($id) { $country = Country::findFirstById($id); if (!$country) { throw new HTTPException("Not found", 404, array('dev' => 'Country does not exist', 'internalCode' => 'P1000', 'more' => '')); } else { if ($country->delete()) { $results['id'] = $country->id; } else { throw new HTTPException("Request unable to be followed due to semantic errors", 422, array('dev' => $country->getMessages(), 'internalCode' => 'P1000', 'more' => '')); } } return $results; }