feat: Category API to handle linked categories and parent-sub categories (#4879)

This commit is contained in:
Tejaswini Chile
2022-06-28 11:23:20 +05:30
committed by GitHub
parent c0249a1b5b
commit df1bf112ea
15 changed files with 286 additions and 29 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'category', category: @category
end