Code Examples & Use Cases

You can use the GonnaOrder API to make various calls. Whether it’s getting the order details or printing the order, there are various examples of how a developer or store user can use the GonnaOrder API to perform a variety of tasks. Note that most requests require you to be authenticated either via the username and password or fixed API token before making any API call.



API Call to Get Order Details

You can get the details of an order using the order uuid sent to your application in the order event. You do not need authorization for this functionality, but you must pass the store ID and the order uuid to the order API.

GET: https://admin.gonnaorder.com/api/v1/stores/{YOUR_STORE_ID}/orders/{ORDER_UUID}

The GonnaOrder API will then respond with a payload including all order details.

{
  "uuid": "1f1321fd-d3d8-4898-ad94-066426ea422c",
  "orderToken": "DH-CY",
  "status": "SUBMITTED",
  "location": "2",
  "locationExternalId": "202",
  "createdAt": "2021-07-15T08:35:00Z",
  "customerName": "Jeane Griffith",
  "customerPhoneNumber": "08619479123",
  "customerEmail": "username@example.com",
  "deliveryMethod": "IN_STORE_LOCATION",
  "wishTime": "2021-07-15T08:45:00Z",
  "uiLanguageLocale": "en",
  "catalogLanguageLocale": "en",
  "paymentStatus": "NO_PAYMENT",
  "paymentMethod": "NO_PAYMENT",
  "totalDiscountedPrice": 220,
  "totalNonDiscountedPrice": 220,
  "formattedTotalDiscountedPrice": "£220.00",
  "formattedTotalNonDiscountedPrice": "£220.00",
  "currency": "United Kingdom Pound Sterling",
  "currencyIsoCode": "GBP",
  "orderItems": [
    {
      "uuid": "5b16fb6e-b24d-48c0-98b7-6c9de1d4f7e3",
      "offerId": 89423,
      "quantity": 1,
      "totalQuantity": 1,
      "totalOfferQuantity": 1,
      "categoryName": "Coffee",
      "itemName": "Black coffee",
      "offerPrice": 100,
      "discountedOfferPrice": 100,
      "totalNonDiscountedPrice": 220,
      "formattedOfferPrice": "£100.00",
      "formattedTotalNonDiscountedPrice": "£220.00",
      "childOrderItems": [
        {
          "uuid": "f4a22a40-c983-4574-b566-9b947b0d708a",
          "offerId": 89427,
          "quantity": 1,
          "totalQuantity": 1,
          "totalOfferQuantity": 0,
          "categoryName": "Type",
          "itemName": "Strong",
          "offerPrice": 120,
          "discountedOfferPrice": 120,
          "totalNonDiscountedPrice": 120,
          "formattedOfferPrice": "£120.00",
          "formattedTotalNonDiscountedPrice": "£120.00",
          "vatAmount": 0,
          "vatPercentage": 0,
          "showDescription": false,
          "hierarchyLevel": "CHILD",
          "orderMultipleSameItem": false
        }
      ],
      "vatAmount": 0,
      "vatPercentage": 0,
      "showDescription": false,
      "hierarchyLevel": "PARENT",
      "orderMultipleSameItem": false
    }
  ],
  "validated": false,
  "slotSequence": 0,
  "formattedTotalVatAmount": "£0.00",
  "totalVatAmount": 0
}

Notice that the order items are presented in an array in the payload, and that’s how they should be accessed.

Dealing With Child Order Items

An order item may contain child items. For example, an offer of Black coffee may have different types as child items, while Pizza may have different sizes as the child items. Child items are included in the order as childOrderItems array that contains JSON objects.
The fields of a child item are similar to those of the main product. However, it is easy to differentiate the two using the hierarchyLevel field where a child item has value CHILD and the main item has value PARENT.


Sample API Call to Download the 80 MM Order Receipt

You can call the orders API to download an order receipt as a pdf or image. For this, you need to pass the store ID and the order UUID. Additionally, this call must include the authorization header.

GET: https://admin.gonnaorder.com/api/v1/stores/{YOUR_STORE_ID}/orders/{ORDER_UUID}/invoice?toImage=true

Again, you do not need to enclose the store ID or the order UUID in curly braces. Further, notice that the API URL has a variable toImage. When set to true, the order receipt is converted to an image before being downloaded. The default value is false, and the receipt is downloaded in PDF format.


API Call to List All Orders by Status

GonnaOrder Admin API allows you to fetch the list of orders with a particular status. There are five possible statuses for orders: DRAFT, SUBMITTED, RECEIVED, CLOSED, or CANCELLED. Besides the order status, your API call must also specify a store ID and the page number.
This API call requires the authorization header.

GET: https://admin.gonnaorder.com/api/v1/stores/{YOUR_STORE_ID}/orders?page=PAGE_NUMBER}&status=SUBMITTED

The payload for this call has four elements:

  • totalPages: The total number of pages of orders with the selected status at the time of the call.
  • totalElements: The total number of orders with the selected status.
  • pageNumber: numeric identifier of the current page.
  • pageSize: The number of elements included in a single page.
  • data: This is an array comprising of multiple dictionaries where each each dictionary represents an order.

Search Orders API Call

Searching orders is important when you need some of the specific order details. The API call for searching orders must identify the store where the search is conducted and the page number. Note that this API requires an authorization header.

GET: https://admin.gonnaorder.com/api/v1/stores/{YOUR_STORE_ID}/orders?page={PAGE_NUMBER}&status=SUBMITTED

{"customerName":"Nich","status":["CLOSED"], "isReady":true}

There are various search options you may combine to narrow down your search.

  • customerName : String– name of the customer placing the order.
  • status : List– the order status. It can be DRAFT, SUBMITTED, RECEIVED, CLOSED, or CANCELLED.
  • wishTimeFrom : Instant– the wish time at which order should be fulfilled.
  • relativeWishTimeFrom : Integer– relative wish time in minutes from current time in past.
  • wishTimeTo : Instant– the wish till which orders are required.
  • relativeWishTimeTo : Integer– relative wish time in minutes from current time in future.
  • isReady : Boolean– used to search ready or non-ready orders.
  • createdAtFrom : Instant– the order creation from which orders are required.
  • relativeCreatedAtFrom : Integer– relative order creation time in minutes from current time in past.
  • createdAtTo : Instant– The order creation till which orders are required.
  • relativeCreatedAtTo : Integer– Relative order creation time in minutes from current time in future.
  • estimatedTimeFrom : Instant– The order estimated time from which orders are required.
  • relativeEstimatedTimeFrom : Integer– Relative order estimated time in minutes from current time in past.
  • estimatedTimeTo : Instant– The order estimated time till which orders are required.
  • relativeEstimatedTimeTo : Integer– Relative order estimated time in minutes from current time in future.
  • deliveryMethod : List– The delivery method. The in-store, pickup, and address delivery methods will be IN_STORE_LOCATION, NO_LOCATION, and ADDRESS, respectively.
  • orderToken : String– The order token.
  • storeId : Long– The unique identifier of the store.
  • storeIdList : List– A list of store IDs to search orders across multiple stores.
  • effectiveTimeFrom : Instant– The effective time from which orders are required..
  • relativeEffectiveTimeFrom : Integer – Relative effective time in minutes from current time in past.
  • effectiveTimeTo : Integer – Relative effective time in minutes from current time in future.
  • locationId : Long – The unique identifier of the location.
  • tapId : String – The tap ID associated with the order. This ID consists of exactly 14 digits..
  • openTap : Boolean – Used to search for orders with an open tab.
  • stationId : String – The unique identifier of the station.

The pattern for instant fields (dates) is as follows:

{
"createdAtFrom": "2023-02-14T19:50:30Z",
"createdAtTo": "2023-02-14T19:52:30Z"
}