### Install YOP TypeScript SDK Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README_zh-CN.md Instructions for installing the YOP TypeScript SDK using common package managers like npm, yarn, or pnpm. ```bash npm install @yeepay/yop-typescript-sdk # or yarn add @yeepay/yop-typescript-sdk # or pnpm add @yeepay/yop-typescript-sdk ``` -------------------------------- ### Install YOP TypeScript SDK (Bash) Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/llms.txt Provides commands to install the @yeepay/yop-typescript-sdk package into your project using common Node.js package managers like npm, yarn, or pnpm. This is the first step required to use the SDK in your application. ```Bash npm install @yeepay/yop-typescript-sdk # or yarn add @yeepay/yop-typescript-sdk ``` -------------------------------- ### Configure YopClient with Environment Variables Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README_zh-CN.md Demonstrates initializing the YopClient by relying on environment variables for configuration. It shows an example .env file and the TypeScript code to load and use these variables. ```dotenv YOP_APP_KEY=your_app_key YOP_SECRET_KEY='-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----' YOP_PUBLIC_KEY='-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----' # YOP_API_BASE_URL=https://sandbox.yeepay.com # Optional, for sandbox environment ``` ```typescript import { YopClient } from '@yeepay/yop-typescript-sdk'; import dotenv from 'dotenv'; // Load environment variables (e.g., from .env file) dotenv.config(); // Initialize YopClient using environment variables try { // No configuration object passed, SDK uses environment variables const yopClient = new YopClient(); console.log('YopClient initialized successfully using environment variables!'); // Use yopClient for API calls... } catch (error) { console.error('Failed to initialize YopClient from environment variables:', error); // Ensure all required environment variables (YOP_APP_KEY, YOP_SECRET_KEY, YOP_PUBLIC_KEY) are set. } ``` -------------------------------- ### Example .env File for Yop Configuration (dotenv) Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md Provides an example of a `.env` file structure for storing YeePay API credentials and configuration. This file is typically loaded by the `dotenv` package to make environment variables available to the application. ```dotenv YOP_APP_KEY=your_app_key YOP_SECRET_KEY='-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----' YOP_PUBLIC_KEY='-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----' # YOP_API_BASE_URL=https://sandbox.yeepay.com # Optional for sandbox environment ``` -------------------------------- ### Install Yop-TypeScript-SDK Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/llms.txt Command to add the Yop-TypeScript-SDK to your project using pnpm. ```shell pnpm add @yeepay/yop-typescript-sdk ``` -------------------------------- ### Install YOP TypeScript SDK Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md Installs the YOP TypeScript SDK package using npm, yarn, or pnpm. This command is executed in your terminal to add the SDK to your project dependencies. ```bash npm install @yeepay/yop-typescript-sdk # or yarn add @yeepay/yop-typescript-sdk # or pnpm add @yeepay/yop-typescript-sdk ``` -------------------------------- ### Create Pre-payment Order with YOP TypeScript SDK Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md Demonstrates how to create a pre-payment order using the YOP TypeScript SDK. This example shows the necessary data payload and how to handle the response, including success and error states. It requires the `yopClient` to be initialized and environment variables for merchant credentials. ```typescript import type { YopResponse } from "@yeepay/yop-typescript-sdk"; // Assume yopClient is configured and initialized as shown above async function createPayment() { const paymentData = { parentMerchantNo: process.env.YOP_PARENT_MERCHANT_NO!, // Your parent merchant number merchantNo: process.env.YOP_MERCHANT_NO!, // Your merchant number orderId: `SDK_TEST_${Date.now()}`, // Unique order ID orderAmount: "0.01", // Amount (string format) goodsName: "SDK Test Product", // Supports UTF-8 characters (e.g., Chinese) notifyUrl: process.env.YOP_NOTIFY_URL!, // URL for receiving payment notifications userIp: "127.0.0.1", // End user's IP address scene: "ONLINE", // Transaction scenario channel: "WECHAT", // Payment channel // ... include any other necessary fields required by the specific API endpoint }; try { console.log("Sending pre-payment request:", paymentData); // Use post() to send default 'application/x-www-form-urlencoded' request const response = await yopClient.post( "/rest/v1.0/aggpay/pre-pay", paymentData ); console.log("Received pre-payment response:", response); if (response.state === "SUCCESS" && response.result?.code === "00000") { console.log("Pre-payment successful:", response.result); // Handle successful response: extract prePayTn, orderId, etc. // const prePayTn = response.result.prePayTn; } else { // Handle API errors or unsuccessful states const errorInfo = response.state === "FAILURE" ? response.error : response.result; console.error("Pre-payment failed:", errorInfo); } } catch (error) { // Handle network errors or issues during request/response console.error("Error executing pre-payment request:", error); } } createPayment(); ``` -------------------------------- ### Clone yop-typescript-sdk Repository Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md Fork the yop-platform/yop-typescript-sdk repository and clone your fork to your local machine to start contributing. This command downloads the project files. ```git git clone https://github.com/yop-platform/yop-typescript-sdk.git ``` -------------------------------- ### YOP TypeScript SDK API Reference Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md This section details the core methods available on the YOP client instance for interacting with YOP APIs. It covers client initialization, sending GET and POST requests, including parameter descriptions, types, and return values. ```APIDOC YopClient: __constructor(config?: YopConfig) Description: Creates and initializes a new YOP client instance. Parameters: - config (optional): A YopConfig object containing your credentials and settings. If omitted, the SDK will attempt to load configuration from environment variables. See [Configuration](#configuration) and src/types.ts. get(apiUrl: string, params: Record, timeout?: number): Promise Description: Sends an HTTP GET request to the specified YOP API endpoint. Parameters: - apiUrl: The API path relative to the yopApiBaseUrl (e.g., /rest/v1.0/trade/order/query). - params: An object containing the request query parameters. - timeout (optional): Request timeout in milliseconds. Returns: A Promise that resolves with the parsed API response of type T. post(apiUrl: string, body: Record, contentType?: ContentType, timeout?: number): Promise Description: Sends an HTTP POST request to the specified YOP API endpoint. Defaults to application/x-www-form-urlencoded content type. Parameters: - apiUrl: The API path relative to the yopApiBaseUrl. - body: An object containing the data to be sent in the request body. - contentType (optional): The content type of the request. Defaults to ContentType.FORM_URLENCODED. For JSON payloads, use ContentType.JSON (or use postJson). - timeout (optional): Request timeout in milliseconds. Returns: A Promise that resolves with the parsed API response of type T. ``` -------------------------------- ### Send GET Request with YOP Client (TypeScript) Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/llms.txt Sends an HTTP GET request to a specified YOP API endpoint. The `apiUrl` is relative to the base URL, `params` are the query parameters, and `timeout` is optional. It returns a Promise that resolves with the parsed API response of type T. ```TypeScript yopClient.get(apiUrl: string, params: Record, timeout?: number): Promise ``` -------------------------------- ### Query Payment Order with YOP TypeScript SDK Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md Provides an example of how to query the status of a payment order using the YOP TypeScript SDK. It details the request parameters, including the order ID, and demonstrates how to process the response. This function requires an initialized `yopClient` and valid merchant credentials. ```typescript import type { YopResponse } from "@yeepay/yop-typescript-sdk"; // Assume yopClient is configured and initialized async function queryPayment(orderId: string) { const queryData = { parentMerchantNo: process.env.YOP_PARENT_MERCHANT_NO!, merchantNo: process.env.YOP_MERCHANT_NO!, orderId: orderId, // The order ID you want to query // queryType: 'PAYMENT', // Example: specify query type if needed }; try { console.log("Sending order query request:", orderId); // Use get() to send GET request const response = await yopClient.get( "/rest/v1.0/trade/order/query", queryData ); console.log("Received query response:", response); if (response.state === "SUCCESS" && response.result?.code === "00000") { console.log("Query successful:", response.result); // Handle order details: response.result.status, response.result.orderAmount, etc. } else { const errorInfo = response.state === "FAILURE" ? response.error : response.result; console.error("Query failed:", errorInfo); } } catch (error) { console.error("Error executing query request:", error); } } // Example call: replace with actual order ID // queryPayment('SDK_TEST_1678886400000'); ``` -------------------------------- ### Query Payment Order Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README_zh-CN.md Illustrates how to query the status of a payment order using the YopClient's get method. It details the required parameters for the query, the API endpoint, and how to process the response, including error handling. ```TypeScript import type { YopResponse } from "@yeepay/yop-typescript-sdk"; // 假设 yopClient 已配置和初始化 async function queryPayment(orderId: string) { const queryData = { parentMerchantNo: process.env.YOP_PARENT_MERCHANT_NO!, merchantNo: process.env.YOP_MERCHANT_NO!, orderId: orderId, // 您要查询的订单 ID // queryType: 'PAYMENT', // 示例:如果需要,指定查询类型 }; try { console.log("发送订单查询请求:", orderId); // 使用 get() 发送 GET 请求 const response = await yopClient.get( "/rest/v1.0/trade/order/query", queryData ); console.log("收到查询响应:", response); if (response.state === "SUCCESS" && response.result?.code === "00000") { console.log("查询成功:", response.result); // 处理订单详情:response.result.status、response.result.orderAmount 等 } else { const errorInfo = response.state === "FAILURE" ? response.error : response.result; console.error("查询失败:", errorInfo); } } catch (error) { console.error("执行查询请求时出错:", error); } } // 示例调用:替换为实际的订单 ID // queryPayment('SDK_TEST_1678886400000'); ``` -------------------------------- ### Query YeePay Payment Order with YopClient.get Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/llms.txt Provides an asynchronous function to query the status and details of an existing payment order using the SDK's get method. It includes constructing the query data, making the API call, and processing the response. ```TypeScript import type { YopResponse } from "@yeepay/yop-typescript-sdk"; // Assuming yopClient is already configured and initialized async function queryPayment(orderId: string) { const queryData = { parentMerchantNo: process.env.YOP_PARENT_MERCHANT_NO!, merchantNo: process.env.YOP_MERCHANT_NO!, orderId: orderId, // queryType: 'PAYMENT', // Example: Specify query type if needed }; try { console.log("Sending query request for order:", orderId); // Use get() for GET requests const response = await yopClient.get( "/rest/v1.0/trade/order/query", queryData ); console.log("Received query response:", response); if (response.state === "SUCCESS" && response.result?.code === "00000") { console.log("Query successful:", response.result); // Process the order details: response.result.status, response.result.orderAmount etc. } else { const errorInfo = response.state === "FAILURE" ? response.error : response.result; ``` -------------------------------- ### Initialize YopClient with Environment Variables Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/llms.txt Demonstrates initializing the YopClient instance by automatically reading configuration from environment variables like YOP_APP_KEY, YOP_APP_PRIVATE_KEY, and YOP_PUBLIC_KEY. It includes importing the SDK and dotenv for loading variables. ```TypeScript import { YopClient } from '@yeepay/yop-typescript-sdk'; import dotenv from 'dotenv'; // Load environment variables (e.g., from a .env file) dotenv.config(); // Initialize YopClient using environment variables try { // No config object passed, SDK uses environment variables const yopClient = new YopClient(); console.log('YopClient initialized successfully using environment variables!'); // Use yopClient for API calls... } catch (error) { console.error('Failed to initialize YopClient from environment variables:', error); // Ensure all required environment variables (YOP_APP_KEY, YOP_APP_PRIVATE_KEY, YOP_PUBLIC_KEY) are set. } ``` -------------------------------- ### Running Tests and Linting Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README_zh-CN.md Provides essential bash commands for managing the Yop TypeScript SDK project, including running unit and integration tests, generating code coverage reports, performing code linting, and building the project. ```Bash # 运行所有测试 npm test # 运行带覆盖率的测试 npm test -- --coverage # 运行代码检查 npm run lint # 构建项目 npm run build ``` -------------------------------- ### Initialize YopClient with Environment Variables (TypeScript) Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md Demonstrates initializing the `YopClient` by automatically loading configuration from environment variables like `YOP_APP_KEY`, `YOP_SECRET_KEY`, and `YOP_PUBLIC_KEY`. This method is recommended for simplicity and requires the `dotenv` package for loading `.env` files. ```typescript import { YopClient } from '@yeepay/yop-typescript-sdk'; import dotenv from 'dotenv'; // Load environment variables (e.g., from a .env file) dotenv.config(); // Initialize YopClient using environment variables try { // No configuration object passed, SDK uses environment variables const yopClient = new YopClient(); console.log('YopClient initialized successfully using environment variables!'); // Use yopClient for API calls... } catch (error) { console.error('Failed to initialize YopClient from environment variables:', error); // Make sure all required environment variables (YOP_APP_KEY, YOP_SECRET_KEY, YOP_PUBLIC_KEY) are set. } ``` -------------------------------- ### Initialize YopClient with Explicit Config (TypeScript) Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/llms.txt Shows how to initialize the YopClient by providing an explicit configuration object to its constructor. This method takes precedence over environment variables and allows for sourcing configuration from various places. ```TypeScript import { YopClient } from '@yeepay/yop-typescript-sdk'; import type { YopConfig } from '@yeepay/yop-typescript-sdk'; import dotenv from 'dotenv'; // Still useful for loading parts of the config dotenv.config(); // Load any potential fallbacks or other env vars // Prepare the configuration object explicitly const yopConfig: YopConfig = { appKey: process.env.MY_CUSTOM_APP_KEY || 'defaultAppKey', // Example: Using different env var or default secretKey: process.env.MY_SECRET_KEY!, yopPublicKey: process.env.YOP_PUBLIC_KEY!, // yeepayApiBaseUrl: 'https://sandbox.yeepay.com' // Example: Overriding the base URL }; // Create a YopClient instance with the explicit config const yopClient = new YopClient(yopConfig); console.log('YopClient initialized successfully with explicit config!'); ``` -------------------------------- ### Create Pre-pay Order Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README_zh-CN.md Demonstrates how to create a pre-pay order using the YopClient's post method. It includes sample data for parent merchant, merchant, order details, and specifies the API endpoint and response handling for success and failure scenarios. ```TypeScript import type { YopResponse } from "@yeepay/yop-typescript-sdk"; // 假设 yopClient 已按上述方式配置和初始化 async function createPayment() { const paymentData = { parentMerchantNo: process.env.YOP_PARENT_MERCHANT_NO!, // 您的父商户编号 merchantNo: process.env.YOP_MERCHANT_NO!, // 您的商户编号 orderId: `SDK_TEST_${Date.now()}`, // 唯一的订单 ID orderAmount: "0.01", // 金额(字符串格式) goodsName: "SDK Test Product", // 支持 UTF-8 字符(如中文) notifyUrl: process.env.YOP_NOTIFY_URL!, // 用于接收支付通知的 URL userIp: "127.0.0.1", // 终端用户的 IP 地址 scene: "ONLINE", // 交易场景 channel: "WECHAT", // 支付渠道 // ... 包含特定 API 端点所需的任何其他必要字段 }; try { console.log("发送预支付请求:", paymentData); // 使用 post() 发送默认的 'application/x-www-form-urlencoded' 请求 const response = await yopClient.post( "/rest/v1.0/aggpay/pre-pay", paymentData ); console.log("收到预支付响应:", response); if (response.state === "SUCCESS" && response.result?.code === "00000") { console.log("预支付成功:", response.result); // 处理成功响应:提取 prePayTn、orderId 等 // const prePayTn = response.result.prePayTn; } else { // 处理 API 错误或不成功的状态 const errorInfo = response.state === "FAILURE" ? response.error : response.result; console.error("预支付失败:", errorInfo); } } catch (error) { // 处理请求/响应过程中的网络错误或问题 console.error("执行预支付请求时出错:", error); } } createPayment(); ``` -------------------------------- ### YopClient Configuration Options Reference (APIDOC) Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md Details the available configuration options (`appKey`, `secretKey`, `yopPublicKey`, `yopApiBaseUrl`) when initializing the `YopClient` with an explicit configuration object. If an option is omitted, the SDK attempts to fall back to corresponding environment variables. ```APIDOC YopClient Constructor Options: When you pass a configuration object to the `YopClient` constructor, these options will be used. If an option is omitted from the object, the SDK will attempt to fall back to the corresponding environment variable. - appKey (string, required): Your unique application identifier provided by YeePay. (Falls back to `process.env.YOP_APP_KEY`). - secretKey (string, required): Your application's private key (in PEM format, as a raw string). The SDK will automatically format the key if it's not already in PEM format. **Keep this secure!** (Falls back to `process.env.YOP_SECRET_KEY`). - yopPublicKey (string, required): The YeePay platform's public key (in PEM format, as a raw string) used to verify responses. This must be the key *content*, not a file path. (Falls back to `process.env.YOP_PUBLIC_KEY`). - yopApiBaseUrl (string, optional): The base URL for the YeePay API. (Falls back to `process.env.YOP_API_BASE_URL`, then defaults to `https://openapi.yeepay.com`). ``` -------------------------------- ### Yop SDK CLI Commands Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md Common command-line interface commands for managing and testing the Yop SDK. These include running tests, generating coverage reports, performing linting, and building the project. ```bash # Run all tests npm test # Run tests with coverage npm test -- --coverage # Run linting npm run lint # Build the project npm run build ``` -------------------------------- ### Initialize YopClient with Explicit Config Object (TypeScript) Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md Shows how to initialize the `YopClient` by passing a `YopConfig` object directly to the constructor. This method allows for explicit control over configuration and takes precedence over environment variables if both are present. ```typescript import { YopClient } from '@yeepay/yop-typescript-sdk'; import type { YopConfig } from '@yeepay/yop-typescript-sdk'; import dotenv from 'dotenv'; // Still useful for loading partial configuration dotenv.config(); // Load any potential fallbacks or other env vars // Explicitly prepare the configuration object const yopConfig: YopConfig = { appKey: process.env.MY_CUSTOM_APP_KEY || 'defaultAppKey', // Example: Using different env var or default secretKey: process.env.MY_SECRET_KEY!, yopPublicKey: process.env.YOP_PUBLIC_KEY!, // yopApiBaseUrl: 'https://sandbox.yeepay.com' // Example: Override base URL }; // Create YopClient instance using explicit configuration const yopClient = new YopClient(yopConfig); console.log('YopClient initialized successfully using explicit configuration!'); ``` -------------------------------- ### Create YeePay Pre-payment Order with YopClient.post Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/llms.txt Provides an asynchronous function to create a payment order using the SDK's post method, which defaults to 'application/x-www-form-urlencoded'. It includes constructing the payment data, making the API call, and handling the response. ```TypeScript import type { YopResponse } from "@yeepay/yop-typescript-sdk"; // Assuming yopClient is already configured and initialized as shown above async function createPayment() { const paymentData = { parentMerchantNo: process.env.YOP_PARENT_MERCHANT_NO!, // Your parent merchant number merchantNo: process.env.YOP_MERCHANT_NO!, // Your merchant number orderId: `SDK_TEST_${Date.now()}`, // Unique order ID orderAmount: "0.01", // Amount as string goodsName: "SDK Test Product", // Supports UTF-8 characters (e.g., Chinese) notifyUrl: process.env.YOP_NOTIFY_URL!, // URL for receiving payment notifications userIp: "127.0.0.1", // End-user's IP address scene: "ONLINE", // Transaction scene channel: "WECHAT", // Payment channel // ... include any other necessary fields required by the specific API endpoint }; try { console.log("Sending pre-pay request:", paymentData); // Use post() for default 'application/x-www-form-urlencoded' requests const response = await yopClient.post( "/rest/v1.0/aggpay/pre-pay", paymentData ); console.log("Received pre-pay response:", response); if (response.state === "SUCCESS" && response.result?.code === "00000") { console.log("Pre-pay successful:", response.result); // Process successful response: extract prePayTn, orderId, etc. // const prePayTn = response.result.prePayTn; } else { // Handle API errors or unsuccessful states const errorInfo = response.state === "FAILURE" ? response.error : response.result; console.error("Pre-pay failed:", errorInfo); } } catch (error) { // Handle network errors or issues during the request/response process console.error("Error during pre-pay request execution:", error); } } createPayment(); ``` -------------------------------- ### Configure YopClient with Explicit YopConfig Object Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README_zh-CN.md Illustrates how to explicitly pass a configuration object to the YopClient constructor. This method takes precedence over environment variables if both are present. ```typescript import { YopClient } from '@yeepay/yop-typescript-sdk'; import type { YopConfig } from '@yeepay/yop-typescript-sdk'; import dotenv from 'dotenv'; // Can still be used for fallback or other variables dotenv.config(); // Load any potential fallback or other environment variables // Prepare the configuration object explicitly const yopConfig: YopConfig = { appKey: process.env.MY_CUSTOM_APP_KEY || 'defaultAppKey', // Example: Use a different env var or default secretKey: process.env.MY_SECRET_KEY!, // Example: Get from a specific variable yopPublicKey: process.env.YOP_PUBLIC_KEY!, // Still load from standard env var if needed // yeepayApiBaseUrl: 'https://sandbox.yeepay.com' // Example: Override base URL }; // Create YopClient instance with explicit configuration const yopClient = new YopClient(yopConfig); console.log('YopClient initialized successfully with explicit configuration!'); // Use yopClient for API calls... ``` -------------------------------- ### Push Changes to Fork Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md Upload your committed changes from your local branch to your forked repository on GitHub. ```git git push origin feature/your-feature-name ``` -------------------------------- ### Run Project Tests Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md Execute the project's test suite to ensure your changes do not introduce regressions. All tests must pass before submitting a pull request. ```bash npm test ``` -------------------------------- ### Lint Code Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md Ensure your code adheres to the project's style guidelines by running the linter. Fix any reported issues to maintain code quality and consistency. ```bash npm run lint ``` -------------------------------- ### Create Feature or Bugfix Branch Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md Before making changes, create a new branch for your work. Use a descriptive name like 'feature/your-feature-name' for new features or 'bugfix/issue-number' for bug fixes. ```bash git checkout -b feature/your-feature-name git checkout -b bugfix/issue-number ``` -------------------------------- ### Commit Changes Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md Stage and commit your changes with a clear and concise message. Following conventional commit messages is recommended for better commit history. ```git git commit -m "feat: Describe your feature" -m "Detailed description..." ``` -------------------------------- ### YopClient postJson Method Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/README.md A convenience method for sending an HTTP POST request with `application/json` content type. It takes an API URL, a request body, and an optional timeout, returning a Promise that resolves with the parsed API response. ```APIDOC yopClient.postJson(apiUrl: string, body: Record, timeout?: number): Promise - apiUrl: The API path relative to the `yopApiBaseUrl`. - body: An object containing the data to be sent as JSON in the request body. - timeout (optional): Request timeout in milliseconds. - Returns: A `Promise` that resolves with the parsed API response of type `T`. ``` -------------------------------- ### Send POST Request with YOP Client (TypeScript) Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/llms.txt Sends a general HTTP POST request to a specified YOP API endpoint. The `apiUrl` is relative to the base URL, and `body` contains the data. `contentType` is optional (defaults to form-urlencoded), and `timeout` is optional. It returns a Promise resolving with the parsed API response of type T. ```TypeScript yopClient.post(apiUrl: string, body: Record, contentType?: ContentType, timeout?: number): Promise ``` -------------------------------- ### Send JSON POST Request with YOP Client (TypeScript) Source: https://github.com/yop-platform/yop-typescript-sdk/blob/main/llms.txt A convenience method for sending an HTTP POST request specifically with the `application/json` content type. `apiUrl` is relative to the base URL, and `body` contains the data sent as JSON. `timeout` is optional. It returns a Promise resolving with the parsed API response of type T. ```TypeScript yopClient.postJson(apiUrl: string, body: Record, timeout?: number): Promise ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.