Product Availability
This guide explains how to interact with the Product Availability API in the Sumaya369 web application. The API provides functionality for customers to register their interest in products that are currently out of stock or not purchasable, enabling them to receive notifications when the product becomes available.
Register Product Availability Interest
Register a customer's interest in a product that is currently unavailable (out of stock or not purchasable). This endpoint creates a notification request and sends a Slack notification to the team.
Endpoint
- Method: POST
- URL:
/v1/customer/product-availability
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Accept | application/json | Yes |
Request Body
| Parameter | Type | Description | Required |
|---|---|---|---|
| string | Customer's email address | Yes | |
| phone | string | Customer's phone number (defaults to '00000000001' if not provided) | No |
| productable_type | string | Type of product ('bundles' or 'courses') | Yes |
| productable_id | string | UUID or special_id of the product | Yes |
Success Response
{
"success": true,
"message": "تم حفظ البيانات بنجاح.",
"data": {
"id": "9f68e2b0-f346-11ef-b5da-33786b717bac",
"email": "samareidxoxo@gmail.com",
"phone": "730000444",
"productable_id": "d32c6190-b67a-11ec-955e-b940e5a4bde1",
"productable_type": "App\\Models\\Course",
"remember_me": null,
"is_remembered": false
},
"status_code": 200
}
Error Responses
Product Not Found (404)
{
"success": false,
"message": "لم يتم العثور على السجل",
"errors": "لم يتم العثور على السجل",
"data": null,
"status_code": 404
}
Invalid Product Type (422)
{
"success": false,
"message": "productable type غير موجود.",
"errors": null,
"data": null,
"status_code": 422
}
Implementation Flow
- Product Availability Request
- Check if product exists and is unavailable (quantity < = 0 or is_purchasable = false)
- Create or find existing availability request for the email and product
- Send Slack notification to team about the request
- Return success response with availability request details
Key Considerations
- The system supports both bundles and courses as product types
- Duplicate requests from the same email for the same product are handled (only one record is created)
- Product can be identified by either UUID or special_id
- Slack notifications are sent to keep the team informed of customer interest
- Phone number defaults to '00000000001' if not provided
- The expired_at field can be used to track when the notification was sent
- The is_remembered field can be used to track if the customer has been notified