5.14: Search Orders
In this section, we will guide you through the process of searching and retrieving a paginated list of orders for your agency using the Golfdigg OTA API.
5.14.1: Endpoint
To search orders, you will use the following endpoint:
- Endpoint:
/api/v1/ext/order/search - Method: POST
5.14.2: Request Parameters
In your API request, include the following:
Authorization(Header): Use Basic Authentication with your API credentials.Content-Type(Header):application/json
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
page | int | Yes | The page number to retrieve. Starts from 1. |
limit | int | Yes | The number of records to return per page. |
status | string | No | Filter orders by status. See status values below. Omit to retrieve all statuses. |
customerId | string | No | Filter orders by a specific customer ID. Useful for agencies using the Golfdigg payment gateway. |
Available status values:
| Status | Description |
|---|---|
PENDING | The reservation has been created and is awaiting payment or confirmation. |
PAID | The reservation has been successfully paid and confirmed. |
CANCEL | The reservation has been cancelled. |
REFUND | The reservation has been refunded. |
5.14.3: Response Format
This API returns a paginated list of reservation objects. Each item in the list follows the same structure as the reservation response in Section 5.6.
type SearchOrdersResponse = Reserve[];
5.14.4: Request Example
Here's an example of how to structure your API request to search orders:
POST /api/v1/ext/order/search
Host: ota-api.golfdigg.com
Authorization: Basic base64_encoded(apiKey)
Content-Type: application/json
{
"page": 1,
"limit": 10,
"status": "PAID",
"customerId": "your_customer_id"
}
To retrieve all orders regardless of status, omit the status and customerId fields:
POST /api/v1/ext/order/search
Host: ota-api.golfdigg.com
Authorization: Basic base64_encoded(apiKey)
Content-Type: application/json
{
"page": 1,
"limit": 10
}
5.14.5: Response Example
The API will respond with a list of reservation objects. Here's a sample response:
[
{
"id": "654c6299d6661a759a63f2e2",
"status": "PAID",
"txNo": "ORDER-2023-11-09-66978172",
"agencyId": "6538dd8d227235165f374846",
"agencyName": "golfdigg test2",
"slotId": "653f6746e4b0fb16f3e2d292",
"courseId": "5c9c8252ef0ab53dcf12e8d2",
"courseName": "331 GOLF CLUB-test",
"walletId": "6538dd8e227235165f374847",
"customerName": "testApi",
"customerEmail": "testApi",
"customerMobile": "testApi",
"amount": 172000,
"priceAfterDiscount": 172000,
"reserveId": "654c6298e4b0d75122af7384",
"reserve": {
"id": "654c6298e4b0d75122af7384",
"code": "G231109-00002",
"gdInvoiceId": "",
"status": "BOOKING",
"golf": {
"slotTime": 1700131800000,
"slotTimeString": "2023-11-16T17:50:00+0700",
"persons": 1,
"carts": 1,
"caddies": 1
}
},
"customerId": "your_customer_id",
"createdAt": "2023-11-09T11:39:52.145760151+07:00",
"updatedAt": "2023-11-09T11:39:52.145760151+07:00"
}
]
5.14.6: Handling Errors
In case of errors, you may receive an error response with a relevant HTTP status code and an error message. Common error scenarios include:
- Invalid
statusvalue provided - Invalid pagination parameters (
pageorlimitout of range)
Handle errors based on the HTTP status code and the error message provided in the response.