Skip to main content

Favorites

This guide explains how to interact with the Favorites API in the Sumaya369 web application. The API provides endpoints for managing customer favorites, including features for listing favorites, adding items to favorites, and removing items from favorites.

List Favorites

Retrieve all favorites for the authenticated customer.

Endpoint

  • Method: GET
  • URL: /v1/customer/favorites

Request Headers

HeaderValueRequired
Content-Typeapplication/jsonYes
Acceptapplication/jsonYes
AuthorizationBearer tokenYes

Query Parameters

ParameterTypeDescriptionRequired
per_pageintegerNumber of items per pageNo

Success Response

{
"success": true,
"message": "تم جلب البيانات بنجاح.",
"data": {
"current_page": 1,
"first_page_url": "http://testing-api.sumaya369.net/v1/customer/favorites?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http://testing-api.sumaya369.net/v1/customer/favorites?page=1",
"links": [
{
"url": null,
"label": "« السابق",
"active": false
},
{
"url": "http://testing-api.sumaya369.net/v1/customer/favorites?page=1",
"label": "1",
"active": true
},
{
"url": null,
"label": "التالي »",
"active": false
}
],
"next_page_url": null,
"path": "http://testing-api.sumaya369.net/v1/customer/favorites",
"per_page": 10,
"prev_page_url": null,
"to": 1,
"total": 1,
"favorites": [
{
"id": "5c5708a0-f315-11ef-8830-c908f76d0944",
"slug": "اسئلة-الجسد-المشاعري",
"model_type": "course",
"poster": "https://sumaya369-testing-media.s3.us-east-2.amazonaws.com/22667/6--%D8%A7%D8%B3%D8%A6%D9%84%D8%A9-%D8%A7%D9%84%D8%AC%D8%B3%D8%AF-%D8%A7%D9%84%D9%85%D8%B4%D8%A7%D8%B9%D8%B1%D9%8A.png",
"name": "اسئلة الجسد المشاعري",
"is_purchasable": null,
"hide_price": false,
"brief_description": "...",
"videos_count": 0,
"has_active_subscribed": true,
"old_price": 190.44,
"price": 190.44,
"favorite": {
"id": "5c5708a0-f315-11ef-8830-c908f76d0944",
"favoriteable_type": "App\\Models\\Course",
"favoriteable_id": "ce31e4d0-fe0b-11ed-8966-83608074a91f",
"customer_id": "9f2ecd22-5c07-48ec-9415-2979deec4493",
"created_at": "2025-02-25 01:10:54",
"updated_at": "2025-02-25 01:10:54"
},
"product_id": "ce31e4d0-fe0b-11ed-8966-83608074a91f",
"pay_button_title": "مشترك",
"pay_button_status": true,
"does_has_vat": true,
"price_with_vat_show": 219.01
}
]
},
"status_code": 200
}

Add to Favorites

Add an item to the authenticated customer's favorites.

Endpoint

  • Method: POST
  • URL: /v1/customer/favorites

Request Headers

HeaderValueRequired
Content-Typeapplication/jsonYes
Acceptapplication/jsonYes
AuthorizationBearer tokenYes

Request Body Parameters

ParameterTypeDescriptionRequired
favoriteable_typestringType of item (courses, publications, ebooks, bundles, articles)Yes
favoriteable_idintegerID of the item to favoriteYes

Success Response

{
"success": true,
"message": "تم حفظ البيانات بنجاح.",
"data": {
"id": "84fe1d60-f3f5-11ef-b152-11a2dd2100eb",
"favoriteable_id": "cf145b70-c795-11ef-b586-eb5871aabd0d",
"type": "bundle",
"customer_id": "9f2ecd22-5c07-48ec-9415-2979deec4493",
"is_favorite": true,
"created_at": "2025-02-26 06:55:29"
},
"status_code": 200
}

Remove from Favorites

Remove items from the authenticated customer's favorites.

Endpoint

  • Method: DELETE
  • URL: /v1/customer/favorites

Request Headers

HeaderValueRequired
Content-Typeapplication/jsonYes
Acceptapplication/jsonYes
AuthorizationBearer tokenYes

Request Body Parameters

ParameterTypeDescriptionRequired
idsarrayArray of favorite IDs to removeYes

Success Response

{
"success": true,
"message": "تم حذف البيانات بنجاح.",
"data": null,
"status_code": 200
}

Example Implementation Flow

  1. Favorites Management
    • Application retrieves user's favorites using the list endpoint
    • User can add new items to favorites
    • User can remove items from favorites list
    • Favorites are organized by item type (courses, articles, etc.)

Key Considerations

  • Authentication is required for all endpoints
  • Favorites are personal to each customer
  • The system supports multiple types of favoriteable items
  • Pagination is available for the list endpoint
  • Bulk deletion is supported through the delete endpoint