72 lines
1.6 KiB
Go
72 lines
1.6 KiB
Go
package api
|
|
|
|
import "havenllo/internal/domain"
|
|
|
|
type createListRequest struct {
|
|
Name string `json:"name"`
|
|
Position *float64 `json:"position,omitempty"`
|
|
}
|
|
|
|
type updateListRequest struct {
|
|
Name *string `json:"name,omitempty"`
|
|
Position *float64 `json:"position,omitempty"`
|
|
}
|
|
|
|
type createCardRequest struct {
|
|
Title string `json:"title"`
|
|
Description string `json:"description"`
|
|
Position *float64 `json:"position,omitempty"`
|
|
}
|
|
|
|
type updateCardRequest struct {
|
|
Title *string `json:"title,omitempty"`
|
|
Description *string `json:"description,omitempty"`
|
|
ListID *int64 `json:"list_id,omitempty"`
|
|
Position *float64 `json:"position,omitempty"`
|
|
}
|
|
|
|
type errorResponse struct {
|
|
Error apiError `json:"error"`
|
|
}
|
|
|
|
type apiError struct {
|
|
Code string `json:"code"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
type listResponse struct {
|
|
List domain.List `json:"list"`
|
|
}
|
|
|
|
type listDetailsResponse struct {
|
|
List domain.List `json:"list"`
|
|
Cards []domain.Card `json:"cards"`
|
|
}
|
|
|
|
type listSummary struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Position float64 `json:"position"`
|
|
CardCount int `json:"card_count"`
|
|
}
|
|
|
|
type listsResponse struct {
|
|
Lists []listSummary `json:"lists"`
|
|
}
|
|
type cardResponse struct {
|
|
Card domain.Card `json:"card"`
|
|
}
|
|
type cardsResponse struct {
|
|
Cards []domain.Card `json:"cards"`
|
|
}
|
|
|
|
func listSummaries(lists []domain.List) []listSummary {
|
|
summaries := make([]listSummary, 0, len(lists))
|
|
for _, list := range lists {
|
|
summaries = append(summaries, listSummary{
|
|
ID: list.ID, Name: list.Name, Position: list.Position, CardCount: list.CardCount,
|
|
})
|
|
}
|
|
return summaries
|
|
}
|