MeshyApi
in package
Handles interactions with the Meshy API.
Defines the plugin name, version, and methods to interact with the Meshy API for text-to-3D tasks.
Tags
Table of Contents
Properties
- $api_base_url : string
- The base URL for the Meshy API.
- $api_key : string
- The API key for authentication with Meshy API.
- $logger : object
- WooCommerce logger instance.
- $plugin_name : string
- The ID of this plugin.
- $plugin_prefix : string
- The unique prefix of this plugin.
- $version : string
- The version of this plugin.
Methods
- __construct() : mixed
- Initialize the class and set its properties.
- createTextTo3DTaskPreview() : array<string|int, mixed>|WP_Error
- Creates a Text to 3D Task.
- createTextTo3DTaskRefine() : mixed
- retrieveTextTo3DTask() : array<string|int, mixed>|WP_Error
- Retrieves a Text to 3D Task.
- make_request() : array<string|int, mixed>|WP_Error
- Makes an HTTP request to the Meshy API.
Properties
$api_base_url
The base URL for the Meshy API.
private
string
$api_base_url
The base URL used to make API requests to Meshy.
Tags
$api_key
The API key for authentication with Meshy API.
private
string
$api_key
The API key used for authenticating API requests.
Tags
$logger
WooCommerce logger instance.
private
object
$logger
An instance of the WooCommerce logger for logging events.
Tags
$plugin_name
The ID of this plugin.
private
string
$plugin_name
The unique identifier of the plugin.
Tags
$plugin_prefix
The unique prefix of this plugin.
private
string
$plugin_prefix
A string used to uniquely prefix technical functions of this plugin.
Tags
$version
The version of this plugin.
private
string
$version
The current version of the plugin.
Tags
Methods
__construct()
Initialize the class and set its properties.
public
__construct(string $plugin_name, string $plugin_prefix, string $version) : mixed
Parameters
- $plugin_name : string
-
The name of the plugin.
- $plugin_prefix : string
-
The unique prefix of the plugin.
- $version : string
-
The version of the plugin.
Tags
createTextTo3DTaskPreview()
Creates a Text to 3D Task.
public
createTextTo3DTaskPreview(string $prompt[, string $mode = 'preview' ][, string $art_style = 'realistic' ][, string $negative_prompt = '' ][, string $preview_task_id = '' ]) : array<string|int, mixed>|WP_Error
Makes a POST request to the /v2/text-to-3d
endpoint with the provided parameters.
Parameters
- $prompt : string
-
The description of the 3D object to generate.
- $mode : string = 'preview'
-
The mode of the request, 'preview' or 'refine'.
- $art_style : string = 'realistic'
-
The artistic style (optional, defaults to 'realistic').
- $negative_prompt : string = ''
-
Description of what the model should NOT look like (optional).
- $preview_task_id : string = ''
-
The ID of the preview task for refine mode (optional).
Tags
Return values
array<string|int, mixed>|WP_Error —The result of the request or an error in case of failure.
createTextTo3DTaskRefine()
public
createTextTo3DTaskRefine(mixed $preview_task_id[, mixed $mode = 'refine' ]) : mixed
Parameters
- $preview_task_id : mixed
- $mode : mixed = 'refine'
retrieveTextTo3DTask()
Retrieves a Text to 3D Task.
public
retrieveTextTo3DTask([string|null $task_id = null ]) : array<string|int, mixed>|WP_Error
Makes a GET request to the /v2/text-to-3d/:id
endpoint to retrieve details of a Text to 3D task.
If no task ID is provided, it returns a default response.
Parameters
- $task_id : string|null = null
-
The unique ID of the Text to 3D task to retrieve.
Tags
Return values
array<string|int, mixed>|WP_Error —The details of the Text to 3D task or a default response if no task_id is provided.
make_request()
Makes an HTTP request to the Meshy API.
private
make_request(string $method, string $url[, array<string|int, mixed> $body = [] ]) : array<string|int, mixed>|WP_Error
Parameters
- $method : string
-
The HTTP method ('GET' or 'POST').
- $url : string
-
The full URL for the request.
- $body : array<string|int, mixed> = []
-
The request body (for POST requests).
Tags
Return values
array<string|int, mixed>|WP_Error —The decoded JSON response or WP_Error on failure.