You've already forked wc-licensed-product-client
Add update-check endpoint support (v0.2.1)
Implement /update-check endpoint aligned with remote OpenAPI spec: - Add checkForUpdates() method to LicenseClientInterface - Add UpdateInfo DTO for update check responses - Add ProductNotFoundException for product_not_found error - Update local openapi.json to v0.4.0 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
272
tmp/openapi.json
272
tmp/openapi.json
@@ -3,7 +3,7 @@
|
||||
"info": {
|
||||
"title": "WooCommerce Licensed Product API",
|
||||
"description": "REST API for validating and managing software licenses bound to domains. This API allows external applications to validate license keys, check license status, and activate licenses on specific domains.\n\n## Response Signing (Optional)\n\nWhen the server is configured with `WC_LICENSE_SERVER_SECRET`, all API responses include cryptographic signatures for tamper protection:\n\n- `X-License-Signature`: HMAC-SHA256 signature of the response\n- `X-License-Timestamp`: Unix timestamp when the response was generated\n\nSignature verification prevents man-in-the-middle attacks and ensures response integrity. Use the `magdev/wc-licensed-product-client` library's `SecureLicenseClient` class to automatically verify signatures.",
|
||||
"version": "0.3.2",
|
||||
"version": "0.4.0",
|
||||
"contact": {
|
||||
"name": "Marco Graetsch",
|
||||
"url": "https://src.bundespruefstelle.ch/magdev",
|
||||
@@ -332,6 +332,148 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/update-check": {
|
||||
"post": {
|
||||
"operationId": "checkForUpdates",
|
||||
"summary": "Check for plugin updates",
|
||||
"description": "Checks if a newer version of the licensed product is available. Returns WordPress-compatible update information that can be used to integrate with WordPress's native plugin update system.",
|
||||
"tags": ["Plugin Updates"],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UpdateCheckRequest"
|
||||
},
|
||||
"example": {
|
||||
"license_key": "ABCD-1234-EFGH-5678",
|
||||
"domain": "example.com",
|
||||
"plugin_slug": "my-licensed-plugin",
|
||||
"current_version": "1.0.0"
|
||||
}
|
||||
},
|
||||
"application/x-www-form-urlencoded": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UpdateCheckRequest"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Update check completed successfully",
|
||||
"headers": {
|
||||
"X-License-Signature": {
|
||||
"$ref": "#/components/headers/X-License-Signature"
|
||||
},
|
||||
"X-License-Timestamp": {
|
||||
"$ref": "#/components/headers/X-License-Timestamp"
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UpdateCheckResponse"
|
||||
},
|
||||
"examples": {
|
||||
"update_available": {
|
||||
"summary": "Update is available",
|
||||
"value": {
|
||||
"success": true,
|
||||
"update_available": true,
|
||||
"version": "1.2.0",
|
||||
"slug": "my-licensed-plugin",
|
||||
"plugin": "my-licensed-plugin/my-licensed-plugin.php",
|
||||
"download_url": "https://example.com/license-download/123-456-abc123",
|
||||
"package": "https://example.com/license-download/123-456-abc123",
|
||||
"last_updated": "2026-01-27",
|
||||
"tested": "6.7",
|
||||
"requires": "6.0",
|
||||
"requires_php": "8.3",
|
||||
"changelog": "## 1.2.0\n- New feature added\n- Bug fixes",
|
||||
"package_hash": "sha256:abc123def456...",
|
||||
"name": "My Licensed Plugin",
|
||||
"homepage": "https://example.com/product/my-plugin"
|
||||
}
|
||||
},
|
||||
"no_update": {
|
||||
"summary": "No update available",
|
||||
"value": {
|
||||
"success": true,
|
||||
"update_available": false,
|
||||
"version": "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "License validation failed",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
},
|
||||
"examples": {
|
||||
"license_invalid": {
|
||||
"summary": "License is not valid",
|
||||
"value": {
|
||||
"success": false,
|
||||
"update_available": false,
|
||||
"error": "license_invalid",
|
||||
"message": "License validation failed."
|
||||
}
|
||||
},
|
||||
"domain_mismatch": {
|
||||
"summary": "Domain mismatch",
|
||||
"value": {
|
||||
"success": false,
|
||||
"update_available": false,
|
||||
"error": "domain_mismatch",
|
||||
"message": "This license is not valid for this domain."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "License or product not found",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
},
|
||||
"examples": {
|
||||
"license_not_found": {
|
||||
"summary": "License not found",
|
||||
"value": {
|
||||
"success": false,
|
||||
"update_available": false,
|
||||
"error": "license_not_found",
|
||||
"message": "License not found."
|
||||
}
|
||||
},
|
||||
"product_not_found": {
|
||||
"summary": "Product not found",
|
||||
"value": {
|
||||
"success": false,
|
||||
"update_available": false,
|
||||
"error": "product_not_found",
|
||||
"message": "Licensed product not found."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"429": {
|
||||
"$ref": "#/components/responses/RateLimitExceeded"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
@@ -473,6 +615,130 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"UpdateCheckRequest": {
|
||||
"type": "object",
|
||||
"required": ["license_key", "domain"],
|
||||
"properties": {
|
||||
"license_key": {
|
||||
"type": "string",
|
||||
"description": "The license key to validate (format: XXXX-XXXX-XXXX-XXXX)",
|
||||
"maxLength": 64,
|
||||
"example": "ABCD-1234-EFGH-5678"
|
||||
},
|
||||
"domain": {
|
||||
"type": "string",
|
||||
"description": "The domain the plugin is installed on",
|
||||
"maxLength": 255,
|
||||
"example": "example.com"
|
||||
},
|
||||
"plugin_slug": {
|
||||
"type": "string",
|
||||
"description": "The plugin slug (optional, for identification)",
|
||||
"example": "my-licensed-plugin"
|
||||
},
|
||||
"current_version": {
|
||||
"type": "string",
|
||||
"description": "Currently installed version for comparison",
|
||||
"example": "1.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"UpdateCheckResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the request was successful"
|
||||
},
|
||||
"update_available": {
|
||||
"type": "boolean",
|
||||
"description": "Whether an update is available"
|
||||
},
|
||||
"version": {
|
||||
"type": "string",
|
||||
"description": "Latest available version"
|
||||
},
|
||||
"slug": {
|
||||
"type": "string",
|
||||
"description": "Plugin slug for WordPress"
|
||||
},
|
||||
"plugin": {
|
||||
"type": "string",
|
||||
"description": "Plugin basename (slug/slug.php)"
|
||||
},
|
||||
"download_url": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"description": "Secure download URL for the update package"
|
||||
},
|
||||
"package": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"description": "Alias for download_url (WordPress compatibility)"
|
||||
},
|
||||
"last_updated": {
|
||||
"type": "string",
|
||||
"format": "date",
|
||||
"description": "Date of the latest release"
|
||||
},
|
||||
"tested": {
|
||||
"type": "string",
|
||||
"description": "Highest WordPress version tested with"
|
||||
},
|
||||
"requires": {
|
||||
"type": "string",
|
||||
"description": "Minimum required WordPress version"
|
||||
},
|
||||
"requires_php": {
|
||||
"type": "string",
|
||||
"description": "Minimum required PHP version"
|
||||
},
|
||||
"changelog": {
|
||||
"type": "string",
|
||||
"description": "Release notes/changelog for the update"
|
||||
},
|
||||
"package_hash": {
|
||||
"type": "string",
|
||||
"description": "SHA256 hash of the package for integrity verification",
|
||||
"example": "sha256:abc123..."
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "Product name"
|
||||
},
|
||||
"homepage": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"description": "Product homepage URL"
|
||||
},
|
||||
"icons": {
|
||||
"type": "object",
|
||||
"description": "Plugin icons for WordPress admin",
|
||||
"properties": {
|
||||
"1x": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"2x": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sections": {
|
||||
"type": "object",
|
||||
"description": "Content sections for plugin info modal",
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"changelog": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -577,6 +843,10 @@
|
||||
{
|
||||
"name": "License Activation",
|
||||
"description": "Activate licenses on domains"
|
||||
},
|
||||
{
|
||||
"name": "Plugin Updates",
|
||||
"description": "Check for plugin updates"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user