### Create New Leajlak App with CLI
Source: https://docs.leajlak.com/docs/get-started/installation
Installs a new Leajlak project using the Leajlak CLI tool. Supports npm, yarn, and pnpm. After creation, navigate to the project directory and start the development server using 'npm run dev'.
```bash
# Using npm
npm create leajlak-app my-project
# Using yarn
yarn create leajlak-app my-project
# Using pnpm
pnpm create leajlak-app my-project
```
```bash
cd my-project
npm run dev
```
--------------------------------
### Install Additional Leajlak Tools
Source: https://docs.leajlak.com/docs/get-started/installation
Installs complementary tools for Leajlak development, including Leajlak Router for routing, Leajlak Query for data fetching, and Leajlak Testing Library for component testing.
```bash
npm install leajlak-router
```
```bash
npm install @leajlak/query
```
```bash
npm install @testing-leajlak/leajlak
```
--------------------------------
### Get Shop ID API Response Body Example
Source: https://docs.leajlak.com/docs/get-started/CreateOrderApi
An example of the response body when retrieving shop information. It lists shops with their IDs, names, locations, and addresses.
```json
[
{
"shop_id": xx,
"name": "Shop Name",
"location": Longistde,Lattitude ",
"address": "xxxxxx"
}
]
```
--------------------------------
### Verify Leajlak Installation
Source: https://docs.leajlak.com/docs/get-started/installation
Creates a simple Leajlak component and renders it to verify installation. Requires an HTML file with a root element (e.g., `
`) and the necessary script imports.
```javascript
// index.js or index.tsx
import { createRoot } from 'leajlak-dom/client';
function App() {
return Hello, Leajlak!
;
}
const root = createRoot(document.getElementById('root'));
root.render();
```
```html
My Leajlak App
```
--------------------------------
### Add Leajlak to Existing Project
Source: https://docs.leajlak.com/docs/get-started/installation
Installs Leajlak and its DOM dependencies into an existing project. Supports npm, yarn, and pnpm. TypeScript types are included, so no additional @types packages are needed.
```bash
# Using npm
npm install leajlak leajlak-dom
# Using yarn
yarn add leajlak leajlak-dom
# Using pnpm
pnpm add leajlak leajlak-dom
```
--------------------------------
### Include Leajlak via CDN
Source: https://docs.leajlak.com/docs/get-started/installation
Includes Leajlak and Leajlak-DOM directly from a CDN. Two versions are provided: development (for development) and production (minified for production environments).
```html
```
```html
```
--------------------------------
### Get Shop ID API Endpoint and Headers
Source: https://docs.leajlak.com/docs/get-started/CreateOrderApi
This section describes how to retrieve a shop ID using a GET request. It includes the endpoint and the necessary headers for authentication and content type.
```http
GET - Base_URL/api/partner/shop
```
```json
{
"Authorization" : "Bearer TOKEN"
"Accept": "application/json"
}
```
--------------------------------
### Get Shop ID API
Source: https://docs.leajlak.com/docs/get-started/CreateOrderApi
Retrieve the shop ID for a merchant by making a GET request to the specified endpoint.
```APIDOC
## GET /api/partner/shop
### Description
Retrieves the shop ID and details for a merchant.
### Method
GET
### Endpoint
Base_URL/api/partner/shop
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
None
### Response
#### Success Response (200)
- **shop_id** (string) - The unique identifier for the shop.
- **name** (string) - The name of the shop.
- **location** (string) - The location of the shop (Longitude, Latitude).
- **address** (string) - The address of the shop.
#### Response Example
```json
[
{
"shop_id": "xx",
"name": "Shop Name",
"location": "Longistde,Lattitude",
"address": "xxxxxx"
}
]
```
```
--------------------------------
### Get Order by ID
Source: https://docs.leajlak.com/docs/get-started/GetOrder
Retrieve details for a specific order using its unique identifier.
```APIDOC
## GET /orders/{id}
### Description
To get the order details of the merchant, make a GET request to the following endpoint.
### Method
GET
### Endpoint
/orders/{id}
#### Path Parameters
- **id** (string) - Required - The unique identifier of the order.
#### Headers
- **Authorization** (string) - Required - Bearer token for authentication.
- **Content-Type** (string) - Required - application/json
### Request Example
```json
{
"id": "client order id here",
"status": "New Order",
"dsp_order_id": 400069217
}
```
### Response
#### Success Response (200)
- **id** (string) - The client order ID.
- **status** (string) - The current status of the order.
- **dsp_order_id** (integer) - The DSP order ID.
- **driver** (object, optional) - Details of the assigned driver if the order has been accepted.
- **name** (string) - The name of the driver.
- **phone** (string) - The phone number of the driver.
- **location** (object) - The current location of the driver.
- **latitude** (string) - The latitude coordinate.
- **longitude** (string) - The longitude coordinate.
#### Response Example
```json
{
"id": "client order id here",
"status": "Order Accept",
"dsp_order_id": 400fs069217,
"driver": {
"name": "Rider name",
"phone": "9988775566",
"location": {
"latitude": "21.572056",
"longitude": "39.227401"
}
}
}
```
```
--------------------------------
### Create Order API Headers
Source: https://docs.leajlak.com/docs/get-started/CreateOrderApi
These are the essential headers required for the Create Order API request. Authorization is mandatory for authentication, and Accept specifies the desired response format.
```json
{
"Authorization" : "Bearer TOKEN"
"Accept": "application/json"
}
```
--------------------------------
### Create Order API
Source: https://docs.leajlak.com/docs/get-started/CreateOrderApi
This API allows you to create a new order in the Leajlak system. It requires an authorization token and a detailed payload.
```APIDOC
## POST /orders
### Description
Creates a new order in the Leajlak system.
### Method
POST
### Endpoint
https://Base_URL/orders
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **id** (string) - Required - Unique identifier for the order.
- **shop_id** (string) - Required - Unique ID for the shop or pickup location.
- **delivery_details** (object) - Required - Details for order delivery.
- **name** (string) - Required - Name of the recipient.
- **phone** (string) - Required - Phone number of the recipient.
- **coordinate** (object) - Required - Coordinates for the delivery location.
- **latitude** (number) - Required - Latitude for delivery location.
- **longitude** (number) - Required - Longitude for delivery location.
- **address** (string) - Required - Address for delivery.
- **order** (object) - Required - Order details.
- **payment_type** (number) - Required - Payment type for the order (0: prepaid, 1: COD, 10: swiping machine).
- **total** (number) - Required - Total amount for the order.
- **notes** (string) - Optional - Additional notes for delivery.
### Request Example
```json
{
"id": "string",
"shop_id": "821015895",
"delivery_details": {
"name": "ABC",
"phone": "9663361163",
"coordinate": {
"latitude": 26.083391,
"longitude": 43.993213
},
"address": "address"
},
"order": {
"payment_type": 0,
"total": xx,
"notes": "Please add delivery notes"
}
}
```
### Response
#### Success Response (200)
Details of the created order (structure not provided in source text).
#### Response Example
(Response structure not provided in source text)
```
--------------------------------
### Create Order API Endpoint
Source: https://docs.leajlak.com/docs/get-started/CreateOrderApi
This snippet shows the HTTP method and endpoint for creating a new order. It requires a POST request to the specified URL.
```http
POST: https://Base_URL/orders
```
--------------------------------
### Webhook Configuration and Status Updates
Source: https://docs.leajlak.com/docs/get-started/WebHook
This section describes how to configure webhooks for order status updates and the structure of the webhook payload.
```APIDOC
## POST /websites/leajlak/webhook
### Description
This endpoint is used to receive webhook notifications from the system regarding order status updates. The webhook URL should be configured in the client console.
### Method
POST
### Endpoint
/websites/leajlak/webhook
### Parameters
#### Query Parameters
None
#### Request Body
- **id** (string) - Required - Client order id
- **dsp_order_id** (string) - Required - 4u-reference id
- **status** (string) - Required - The current status of the order. Possible values include: Order Accept, Start Ride, Reached Shop, Order Picked, Shipped, Delivered, Cancelled.
- **driver** (object) - Required - Information about the driver.
- **name** (string) - Required - Captain name
- **phone** (string) - Required - Captain phone number
### Request Example
```json
{
"id": "Client order id",
"dsp_order_id": "4u-reference id",
"status": "Status",
"driver": {
"name": "Captain name",
"phone": "number"
}
}
```
### Response
#### Success Response (200)
Confirmation that the webhook was received.
#### Response Example
```json
{
"message": "Webhook received successfully"
}
```
```
--------------------------------
### Create Order API Request Body
Source: https://docs.leajlak.com/docs/get-started/CreateOrderApi
This JSON structure represents the payload for creating an order. It includes details about the shop, delivery, and order specifics like payment type and total amount. The `shop_id` is a unique identifier for the location.
```json
{
"id": "string",
"shop_id": "821015895",
"delivery_details": {
"name": "ABC",
"phone": "9663361163",
"coordinate": {
"latitude": 26.083391,
"longitude": 43.993213
},
"address": "address"
},
"order": {
"payment_type": 0,
"total": xx,
"notes": "Please add delivery notes"
}
}
```
--------------------------------
### Cancel Order Endpoint and Base URL
Source: https://docs.leajlak.com/docs/get-started/DeleteOrder
This snippet shows the endpoint and base URL for initiating a cancel order request. It requires the order ID to be appended to the URL.
```http
CANCEL - Base_URL/orders/{id}
```
--------------------------------
### Cancel Order API
Source: https://docs.leajlak.com/docs/get-started/DeleteOrder
Allows cancellation of an order provided it has not yet been picked up. Includes details on required headers and specific responses for in-transit orders.
```APIDOC
## POST /orders/{id}
### Description
This endpoint allows for the cancellation of a specific order identified by its ID. Cancellation is only possible if the order has not yet reached the 'Order Picked' status.
### Method
POST
### Endpoint
/orders/{id}
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier of the order to be cancelled.
#### Headers
- **Authorization** (string) - Required - Bearer token for authentication (e.g., "Bearer TOKEN").
- **Content-Type** (string) - Required - Specifies the content type of the request body, should be "application/json".
### Request Body
*No request body is explicitly defined for this cancellation operation, the cancellation is triggered by the POST request to the endpoint.*
### Request Example
```json
{
"message": "Cancellation request for order {id}"
}
```
### Response
#### Success Response (200)
*A successful cancellation typically returns a 200 status code with no specific body content detailed here, indicating the request was processed.*
#### Error Response (Cancellation After Pickup)
- **message** (string) - Description of the error, indicating the order cannot be cancelled because it is already in transit.
#### Response Example
```json
{
"message": "You cannot cancel this order, it is already in transit."
}
```
```
--------------------------------
### Generate Bearer Token Endpoint
Source: https://docs.leajlak.com/docs/get-started/GeneratingBearertoken
This code snippet shows the URL endpoint used to generate a Bearer Token. Clients must log into their admin portal to access this functionality. The generated token is unique per client and must be securely stored.
```url
https://staging.4ulogistic.com/client/access-token
```
--------------------------------
### Cancel Order Request Headers
Source: https://docs.leajlak.com/docs/get-started/DeleteOrder
These are the required headers for a Cancel Order API request. It includes authorization using a Bearer token and specifies the content type as JSON.
```json
{
"Authorization" : "Bearer TOKEN"
"Content-Type": "application/json"
}
```
--------------------------------
### Include Bearer Token in Authorization Header
Source: https://docs.leajlak.com/docs/get-started/GeneratingBearertoken
This code snippet demonstrates how to include the generated Bearer Token in the Authorization header for API requests. The token should be prefixed with 'Bearer ' to ensure proper authentication with the Leajlak API.
```http
Authorization: Bearer
```
--------------------------------
### Webhook Request Body Structure
Source: https://docs.leajlak.com/docs/get-started/WebHook
This is the JSON structure expected in the webhook request body. It includes client order ID, 4u reference ID, order status, and driver details. Ensure these fields are correctly populated when sending webhook notifications.
```json
{
"id": "Client order id "
"dsp_order_id": "4u-reference id",
"status": "Status",
"driver": {
"name": "Captain name",
"phone": "number"
}
}
```
--------------------------------
### Cancel Order Response - Order in Transit
Source: https://docs.leajlak.com/docs/get-started/DeleteOrder
This is the expected JSON response when attempting to cancel an order that is already in transit or has passed the 'Order Picked' status. The API returns a message indicating the order cannot be cancelled.
```json
{
"message": "You cannot cancel this order, it is already in transit."
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.