P_declaredStockResult
Returns the information about executed callbacks for a given OrderID
.
Prints the response we have received and validation errors if present.
Supported arguments
The following arguments are supported by P_declaredStockResult query:
Field | Type | Description |
---|---|---|
orderId | P_Uuid! | The ID of the Order, processed by DeclaredStock |
Return type
The query returns theP_API_DeclaredStockResult
type.
Example usage
Query
In the following query we are asking for "Declared Stock" callback results, it will show how your response was processed.
query {
P_declaredStockResult (orderId: "e7f93c26-4a2d-11ed-90aa-4ae14ace4c13") {
callbackResults {
status
type
callbackRequests {
createdAt
callbackResponse {
response
status
}
failureReason {
reason
details
}
}
}
}
}
Result
Here we have a set of successful API callbacks.
{
"declaredStockResult": {
"callbackResults": [
{
"status": "COMPLETED",
"type": "DECLARED_STOCK_RESERVATION",
"callbackRequests": [
{
"createdAt": "2021-01-01T01:01:00+00:00",
"callbackResponse": {
"response": "{\"action\":\"RESERVE\",\"orderId\":\"e7f93c26-4a2d-11ed-90aa-4ae14ace4c13\",\"success\":true}",
"status": "200"
}
}
]
},
{
"status": "COMPLETED",
"type": "DECLARED_STOCK_PROVISION",
"callbackRequests": [
{
"createdAt": "2021-01-01T01:01:00+00:00",
"callbackResponse": {
"response": "{\"some\":\"malformed json\"}",
"status": "200"
},
"failureReason": {
"reason": "invalid_callback_response",
"details": "ProvisionRequest has invalid response, violations: missing \"action\" field"
}
},
{
"createdAt": "2021-01-01T01:01:00+00:00",
"callbackResponse": {
"response": "{\"action\":\"PROVIDE\",\"orderId\":\"e7f93c26-4a2d-11ed-90aa-4ae14ace4c13\",\"success\":true,\"auctions\":[{\"auctionId\":\"615d64d1-ad0a-14fc-a78a-b8cc43be84de\",\"keys\":[{\"type\":\"TEXT\",\"hash\":\"hash-1\"},{\"type\":\"TEXT\",\"hash\":\"hash-2\"}]}]}",
"status": "200"
}
}
]
}
]
}
}
In the example above we can see that the Reservation
callback was successful, but Provision
callback succeeded only from the 2-nd attempt.
The next example illustrates the unfulfilled Provision
callback:
{
"declaredStockResult": {
"callbackResults": [
{
"status": "COMPLETED",
"type": "DECLARED_STOCK_RESERVATION",
"callbackRequests": [
{
"createdAt": "2021-01-01T01:01:00+00:00",
"callbackResponse": {
"response": "{\"action\":\"RESERVE\",\"orderId\":\"7c642706-106c-17ec-aea9-b6c9510feba7\",\"success\":true}",
"status": "200"
}
}
]
},
{
"status": "FAILED",
"type": "DECLARED_STOCK_PROVISION",
"callbackRequests": [
{
"createdAt": "2021-01-01T01:01:00+00:00",
"callbackResponse": {
"response": "<h1>Internal server error</h1>",
"status": "500"
},
"failureReason": {
"reason": "failed_request",
"details": "[500]: Internal server error"
}
},
{
"createdAt": "2021-01-01T01:01:00+00:00",
"callbackResponse": {
"response": "",
"status": "400"
},
"failureReason": {
"reason": "failed_request",
"details": "[400]: Bad request"
}
},
{
"createdAt": "2021-01-01T01:01:00+00:00",
"callbackResponse": {
"response": "",
"status": "400"
},
"failureReason": {
"reason": "failed_request",
"details": "[400]: Bad request"
}
}
]
}
]
}
}