[TRD] Group Landing Page Phase 2 Implementation Backend
Admin APIs
Get a Group Landing Page
- URL
{base_url}/admin/group_landing_pages/{group_landing_page_id}.json
- HTTP Method
GET
- Response (success)
HTTP Code => 200 (ok)
{
"success": true,
"message": null,
"data": {
"id": 45,
"slug": "test-title-basic-info",
"title_en": "Test Title Basic Info",
"title_th": "Test Title Basic Info",
"description_th": "Test Description Basic Info",
"description_en": "Test Description Basic Info",
"footer_description_th": "Footer Description Basic Info",
"footer_description_en": "Footer Description Basic Info",
"tag_line_th": "Tag Line Basic Info",
"tag_line_en": "Tag Line Basic Info",
"sort_type": "most_relevance",
"group_single_type": null,
"created_at": "2024-08-30T09:13:38.000Z",
"updated_at": "2024-09-02T03:48:06.000Z",
"tags": [
{
"group_type": "Branch",
"group_id": 78,
"priority": 1,
"rank_sort_type": "manual"
},
{
"group_type": "RestaurantTagGroup",
"group_id": 69,
"priority": 2,
"rank_sort_type": "manual"
},
{
"group_type": "RestaurantTag",
"group_id": 1272,
"priority": 3,
"rank_sort_type": "default"
},
{
"group_type": "RestaurantTag",
"group_id": 2,
"priority": 4,
"rank_sort_type": "manual"
}
],
"banners": [
{
"priority": 1,
"mobile_version": "/uploads/attachment/mobile_version/3779/rails-logo.png",
"desktop_version": "/uploads/attachment/desktop_version/3779/rails-logo.png",
"locale": "th"
},
{
"priority": 2,
"mobile_version": "/uploads/attachment/mobile_version/3780/rails-logo.png",
"desktop_version": "/uploads/attachment/desktop_version/3780/rails-logo.png",
"locale": "en"
}
],
"restaurant_ranks": [
{
"group_type": "Branch",
"group_id": 78,
"restaurant_id": 34,
"rank": 1
},
{
"group_type": "Branch",
"group_id": 78,
"restaurant_id": 997,
"rank": 2
}
],
"compact_restaurant_ranks": [
{
"group_type": "RestaurantTagGroup",
"group_id": 69,
"compact_restaurant_id": 204,
"rank": 1
},
{
"group_type": "RestaurantTag",
"group_id": 2,
"compact_restaurant_id": 204,
"rank": 1
},
{
"group_type": "RestaurantTagGroup",
"group_id": 69,
"compact_restaurant_id": 157,
"rank": 2
},
{
"group_type": "RestaurantTag",
"group_id": 2,
"compact_restaurant_id": 157,
"rank": 2
}
]
}
}
Create New Group Landing Page
- URL
{base_url}/admin/group_landing_pages.json
- HTTP Method
POST
- Request Body
Rules
- Request type should be form-data
- Available sort_type values = ['most_relevance', 'price asc', 'price desc', 'reviews_score desc', 'most_reviewed', 'nearest_first']
- group_landing_page_groups_attributes priority is unique
- glp_restaurant_ranks_attributes for group_type: 'Branch' and rank_sort_type: 'manual'
- glp_compact_restaurant_ranks_attributes for group_type 'RestaurantTag' and 'RestaurantTagGroup'
- glp_restaurant_ranks_attributes and glp_compact_restaurant_ranks_attributes only filled if the rank_sort_type is 'manual' (no need for 'default')
- rank for the same group_type and group_id on glp_restaurant_ranks_attributes and glp_compact_restaurant_ranks_attributes is unique
Request Body (form-data)
{
"group_landing_page": {
"title_en": "Test Title Basic Info",
"title_th": "Test Title Basic Info",
"description_th": "Test Description Basic Info",
"description_en": "Test Description Basic Info",
"footer_description_th": "Footer Description Basic Info",
"footer_description_en": "Footer Description Basic Info",
"tag_line_th": "Tag Line Basic Info",
"tag_line_en": "Tag Line Basic Info",
"sort_type": "most_relevance",
"banners": [
{
"priority": 1,
"mobile_version": {{ input file }},
"desktop_version": {{ input file }},
"locale": "th"
},
{
"priority": 2,
"mobile_version": {{ input file }},
"desktop_version": {{ input file }},
"locale": "en"
}
],
"group_landing_page_groups_attributes": [
{
"group_type": "Branch",
"group_id": 78,
"priority": 1,
"rank_sort_type": "manual"
},
{
"group_type": "RestaurantTag",
"group_id": 1272,
"priority": 3,
"rank_sort_type": "default"
},
{
"group_type": "RestaurantTagGroup",
"group_id": 69,
"priority": 2,
"rank_sort_type": "manual"
},
{
"group_type": "RestaurantTag",
"group_id": 2,
"priority": 4,
"rank_sort_type": "manual"
}
],
"glp_restaurant_ranks_attributes": [
{
"group_type": "Branch",
"group_id": 78,
"restaurant_id": 34,
"rank": 1
},
{
"group_type": "Branch",
"group_id": 78,
"restaurant_id": 997,
"rank": 2
}
],
"glp_compact_restaurant_ranks_attributes": [
{
"group_type": "RestaurantTagGroup",
"group_id": 69,
"compact_restaurant_id": 204,
"rank": 1
},
{
"group_type": "RestaurantTagGroup",
"group_id": 69,
"compact_restaurant_id": 157,
"rank": 2
},
{
"group_type": "RestaurantTag",
"group_id": 2,
"compact_restaurant_id": 204,
"rank": 1
},
{
"group_type": "RestaurantTag",
"group_id": 2,
"compact_restaurant_id": 157,
"rank": 2
}
]
}
}
- Response (success)
HTTP Code => 200 (ok)
{
"success": true,
"message": "Group landing page created successfully",
"data": {
// The value is the same with data from Get a Group Landing Page response.data
}
}
Update Group Landing Page Basic Info
- URL
{base_url}/admin/group_landing_pages/{group_landing_page_id}.json
- HTTP Method
PUT
- Request Body
JSON
{
"group_landing_page": {
"title_en": "Test Title Basic Info",
"title_th": "Test Title Basic Info",
"description_th": "Test Description Basic Info",
"description_en": "Test Description Basic Info",
"footer_description_th": "Footer Description Basic Info",
"footer_description_en": "Footer Description Basic Info",
"tag_line_th": "Tag Line Basic Info",
"tag_line_en": "Tag Line Basic Info",
"sort_type": "most_relevance"
}
}
- Response (success)
HTTP Code => 200 (ok)
{
"success": true,
"message": "Group landing page updated successfully",
"data": {
// The value is the same with data from Get a Group Landing Page response.data
}
}
Update Group Landing Page Attachments (Banners)
- URL
{base_url}/admin/group_landing_pages/:group_landing_page_id/banners.json
- HTTP Method
PUT
- Request Body
Rules
- Request type should be form-data
- add_attachments_attributes priority is unique
- locale values are either
enorth
Request Body (form-data)
{
"group_landing_page": {
"add_attachments_attributes": [
{
"priority": 1,
"mobile_version": {{ input file }},
"desktop_version": {{ input file }},
"locale": "en"
},
{
"priority": 2,
"mobile_version": {{ input file }},
"desktop_version": {{ input file }},
"locale": "th"
},
{
"priority": 3,
"mobile_version": {{ input file }},
"desktop_version": {{ input file }},
"locale": "th"
}
],
"remove_attachments_attributes": [
{
"id": 1
},
{
"id": 2
},
{
"id": 25
}
]
}
}
- Response (Success)
HTTP Code: 200 (ok)
{
"success": true,
"message": "Group landing page banners updated successfully",
"data": {
// The value is the same with data from Get a Group Landing Page response.data
}
}
Update Group Landing Page Tags
- URL
{base_url}/admin/group_landing_pages/:group_landing_page_id/tags.json
- HTTP Method
PUT
- Request Body
Rules:
- group_landing_page_groups_attributes priority is unique
- glp_restaurant_ranks_attributes for group_type: 'Branch' and rank_sort_type: 'manual'
- glp_compact_restaurant_ranks_attributes for group_type 'RestaurantTag' and 'RestaurantTagGroup'
- glp_restaurant_ranks_attributes and glp_compact_restaurant_ranks_attributes only filled if the rank_sort_type is 'manual' (no need for 'default')
- rank for the same group_type and group_id on glp_restaurant_ranks_attributes and glp_compact_restaurant_ranks_attributes is unique
JSON:
{
"group_landing_page": {
"group_landing_page_groups_attributes": [
{
"group_type": "Branch",
"group_id": 78,
"priority": 1,
"rank_sort_type": "manual"
},
{
"group_type": "RestaurantTag",
"group_id": 1272,
"priority": 3,
"rank_sort_type": "default"
},
{
"group_type": "RestaurantTagGroup",
"group_id": 69,
"priority": 2,
"rank_sort_type": "manual"
},
{
"group_type": "RestaurantTag",
"group_id": 2,
"priority": 4,
"rank_sort_type": "manual"
}
],
"glp_restaurant_ranks_attributes": [
{
"group_type": "Branch",
"group_id": 78,
"restaurant_id": 34,
"rank": 1
},
{
"group_type": "Branch",
"group_id": 78,
"restaurant_id": 997,
"rank": 2
}
],
"glp_compact_restaurant_ranks_attributes": [
{
"group_type": "RestaurantTagGroup",
"group_id": 69,
"compact_restaurant_id": 204,
"rank": 1
},
{
"group_type": "RestaurantTagGroup",
"group_id": 69,
"compact_restaurant_id": 157,
"rank": 2
},
{
"group_type": "RestaurantTag",
"group_id": 2,
"compact_restaurant_id": 204,
"rank": 1
},
{
"group_type": "RestaurantTag",
"group_id": 2,
"compact_restaurant_id": 157,
"rank": 2
}
]
}
}
- Response (Success)
HTTP Code: 200 (ok)
{
"success": true,
"message": "Group landing page tags updated successfully",
"data": {
// The value is the same with data from Get a Group Landing Page response.data
}
}
Delete Group Landing Page
- URL
{base_url}/admin/group_landing_pages/{group_landing_page_id}.json
- HTTP Method
DELETE
- Response (success)
Rules
- Delete a group landing page will remove all of data related to the group landing page like banners, groups, dan ranks
{
"success": true,
"message": "Group landing page deleted successfully",
"data": null
}
Get Associated Outlets
- URL
{base_url}/admin/group_landing_pages/associated_outlets.json?group_type={group_type}&group_id={group_id}
- HTTP Method
GET
- Response (success)
Rules
1. group_type values are 'Branch', 'RestaurantTag', or 'RestaurantTagGroup'
2. group_type and group_id params are required
3. If group_type = "Branch" the data will include restaurants
4. If group_type = "RestaurantTag" or "RestaurantTagGroup" the data will include compact_restaurants
- Request Query
?group_type={group_type}&group_id={group_id}
- Response (Success)
Response 1 (Branch)
{
"success": true,
"message": null,
"data": {
"restaurants": [
{
"id": 33,
"name": "Audrey Cafe (Thonglor Soi 11)"
},
{
"id": 423,
"name": "Audrey Cafe (Siam Center)"
},
{
"id": 424,
"name": "Audrey Cafe (Central Embassy)"
},
{
"id": 425,
"name": "Audrey Cafe (EmQuartier)"
},
{
"id": 426,
"name": "Audrey Cafe Central Ladprao"
},
{
"id": 554,
"name": "Audrey Cafe (ZPELL Rangsit)"
},
{
"id": 581,
"name": "Audrey Cafe (Central WestGate)"
}
]
}
}
Response 2 (RestaurantTag or RestaurantTagGroup)
{
"success": true,
"message": null,
"data": {
"compact_restaurants": [
{
"id": 6,
"name": "You & I Buffet Delivery"
},
{
"id": 8,
"name": "Maneeja Seafood"
},
{
"id": 10,
"name": "Rang Mahal Rembrandt Hotel"
}
]
}
}