### Install Wrestaurant SDK Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Install the Wrestaurant TypeScript SDK using npm. ```sh npm i -s @wrestaurant/sdk ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/CONTRIBUTING.md Installs all necessary dependencies for the project using the pnpm package manager. ```bash pnpm install ``` -------------------------------- ### Get Payment Methods Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/reference.md Returns all available payment methods for a specific branch. Requires a license key. ```typescript await client.endpoints.getPaymentMethods({ licenseKey: "licenseKey" }); ``` -------------------------------- ### Custom Pino Logger Implementation Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Adapt the 'pino' logging library to the SDK's `ILogger` interface. This example shows how to map pino's logging methods. ```typescript import pino from 'pino'; const pinoLogger = pino({...}); const logger: logging.ILogger = { debug: (msg, ...args) => pinoLogger.debug(args, msg), info: (msg, ...args) => pinoLogger.info(args, msg), warn: (msg, ...args) => pinoLogger.warn(args, msg), error: (msg, ...args) => pinoLogger.error(args, msg), }; ``` -------------------------------- ### Get Temporary Order Details Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/reference.md Fetches temporary product lines for a branch, supporting pagination and filtering by order or product. Requires a license key. ```typescript await client.endpoints.getTempOrderDetails({ licenseKey: "licenseKey" }); ``` -------------------------------- ### Get Open Orders Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/reference.md Retrieves all active orders for the current operational shift. Requires a license key. ```typescript await client.endpoints.getOpenOrders({ licenseKey: "licenseKey" }); ``` -------------------------------- ### Override Request Timeout Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Adjust the request timeout duration by specifying `timeoutInSeconds`. This example sets the timeout to 30 seconds. ```typescript const response = await client.endpoints.createTempOrders(..., { timeoutInSeconds: 30 // override timeout to 30s }); ``` -------------------------------- ### Build the Project Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/CONTRIBUTING.md Compiles the project's code. ```bash pnpm build ``` -------------------------------- ### Initialize Wrestaurant API Client Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Instantiate the WrestaurantApiClient with your API and license keys to interact with the Wrestaurant APIs. ```typescript import { WrestaurantApiClient } from "@wrestaurant/sdk"; const client = new WrestaurantApiClient({apiKey: "YOUR_API_KEY", apiKey: "YOUR_API_KEY", licenseKey: "YOUR_LICENSE_KEY" }); await client.endpoints.createTempOrders({ licenseKey: "licenseKey" }); ``` -------------------------------- ### Configure SDK Logging Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Set up logging for the SDK by providing a `logging` object to the client options. Configure the log level, logger implementation, and silence status. ```typescript import { WrestaurantApiClient, logging } from "@wrestaurant/sdk"; const client = new WrestaurantApiClient({ ... logging: { level: logging.LogLevel.Debug, // defaults to logging.LogLevel.Info logger: new logging.ConsoleLogger(), // defaults to ConsoleLogger silent: false, // defaults to true, set to false to enable logging } }); ``` -------------------------------- ### Run Test Suite Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/CONTRIBUTING.md Executes all tests in the project's test suite. ```bash pnpm test ``` -------------------------------- ### client.endpoints.getPaymentMethods Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/reference.md Returns all available payment methods in a specific branch. ```APIDOC ## getPaymentMethods ### Description Returns all available payment methods in a specific branch. ### Method POST ### Endpoint /endpoints/getPaymentMethods ### Parameters #### Request Body - **request** (WrestaurantApi.GetPaymentMethodsRequest) - Required - Details of the request. - **requestOptions** (EndpointsClient.RequestOptions) - Required - Options for the request. ### Request Example ```json { "request": { "licenseKey": "licenseKey" }, "requestOptions": {} } ``` ### Response #### Success Response (200) - **paymentMethods** (WrestaurantApi.PaymentMethodsResponse) - Description of the response structure. ``` -------------------------------- ### Check Code Style Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/CONTRIBUTING.md Verifies that the code adheres to the project's linting and formatting rules. ```bash pnpm run lint ``` ```bash pnpm run format:check ``` -------------------------------- ### client.endpoints.getTempOrderDetails Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/reference.md Retrieves temporary product lines for a branch, with optional pagination and filtering by order folio or product search. ```APIDOC ## getTempOrderDetails ### Description Retrieves temporary product lines for a branch, with optional pagination and filtering by order folio or product search. ### Method POST ### Endpoint /endpoints/getTempOrderDetails ### Parameters #### Request Body - **request** (WrestaurantApi.GetTempOrderDetailsRequest) - Required - Details of the request. - **requestOptions** (EndpointsClient.RequestOptions) - Required - Options for the request. ### Request Example ```json { "request": { "licenseKey": "licenseKey" }, "requestOptions": {} } ``` ### Response #### Success Response (200) - **orderDetails** (WrestaurantApi.OrderDetailsQueryResponse) - Description of the response structure. ``` -------------------------------- ### Import Request and Response Types Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Import and utilize TypeScript interfaces for request and response types from the WrestaurantApi namespace. ```typescript import { WrestaurantApi } from "@wrestaurant/sdk"; const request: WrestaurantApi.GetProductsRequest = { ... }; ``` -------------------------------- ### Configure API Environment Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Set a specific environment for API requests using WrestaurantApiEnvironment. ```typescript import { WrestaurantApiClient, WrestaurantApiEnvironment } from "@wrestaurant/sdk"; const client = new WrestaurantApiClient({ environment: WrestaurantApiEnvironment.Default, }); ``` -------------------------------- ### Custom Winston Logger Implementation Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Integrate the 'winston' logging library by creating an `ILogger` object that maps winston's methods to the SDK's logging interface. ```typescript import winston from 'winston'; const winstonLogger = winston.createLogger({...}); const logger: logging.ILogger = { debug: (msg, ...args) => winstonLogger.debug(msg, ...args), info: (msg, ...args) => winstonLogger.info(msg, ...args), warn: (msg, ...args) => winstonLogger.warn(msg, ...args), error: (msg, ...args) => winstonLogger.error(msg, ...args), }; ``` -------------------------------- ### Import Subpackage Client Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Import specific subpackage clients like EndpointsClient for improved tree-shaking and smaller bundle sizes. ```typescript import { EndpointsClient } from '@wrestaurant/sdk/endpoints'; const client = new EndpointsClient({...}); ``` -------------------------------- ### Combined Code Style Check and Fix Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/CONTRIBUTING.md Performs both linting and formatting checks and applies fixes if necessary. ```bash pnpm run check:fix ``` -------------------------------- ### Run Specific Test Types Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/CONTRIBUTING.md Executes specific categories of tests, such as unit or integration tests. ```bash pnpm test:unit ``` ```bash pnpm test:wire ``` -------------------------------- ### Make Custom Fetch Request Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Utilize the SDK's `fetch` method for custom HTTP requests to endpoints not directly supported. This method inherits SDK configurations like authentication and retries. ```typescript const response = await client.fetch("/v1/custom/endpoint", { method: "GET", }, { timeoutInSeconds: 30, maxRetries: 3, headers: { "X-Custom-Header": "custom-value", }, }); const data = await response.json(); ``` -------------------------------- ### client.endpoints.getOpenOrders Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/reference.md Retrieves all active (non-canceled) accounts for the current operational shift (6:00 AM – 5:59:59 AM the next day). ```APIDOC ## getOpenOrders ### Description Retrieves all active (non-canceled) accounts for the current operational shift (6:00 AM – 5:59:59 AM the next day). ### Method POST ### Endpoint /endpoints/getOpenOrders ### Parameters #### Request Body - **request** (WrestaurantApi.GetOpenOrdersRequest) - Required - Details of the request. - **requestOptions** (EndpointsClient.RequestOptions) - Required - Options for the request. ### Request Example ```json { "request": { "licenseKey": "licenseKey" }, "requestOptions": {} } ``` ### Response #### Success Response (200) - **openOrders** (WrestaurantApi.OpenOrdersResponse) - Description of the response structure. ``` -------------------------------- ### Handle API Exceptions Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Catch and handle WrestaurantApiError instances thrown for non-success status codes, accessing details like status code, message, and raw response. ```typescript import { WrestaurantApiError } from "@wrestaurant/sdk"; try { await client.endpoints.createTempOrders(...); } catch (err) { if (err instanceof WrestaurantApiError) { console.log(err.statusCode); console.log(err.message); console.log(err.body); console.log(err.rawResponse); } } ``` -------------------------------- ### Fix Code Style Issues Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/CONTRIBUTING.md Automatically corrects code style violations to meet project standards. ```bash pnpm run lint:fix ``` ```bash pnpm run format:fix ``` -------------------------------- ### Add Custom Request Headers Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Include custom headers in API requests by providing them during client instantiation or per-request. ```typescript import { WrestaurantApiClient } from "@wrestaurant/sdk"; const client = new WrestaurantApiClient({ ... headers: { 'X-Custom-Header': 'custom value' } }); const response = await client.endpoints.createTempOrders(..., { headers: { 'X-Custom-Header': 'custom value' } }); ``` -------------------------------- ### Add Custom Query String Parameters Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Append custom query string parameters to API requests using the queryParams option. ```typescript const response = await client.endpoints.createTempOrders(..., { queryParams: { 'customQueryParamKey': 'custom query param value' } }); ``` -------------------------------- ### Access Raw Response Data Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Retrieve the raw HTTP response, including headers, using the `.withRawResponse()` method. Access the response data via the `data` property and headers via `rawResponse.headers`. ```typescript const { data, rawResponse } = await client.endpoints.createTempOrders(...).withRawResponse(); console.log(data); console.log(rawResponse.headers['X-My-Header']); ``` -------------------------------- ### Abort a Request Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Cancel an ongoing request using an `AbortController`. Call `controller.abort()` to trigger the cancellation. ```typescript const controller = new AbortController(); const response = await client.endpoints.createTempOrders(..., { abortSignal: controller.signal }); controller.abort(); // aborts the request ``` -------------------------------- ### Override Max Retries for a Request Source: https://github.com/inowu/wrestaurant-sdk-typescript/blob/main/README.md Configure the maximum number of retry attempts for a specific request by setting the `maxRetries` option. Set to 0 to disable retries for this request. ```typescript const response = await client.endpoints.createTempOrders(..., { maxRetries: 0 // override maxRetries at the request level }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.