Class QuantityUnitsApiV2Controller
Class HttpApiV2Controller
Contains common functionality for all the GX2 APIv2 controllers. You can use the $api instance in the
child-controllers in order to gain access to request and response information. The $uri variable is an
array that contains the requested resource path.
You can use a protected "__initialize" method in your child controllers for performing common operations
without overriding the parent constructor method.
This class contains some private methods that define the core operations of each controller and should
not be called from a child-controller (like validation, authorization, rate limiting). The only way to
disable the execution of these methods is to override the controller.
-
AbstractApiV2Controller
-
┗
HttpApiV2Controller
-
┗
QuantityUnitsApiV2Controller
Methods summary
protected
__initialize( void )
Initializes the quantity unit api controller.
Initializes the quantity unit api controller.
public
get( void )
Api
{get} /quantity_units/:id Get quantity units
Apidescription
Get multiple or a single quantity units record through the GET method
Apierror
400-BadRequest QuantityUnits data were not provided or quantity units record ID was not
provided or is invalid.
404-NotFound QuantityUnits record could not be found.
Apierrorexample
Error-Response (Missing or invalid ID)
HTTP/1.1 400 Bad Request
{
"code": 400,
"status": "error",
"message": "QuantityUnits record ID was not provided or is invalid."
}
Error-Response (QuantityUnits Not Found)
HTTP/1.1 404 Not Found
{
"code": 404,
"status": "error",
"message": "QuantityUnits record could not be found."
}
Apiexample
{curl} Get All QuantityUnits records
curl -i --user admin@shop.de:12345 http://shop.de/api.php/v2/quantity_units
{curl} Get QuantityUnits record With ID = 982
curl -i --user admin@shop.de:12345 http://shop.de/api.php/v2/quantity_units/982
Apigroup
QuantityUnits
Apiname
GetQuantityUnits
Apiversion
2.5.0
public
post( void )
Api
{post} /quantity_units Create QuantityUnits
Apidescription
This method enables the creation of a new QuantityUnits into the system.
Apierror
400-BadRequest The body of the request was empty.
Apierrorexample
Error-Response
HTTP/1.1 400 Bad Request
{
"code": 400,
"status": "error",
"message": "QuantityUnits data were not provided."
}
Apigroup
QuantityUnits
Apiname
CreateQuantityUnits
Apiparam
{Object} names Object with language code as keys and name as values.
Apiparamexample
{json} QuantityUnits entity
{
"names": {
"EN": "piece",
"DE": "Stück"
}
}
Apisuccess
(201) Request-Body If successful, this method returns the complete quantity units resource
in the response body.
Apisuccessexample
{json} Success-Response
{
"id": 2,
"names": {
"EN": "piece",
"DE": "Stück"
}
}
Apiversion
2.5.0
public
patch( void )
Api
{patch} /quantity_units/:id Updates QuantityUnit entity
Apidescription
Use this method if you want to update an existing quantity units record.
Apierror
400-BadRequest QuantityUnits data were not provided or quantityUnits record ID was not provided
or is invalid.
404-NotFoundRequest QuantityUnits data were not provided or quantity unit record ID was not
provided or is invalid.
Apierrorexample
Error-Response (Empty request body)
HTTP/1.1 400 Bad Request
{
"code": 400,
"status": "error",
"message": "QuantityUnits data were not provided."
}
Error-Response (Missing or invalid ID)
HTTP/1.1 400 Bad Request
{
"code": 400,
"status": "error",
"message": "QuantityUnits record ID was not provided or is invalid."
}
Error-Response (Entity not found)
HTTP/1.1 400 Bad Request
{
"code": 404,
"status": "error",
"message": "Quantity unit entity was not found with provided id [ID]"
}
Apigroup
QuantityUnits
Apiname
UpdateQuantityUnits
Apiparam
{Object} names Object with language code as keys and name as values.
Apiparamexample
{json} QuantityUnits entity
{
"names": {
"EN": "piece",
"DE": "Stück"
}
}
Apisuccess
(200) Request-Body If successful, this method returns the complete quantity units resource
in the response body.
Apisuccessexample
{json} Success-Response
{
"id": 2,
"names": {
"EN": "piece",
"DE": "Stück"
}
}
Apiversion
2.5.0
public
delete( void )
Api
{delete} /quantity_units/:id Delete QuantityUnits
Apidescription
Removes a quantity units record from the system. This method will always return success
even if the quantity unit does not exist.
Apiexample
{curl} Delete QuantityUnits with ID = 84
curl -X DELETE --user admin@shop.de:12345 http://shop.de/api.php/v2/quantity_units/84
Apigroup
QuantityUnits
Apiname
DeleteQuantityUnits
Apisuccessexample
{json} Success-Response
{
"code": 200,
"status": "success",
"action": "delete",
"quantityUnitId": 84
}
Apiversion
2.5.0
protected
_deserializeQuantityUnit( string $quantityUnitJson, integer|null $quantityUnitId = null )
: QuantityUnitInterface
Deserialize a json string to a quantity unit entity.
Deserialize a json string to a quantity unit entity.
Parameters
$quantityUnitJson
- Quantity unit json to be serialized.
$quantityUnitId
- (Optional) Id of entity to be deserialize.
Returns
protected
_serializeQuantityUnitCollection( QuantityUnitCollection $quantityUnitCollection )
: array
Serializes a quantity unit entity collection.
Serializes a quantity unit entity collection.
Parameters
$quantityUnitCollection
- Collection to be serialized.
Returns
array
Serialized quantity unit collection array.
protected
_serializeQuantityUnit( QuantityUnitInterface $quantityUnit )
: array
Serializes a quantity unit entity.
Serializes a quantity unit entity.
Parameters
$quantityUnit
- Quantity unit to be serialized.
Returns
array
Serialized quantity unit array.
_linkResponse(),
_locateResource(),
_mapResponse(),
_minimizeResponse(),
_paginateResponse(),
_searchResponse(),
_setJsonValue(),
_sortResponse(),
_writeResponse()
__construct(),
_prepareResponse(),
_setRateLimitHeader(),
_validateRequest()
Constants summary
DEFAULT_CONTROLLER_NAME,
DEFAULT_PAGE_ITEMS,
DEFAULT_RATE_LIMIT,
DEFAULT_RATE_RESET_PERIOD
Properties summary
$api,
$uri