Subscriptions
This guide explains how to interact with the Subscriptions API in the Sumaya369 mobile application. The API provides endpoints for retrieving and creating subscriptions.
List Subscriptions
Retrieve a list of subscriptions for the authenticated customer. This endpoint returns the customer's active and historical subscriptions, filtered by product type.
Endpoint
- Method: GET
- URL:
/v1/mobile/subscriptions
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Accept | application/json | Yes |
| Authorization | Bearer token | Yes |
Query Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | string | Filter by product type ('courses', 'ebooks', 'bundles') | Yes |
| search_text | string | Search within product names | No |
| per_page | integer | Number of items per page | No |
Success Response
{
"success": true,
"message": "تم جلب البيانات بنجاح.",
"data": {
"current_page": 1,
"first_page_url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=1",
"from": 1,
"last_page": 62,
"last_page_url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=62",
"links": [
{
"url": null,
"label": "« السابق",
"active": false
},
{
"url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=1",
"label": "1",
"active": true
},
{
"url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=2",
"label": "2",
"active": false
},
{
"url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=3",
"label": "3",
"active": false
},
{
"url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=4",
"label": "4",
"active": false
},
{
"url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=5",
"label": "5",
"active": false
},
{
"url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=6",
"label": "6",
"active": false
},
{
"url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=7",
"label": "7",
"active": false
},
{
"url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=8",
"label": "8",
"active": false
},
{
"url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=9",
"label": "9",
"active": false
},
{
"url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=10",
"label": "10",
"active": false
},
{
"url": null,
"label": "...",
"active": false
},
{
"url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=61",
"label": "61",
"active": false
},
{
"url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=62",
"label": "62",
"active": false
},
{
"url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=2",
"label": "التالي »",
"active": false
}
],
"next_page_url": "http://127.0.0.1:8000/v1/mobile/subscriptions?per_page=2&type=courses&page=2",
"path": "http://127.0.0.1:8000/v1/mobile/subscriptions",
"per_page": 2,
"prev_page_url": null,
"to": 2,
"total": 123,
"subscriptions": [
{
"id": "2ce6b770-afc3-11ef-b2ed-072cd6701140",
"poster": "http://127.0.0.1:8000/storage/27413/8-قفزة2025.jpg",
"name": "قفزة 2025",
"price": 130.44,
"watched_videos_count": 0,
"subscription_status_date": "سينتهي اشتراكك بعد 652.99999999999 يوم",
"videos_count": null
},
{
"id": "711117b0-1e5d-11ef-99e8-510e7b0073e2",
"poster": "http://127.0.0.1:8000/storage/23266/الاطفال-السبعة-(1).jpg-جديد.jpg",
"name": "الأطفال السبعة",
"price": 868.7,
"watched_videos_count": 0,
"subscription_status_date": "سينتهي اشتراكك بعد 456.99999999999 يوم",
"videos_count": null
}
]
},
"status_code": 200
}
Create Subscription
Create a new subscription for the authenticated customer. This endpoint handles both free courses and courses with reduced pricing.
Endpoint
- Method: POST
- URL:
/v1/mobile/subscriptions
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Accept | application/json | Yes |
| Authorization | Bearer token | Yes |
Request Body
| Parameter | Type | Description | Required |
|---|---|---|---|
| id | string | UUID or special ID of the course | Yes |
Success Response
{
"success": true,
"message": "تم إضافة المادة إلى إشتراكاتك",
"data": null,
"status_code": 200
}
Error Responses
{
"success": false,
"message": "أنت مشترك في هذه المادة من قبل",
"errors": "أنت مشترك في هذه المادة من قبل",
"data": null,
"status_code": 400
}
{
"success": false,
"message": "أنت غير مصرح لهذا الإجراء",
"errors": "أنت غير مصرح لهذا الإجراء",
"data": null,
"status_code": 422
}
Implementation Details
Listing Subscriptions
- Supports filtering by product type (courses, ebooks, bundles)
- Courses are sorted by completion status and expiry date
- Bundle subscriptions show grouped products under each bundle
- Includes video progress tracking for courses
- Supports pagination and search functionality
Creating Subscriptions
- Handles both UUID and special course IDs
- Validates free course access
- Checks for reduced price eligibility
- Manages subscription renewal for existing subscriptions
- Sets appropriate expiration dates based on course duration
- Records subscription history and operations
Key Considerations
- Authentication is required for all subscription endpoints
- Subscriptions are tied to the authenticated customer
- Course subscriptions include video tracking and certificate/summary availability
- Bundle subscriptions group related products together
- Proper validation is performed for subscription eligibility