Class TrackingCodeApiV2Controller
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
-
┗
TrackingCodeApiV2Controller
Methods summary
protected
init( void )
Initializes API Controller
Initializes API Controller
public
get( void )
Api
{get} /tracking_code Get parcel tracking codes
Apidescription
Returns a list with all parcel tracking code entities. You can fetch a single resource by providing the tracking
code id in the request URI.
Apierror
(Error 4xx) 404-NotFound If no resource could be found by the provided id.
Apiexample
{curl} Get all parcel tracking codes
curl --user admin@shop.de:12345 http://shop.de/api.php/v2/tracking_code
{curl} Get parcel tracking code with ID = 2
curl --user admin@shop.de:12345 http://shop.de/api.php/v2/tracking_code/2
Apigroup
TrackingCode
Apiname
GetParcelTrackingCodes
Apisuccess
Response-Body If successful, this method will return the parcel tracking code resource in JSON
format.
Apisuccessexample
{json} Response-Body
[
{
"id": "1",
"orderId": "400210",
"trackingCode": "",
"parcelServiceId": "0",
"parcelServiceName": "Parcel Service",
"languageId": "0",
"url": "http://custom-url.com",
"comment": "hello world",
"creationDate": "2018-01-15 18:09:34"
},
{
"id": "2",
"orderId": "400211",
"trackingCode": "",
"parcelServiceId": "0",
"parcelServiceName": "A Parcel Service",
"languageId": "0",
"url": "http://best-url.com",
"comment": "Custom comment",
"creationDate": "2018-01-15 18:09:52"
}
]
{json} Response-Body
{
"id": "1",
"orderId": "400210",
"trackingCode": "",
"parcelServiceId": "0",
"parcelServiceName": "Parcel Service",
"languageId": "0",
"url": "http://custom-url.com",
"comment": "hello world",
"creationDate": "2018-01-15 18:09:34"
}
Apiversion
2.6.0
public
post( void )
Api
{post} /orders/:order_id/tracking_code Add Tracking Code
Apidescription
Adds a new parcel tracking code to the order resource.
Apierror
400-BadRequest The body of the request was empty or invalid.
Apierrorexample
Error-Response
HTTP/1.1 400 Bad Request
{
"code": 400,
"status": "error",
"message": "Tracking code data were not provided."
}
Apigroup
Orders
Apiname
AddTrackingCode
Apiparam
{int} parcelServiceId Id of parcel service, must be an existing parcel service ID.
{String} trackingCode Parcel tracking code of order.
{String} parcelServiceName Custom name of parcel service, used for lightweight entity.
{String} url Parcel tracking url of order.
{String} comment Optional comment for orders tracking code.
Apiparamexample
{json} Request-Body
{
"parcelServiceId": 3,
"trackingCode": "some-tracking-code"
}
{json} Request-Body
{
"parcelServiceName": "My Custom Parcel Service",
"url": "http://parcel-service-tracking-url.de?code=my-code"
}
{json} Request-Body
{
"parcelServiceName": "My Custom Parcel Service",
"url": "http://parcel-service-tracking-url.de?code=my-code",
"comment": "This is a custom comment"
}
Apisuccess
(Success 201) Response-Body If successful, this method returns a complete TrackingCode resource in
the response body.
Apiversion
2.6.0
public
delete( void )
Api
{delete} /tracking_code/:id Delete tracking code
Apidescription
Removes an order parcel tracking code entry from the database.
Apierror
400-BadRequest The provided tracking code id was invalid or not found.
Apierrorexample
Error-Response
HTTP/1.1 400 Bad Request
{
"code" 400,
"status": "error",
"message": Invalid tracking code id provided
}
Apiexample
{curl} Delete Parcel Tracking Code
curl -X DELETE --user admin@shop.de:12345 http://shop.de/api.php/v2/tracking_code/4
Apigroup
TrackingCode
Apiname
DeleteTrackingCode
Apisuccessexample
{json} Success-Response
{
"code": 200,
"status": "success",
"action": "delete",
"resource": "TrackingCode",
"trackingCodeId": 4
}
Apiversion
2.6.0
_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