feat: Category API to handle linked categories and parent-sub categories (#4879)
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
json.id category.id
|
||||
json.name category.name
|
||||
json.slug category.slug
|
||||
json.locale category.locale
|
||||
json.description category.description
|
||||
json.position category.position
|
||||
json.account_id category.account_id
|
||||
@@ -5,3 +5,23 @@ json.locale category.locale
|
||||
json.description category.description
|
||||
json.position category.position
|
||||
json.account_id category.account_id
|
||||
|
||||
json.related_categories do
|
||||
if category.related_categories.any?
|
||||
json.array! category.related_categories.each do |related_category|
|
||||
json.partial! 'api/v1/accounts/categories/associated_category.json.jbuilder', category: related_category
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if category.parent_category.present?
|
||||
json.parent_category do
|
||||
json.partial! 'api/v1/accounts/categories/associated_category.json.jbuilder', category: category.parent_category
|
||||
end
|
||||
end
|
||||
|
||||
if category.linked_category.present?
|
||||
json.linked_category do
|
||||
json.partial! 'api/v1/accounts/categories/associated_category.json.jbuilder', category: category.linked_category
|
||||
end
|
||||
end
|
||||
|
||||
3
app/views/api/v1/accounts/categories/show.json.jbuilder
Normal file
3
app/views/api/v1/accounts/categories/show.json.jbuilder
Normal file
@@ -0,0 +1,3 @@
|
||||
json.payload do
|
||||
json.partial! 'category', category: @category
|
||||
end
|
||||
Reference in New Issue
Block a user