REST API යොමුව
මූලික වින්යාසය
මූලික URL: {site_url}/wp-json/wu/v2/
සත්යාපනය: API Key සහ Secret (HTTP Basic Auth හෝ URL පරාමිති)
සත්යාපනය
API සක්රීය කරන්න
// Enable API in Ultimate Multisite settings or programmatically
wu_save_setting('enable_api', true);
API අක්තපත්ර ලබා ගන්න
$api_key = wu_get_setting('api_key');
$api_secret = wu_get_setting('api_secret');
සත්යාපන ක්රම
HTTP Basic Auth (නිර්දේශිත):
curl -u "api_key:api_secret" https://yoursite.com/wp-json/wu/v2/customers
URL පරාමිති:
curl "https://yoursite.com/wp-json/wu/v2/customers?api_key=your_key&api_secret=your_secret"
ප්රධාන අන්ත ලක්ෂ්ය
1. පාරිභෝගික API
මූලික මාර්ගය: /customers
සියලු පාරිභෝගිකයන් ලබා ගන්න
GET /wu/v2/customers
තනි පාරිභෝගිකයෙකු ලබා ගන්න
GET /wu/v2/customers/{id}
පාරිභෝගිකයෙකු සාදන්න
POST /wu/v2/customers
Content-Type: application/json
{
"user_id": 123,
"email_verification": "verified",
"type": "customer",
"has_trialed": false,
"vip": false
}
පාරිභෝගිකයෙකු යාවත්කාලීන කරන්න
PUT /wu/v2/customers/{id}
Content-Type: application/json
{
"vip": true,
"extra_information": "VIP customer notes"
}
පාරිභෝගිකයෙකු මකන්න
DELETE /wu/v2/customers/{id}
2. අඩවි API
මූලික මාර්ගය: /sites
අඩවියක් සාදන්න
POST /wu/v2/sites
Content-Type: application/json
{
"customer_id": 5,
"membership_id": 10,
"domain": "example.com",
"path": "/",
"title": "My New Site",
"template_id": 1,
"type": "customer_owned"
}
3. සාමාජිකත්ව API
මූලික මාර්ගය: /memberships
සාමාජිකත්වයක් සාදන්න
POST /wu/v2/memberships
Content-Type: application/json
{
"customer_id": 5,
"plan_id": 3,
"status": "active",
"gateway": "stripe",
"gateway_subscription_id": "sub_1234567890",
"auto_renew": true
}
4. නිෂ්පාදන API
මූලික මාර්ගය: /products
සියලු නිෂ්පාදන ලබා ගන්න
GET /wu/v2/products
5. ගෙවීම් API
මූලික මාර්ගය: /payments
ගෙවීමක් සාදන්න
POST /wu/v2/payments
Content-Type: application/json
{
"customer_id": 5,
"membership_id": 10,
"status": "completed",
"gateway": "stripe",
"gateway_payment_id": "pi_1234567890",
"total": 29.99,
"currency": "USD"
}
6. වසම් API
මූලික මාර්ගය: /domains
වසමක් සිතියම්ගත කරන්න
POST /wu/v2/domains
Content-Type: application/json
{
"domain": "custom-domain.com",
"customer_id": 5,
"primary_domain": 1,
"stage": "domain-mapping"
}
ලියාපදිංචි අන්ත ලක්ෂ්යය
/register අන්ත ලක්ෂ්යය සම්පූර්ණ checkout/ලියාපදිංචි ප්රවාහයක් සපයයි:
POST /wu/v2/register
Content-Type: application/json
{
"customer": {
"username": "newuser",
"password": "securepass123",
"email": "[email protected]"
},
"products": ["basic-plan"],
"duration": 1,
"duration_unit": "month",
"auto_renew": true,
"site": {
"site_url": "mynewsite",
"site_title": "My New Site",
"template_id": 1
},
"payment": {
"status": "completed"
},
"membership": {
"status": "active"
}
}
ප්රතිචාරය:
{
"customer": { ... },
"membership": { ... },
"payment": { ... },
"site": { "id": 123 }
}