Documentation
¶
Index ¶
- Variables
- func CheckPackOwnership(ctx context.Context, packID uint, userID uint) (bool, error)
- func DeleteMyPackByID(c *gin.Context)
- func DeleteMyPackContentByID(c *gin.Context)
- func DeletePackByID(c *gin.Context)
- func DeletePackContentByID(c *gin.Context)
- func FindPackIDByPackName(packs Packs, packname string) uint
- func GetMyPackByID(c *gin.Context)
- func GetMyPackContentsByPackID(c *gin.Context)
- func GetMyPacks(c *gin.Context)
- func GetPackByID(c *gin.Context)
- func GetPackContentByID(c *gin.Context)
- func GetPackContents(c *gin.Context)
- func GetPackContentsByPackID(c *gin.Context)
- func GetPacks(c *gin.Context)
- func ImportFromLighterPack(c *gin.Context)
- func PostMyPack(c *gin.Context)
- func PostMyPackContent(c *gin.Context)
- func PostPack(c *gin.Context)
- func PostPackContent(c *gin.Context)
- func PutMyPackByID(c *gin.Context)
- func PutMyPackContentByID(c *gin.Context)
- func PutPackByID(c *gin.Context)
- func PutPackContentByID(c *gin.Context)
- func ShareMyPack(c *gin.Context)
- func SharedList(c *gin.Context)
- func UnshareMyPack(c *gin.Context)
- type ImportLighterPackResponse
- type LighterPack
- type LighterPackItem
- type Pack
- type PackContent
- type PackContentCreateRequest
- type PackContentRequest
- type PackContentUpdateRequest
- type PackContentWithItem
- type PackContentWithItems
- type PackContents
- type PackCreateAdminRequest
- type PackCreateRequest
- type PackUpdateRequest
- type Packs
- type SharedPackInfo
- type SharedPackResponse
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPackNotFound is returned when a pack is not found ErrPackNotFound = errors.New("pack not found") // ErrPackContentNotFound is returned when no items are found in a given pack ErrPackContentNotFound = errors.New("pack content not found") )
Domain errors
Functions ¶
func CheckPackOwnership ¶ added in v0.14.0
CheckPackOwnership verifies if a user owns a specific pack This is a public service function used by other packages (e.g., images)
func DeleteMyPackByID ¶
Delete a pack by ID @Summary Delete a pack by ID @Description Delete a pack by ID @Security Bearer @Tags Packs @Produce json @Param id path int true "Pack ID" @Success 200 {object} apitypes.OkResponse "Pack deleted" @Failure 400 {object} apitypes.ErrorResponse "Invalid ID format" @Failure 401 {object} apitypes.ErrorResponse "Unauthorized" @Failure 403 {object} apitypes.ErrorResponse "This pack does not belong to you" @Failure 500 {object} apitypes.ErrorResponse "Internal Server Error" @Router /v1/mypack/{id} [delete]
func DeleteMyPackContentByID ¶
Delete a pack content ID by Pack ID @Summary Delete a pack content by ID @Description Delete a pack content by ID @Security Bearer @Tags Packs @Produce json @Param id path int true "Pack ID" @Param item_id path int true "Item ID" @Success 200 {object} apitypes.OkResponse "Pack Item deleted" @Failure 400 {object} apitypes.ErrorResponse "Invalid ID format" @Failure 401 {object} apitypes.ErrorResponse "Unauthorized" @Failure 403 {object} apitypes.ErrorResponse "This pack does not belong to you" @Failure 500 {object} apitypes.ErrorResponse "Internal Server Error" @Router /v1/mypack/{id}/packcontent/{item_id} [delete]
func DeletePackByID ¶
func DeletePackContentByID ¶
Delete a pack content by ID @Summary [ADMIN] Delete a pack content by ID @Description Delete a pack content by ID - for admin use only @Security Bearer @Tags Internal @Produce json @Param id path int true "Pack Content ID" @Success 200 {object} map[string]string "message" @Failure 400 {object} apitypes.ErrorResponse @Failure 500 {object} apitypes.ErrorResponse @Router /admin/packcontents/{id} [delete]
func FindPackIDByPackName ¶ added in v0.15.0
FindPackIDByPackName finds a pack ID by its name Returns 0 if not found
func GetMyPackByID ¶
Get My pack by ID @Summary Get My pack by ID @Description Get pack by ID @Security Bearer @Tags Packs @Produce json @Param id path int true "Pack ID" @Success 200 {object} Pack @Failure 400 {object} apitypes.ErrorResponse "Invalid ID format" @Failure 401 {object} apitypes.ErrorResponse "Unauthorized" @Failure 403 {object} apitypes.ErrorResponse "This pack does not belong to you" @Failure 404 {object} apitypes.ErrorResponse "Pack not found" @Failure 500 {object} apitypes.ErrorResponse "Internal Server Error" @Router /v1/mypack/{id} [get]
func GetMyPackContentsByPackID ¶
Get pack content by ID @Summary Get pack content by ID @Description Get pack content by ID @Security Bearer @Tags Packs @Produce json @Param id path int true "Pack Content ID" @Success 200 {object} PackContent "Pack Item" @Failure 400 {object} apitypes.ErrorResponse "Invalid ID format" @Failure 401 {object} apitypes.ErrorResponse "Unauthorized" @Failure 403 {object} apitypes.ErrorResponse "This pack does not belong to you" @Failure 404 {object} apitypes.ErrorResponse "Pack not found" @Failure 500 {object} apitypes.ErrorResponse "Internal Server Error" @Router /v1/mypack/{id}/packcontents [get]
func GetMyPacks ¶
Get My packs @Summary Get My Packs @Description Get my packs @Security Bearer @Tags Packs @Produce json @Success 200 {object} Packs "Packs" @Failure 401 {object} apitypes.ErrorResponse "Unauthorized" @Failure 404 {object} apitypes.ErrorResponse "No pack found" @Failure 500 {object} apitypes.ErrorResponse "Internal Server Error" @Router /v1/mypacks [get]
func GetPackByID ¶
Get pack by ID @Summary [ADMIN] Get pack by ID @Description Get pack by ID - for admin use only @Security Bearer @Tags Internal @Produce json @Param id path int true "Pack ID" @Success 200 {object} Pack @Failure 400 {object} apitypes.ErrorResponse "Invalid ID format" @Failure 404 {object} apitypes.ErrorResponse "Pack not found" @Failure 500 {object} apitypes.ErrorResponse "Internal Server Error" @Router /admin/packs/{id} [get]
func GetPackContentByID ¶
Get pack content by ID @Summary [ADMIN] Get pack content by ID @Description Get pack content by ID - for admin use only @Security Bearer @Tags Internal @Produce json @Param id path int true "Pack Content ID" @Success 200 {object} PackContent @Failure 400 {object} apitypes.ErrorResponse @Failure 404 {object} apitypes.ErrorResponse @Failure 500 {object} apitypes.ErrorResponse @Router /admin/packcontents/{id} [get]
func GetPackContents ¶
Get all pack contents @Summary [ADMIN] Get all pack contents @Description Get all pack contents - for admin use only @Security Bearer @Tags Internal @Produce json @Success 200 {object} PackContents @Failure 500 {object} apitypes.ErrorResponse @Router /admin/packcontents [get]
func GetPackContentsByPackID ¶
Get all pack contents @Summary [ADMIN] Get all pack contents @Description Get all pack contents - for admin use only @Security Bearer @Tags Internal @Produce json @Success 200 {object} PackContents @Failure 400 {object} apitypes.ErrorResponse @Failure 404 {object} apitypes.ErrorResponse @Failure 500 {object} apitypes.ErrorResponse @Router /admin/packs/:id/packcontents [get]
func GetPacks ¶
Get all packs @Summary [ADMIN] Get all packs @Description Get all packs - for admin use only @Security Bearer @Tags Internal @Produce json @Success 200 {object} Packs @Failure 500 {object} apitypes.ErrorResponse @Router /admin/packs [get]
func ImportFromLighterPack ¶
Import from lighterpack @Summary Import from lighterpack csv pack file @Description Import from lighterpack csv pack file @Security Bearer @Tags Packs @Accept multipart/form-data @Produce json @Param file formData file true "CSV file" @Success 200 {object} ImportLighterPackResponse "CSV data imported successfully with pack ID" @Failure 400 {object} apitypes.ErrorResponse "Invalid CSV format" @Failure 401 {object} apitypes.ErrorResponse "Unauthorized" @Failure 500 {object} apitypes.ErrorResponse "Internal Server Error" @Router /v1/importfromlighterpack [post]
func PostMyPack ¶
Create a new pack @Summary Create a new pack @Description Create a new pack @Security Bearer @Tags Packs @Accept json @Produce json @Param pack body PackCreateRequest true "Pack" @Success 201 {object} Pack "Pack created" @Failure 400 {object} apitypes.ErrorResponse "Invalid Body format" @Failure 401 {object} apitypes.ErrorResponse "Unauthorized" @Failure 500 {object} apitypes.ErrorResponse "Internal Server Error" @Router /v1/mypack [post]
func PostMyPackContent ¶
Create a new pack content @Summary Create a new pack content @Description Create a new pack content @Security Bearer @Tags Packs @Accept json @Produce json @Param packcontent body PackContent true "Pack Content" @Success 201 {object} PackContent @Failure 400 {object} apitypes.ErrorResponse @Failure 401 {object} apitypes.ErrorResponse @Failure 403 {object} apitypes.ErrorResponse @Failure 500 {object} apitypes.ErrorResponse @Router /v1/mypack/:id/packcontent [post]
func PostPack ¶
Create a new pack @Summary [ADMIN] Create a new pack @Description Create a new pack - for admin use only @Security Bearer @Tags Internal @Accept json @Produce json @Param pack body PackCreateAdminRequest true "Pack" @Success 201 {object} Pack @Failure 400 {object} apitypes.ErrorResponse @Failure 500 {object} apitypes.ErrorResponse @Router /admin/packs [post]
func PostPackContent ¶
Create a new pack content @Summary [ADMIN] Create a new pack content @Description Create a new pack content - for admin use only @Security Bearer @Tags Internal @Accept json @Produce json @Param packcontent body PackContentCreateRequest true "Pack Content" @Success 201 {object} PackContent @Failure 400 {object} apitypes.ErrorResponse @Failure 500 {object} apitypes.ErrorResponse @Router /admin/packcontents [post]
func PutMyPackByID ¶
Update a pack by ID @Summary Update a pack by ID @Description Update a pack by ID @Security Bearer @Tags Packs @Accept json @Produce json @Param id path int true "Pack ID" @Param pack body PackUpdateRequest true "Pack" @Success 200 {object} Pack "Pack updated" @Failure 400 {object} apitypes.ErrorResponse "Invalid ID format" @Failure 400 {object} apitypes.ErrorResponse "Invalid Payload" @Failure 401 {object} apitypes.ErrorResponse "Unauthorized" @Failure 403 {object} apitypes.ErrorResponse "This pack does not belong to you" @Failure 500 {object} apitypes.ErrorResponse "Internal Server Error" @Router /v1/mypack/{id} [put]
func PutMyPackContentByID ¶
Update My pack content ID by Pack ID @Summary Update My pack content ID by Pack ID @Description Update My pack content ID by Pack ID @Security Bearer @Tags Packs @Accept json @Produce json @Param id path int true "Pack ID" @Param item_id path int true "Item ID" @Param packcontent body PackContentRequest true "Pack Content" @Success 200 {object} PackContent "Pack Content updated" @Failure 400 {object} apitypes.ErrorResponse "Invalid ID format" @Failure 400 {object} apitypes.ErrorResponse "Invalid Body format" @Failure 401 {object} apitypes.ErrorResponse "Unauthorized" @Failure 403 {object} apitypes.ErrorResponse "This pack does not belong to you" @Failure 500 {object} apitypes.ErrorResponse "Internal Server Error" @Router /v1/mypack/{id}/packcontent/{item_id} [put]
func PutPackByID ¶
Update a pack by ID @Summary [ADMIN] Update a pack by ID @Description Update a pack by ID - for admin use only @Security Bearer @Tags Internal @Accept json @Produce json @Param id path int true "Pack ID" @Param pack body PackUpdateRequest true "Pack" @Success 200 {object} Pack @Failure 400 {object} apitypes.ErrorResponse @Failure 500 {object} apitypes.ErrorResponse @Router /admin/packs/{id} [put]
func PutPackContentByID ¶
Update a pack content by ID @Summary [ADMIN] Update a pack content by ID @Description Update a pack content by ID - for admin use only @Security Bearer @Tags Internal @Accept json @Produce json @Param id path int true "Pack Content ID" @Param packcontent body PackContentUpdateRequest true "Pack Content" @Success 200 {object} PackContent @Failure 400 {object} apitypes.ErrorResponse @Failure 500 {object} apitypes.ErrorResponse @Router /admin/packcontents/{id} [put]
func ShareMyPack ¶ added in v0.11.0
Share a pack by ID @Summary Share a pack by ID @Description Generate a sharing code for a pack to make it publicly accessible (idempotent) @Security Bearer @Tags Packs @Produce json @Param id path int true "Pack ID" @Success 200 {object} map[string]string "Pack shared successfully" @Failure 400 {object} apitypes.ErrorResponse "Invalid ID format" @Failure 401 {object} apitypes.ErrorResponse "Unauthorized" @Failure 403 {object} apitypes.ErrorResponse "This pack does not belong to you" @Failure 404 {object} apitypes.ErrorResponse "Pack not found" @Failure 500 {object} apitypes.ErrorResponse "Internal Server Error" @Router /v1/mypack/{id}/share [post]
func SharedList ¶ added in v0.4.0
SharedList gets pack metadata and contents for a shared pack @Summary Get shared pack with metadata @Description Retrieves pack metadata and contents using a sharing code @Tags Public @Accept json @Produce json @Param sharing_code path string true "Pack sharing code" @Success 200 {object} SharedPackResponse "Shared pack with metadata and contents" @Failure 404 {object} apitypes.ErrorResponse "Pack not found or not shared" @Failure 500 {object} apitypes.ErrorResponse "Internal server error" @Router /sharedlist/{sharing_code} [get]
func UnshareMyPack ¶ added in v0.11.0
Unshare a pack by ID @Summary Unshare a pack by ID @Description Remove the sharing code from a pack to make it private (idempotent) @Security Bearer @Tags Packs @Produce json @Param id path int true "Pack ID" @Success 200 {object} apitypes.OkResponse "Pack unshared successfully" @Failure 400 {object} apitypes.ErrorResponse "Invalid ID format" @Failure 401 {object} apitypes.ErrorResponse "Unauthorized" @Failure 403 {object} apitypes.ErrorResponse "This pack does not belong to you" @Failure 404 {object} apitypes.ErrorResponse "Pack not found" @Failure 500 {object} apitypes.ErrorResponse "Internal Server Error" @Router /v1/mypack/{id}/share [delete]
Types ¶
type ImportLighterPackResponse ¶ added in v0.15.1
type ImportLighterPackResponse struct {
Message string `json:"message"`
PackID uint `json:"pack_id"`
}
ImportLighterPackResponse represents the response when importing from LighterPack
type LighterPack ¶ added in v0.15.0
type LighterPack []LighterPackItem
LighterPack represents a collection of LighterPack items
type LighterPackItem ¶ added in v0.15.0
type LighterPackItem struct {
ItemName string `json:"item_name"`
Category string `json:"category"`
Desc string `json:"desc"`
Qty int `json:"qty"`
Weight int `json:"weight"`
Unit string `json:"unit"`
URL string `json:"url"`
Price int `json:"price"`
Worn bool `json:"worn"`
Consumable bool `json:"consumable"`
}
LighterPackItem represents an item imported from LighterPack format
type Pack ¶ added in v0.15.0
type Pack struct {
ID uint `json:"id"`
UserID uint `json:"user_id"`
PackName string `json:"pack_name"`
PackDescription string `json:"pack_description"`
PackWeight int `json:"pack_weight"`
PackItemsCount int `json:"pack_items_count"`
SharingCode *string `json:"sharing_code,omitempty"`
HasImage bool `json:"has_image"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Pack represents a pack with its metadata
type PackContent ¶ added in v0.15.0
type PackContent struct {
ID uint `json:"id"`
PackID uint `json:"pack_id"`
ItemID uint `json:"item_id"`
Quantity int `json:"quantity"`
Worn bool `json:"worn"`
Consumable bool `json:"consumable"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
PackContent represents an item in a pack
type PackContentCreateRequest ¶ added in v1.0.0
type PackContentCreateRequest struct {
PackID uint `json:"pack_id" binding:"required"`
ItemID uint `json:"item_id" binding:"required"`
Quantity int `json:"quantity" binding:"required,min=1"`
Worn bool `json:"worn"`
Consumable bool `json:"consumable"`
}
PackContentCreateRequest represents the input for creating pack content (admin) Note: User endpoint uses PackContentRequest which doesn't include PackID/ItemID
type PackContentRequest ¶ added in v0.15.0
type PackContentRequest struct {
InventoryID uint `json:"inventory_id" binding:"required"`
Quantity int `json:"quantity" binding:"required,min=1"`
Worn bool `json:"worn"`
Consumable bool `json:"consumable"`
}
PackContentRequest represents the data required to add an item to a pack
type PackContentUpdateRequest ¶ added in v1.0.0
type PackContentUpdateRequest struct {
PackID uint `json:"pack_id" binding:"required"`
ItemID uint `json:"item_id" binding:"required"`
Quantity int `json:"quantity" binding:"required,min=1"`
Worn bool `json:"worn"`
Consumable bool `json:"consumable"`
}
PackContentUpdateRequest represents the input for updating pack content
type PackContentWithItem ¶ added in v0.15.0
type PackContentWithItem struct {
PackContentID uint `json:"pack_content_id"`
PackID uint `json:"pack_id"`
InventoryID uint `json:"inventory_id"`
ItemName string `json:"item_name"`
Category string `json:"category"`
ItemDescription string `json:"item_description"`
Weight int `json:"weight"`
ItemURL string `json:"item_url"`
Price int `json:"price"`
Currency string `json:"currency"`
Quantity int `json:"quantity"`
Worn bool `json:"worn"`
Consumable bool `json:"consumable"`
}
PackContentWithItem represents a pack content with inventory item details
type PackContentWithItems ¶ added in v0.15.0
type PackContentWithItems []PackContentWithItem
PackContentWithItems represents a collection of pack contents with item details
type PackContents ¶ added in v0.15.0
type PackContents []PackContent
PackContents represents a collection of pack contents
type PackCreateAdminRequest ¶ added in v1.0.0
type PackCreateAdminRequest struct {
UserID uint `json:"user_id" binding:"required"`
PackName string `json:"pack_name" binding:"required"`
PackDescription string `json:"pack_description"`
}
PackCreateAdminRequest represents the input for creating a pack (admin endpoint)
type PackCreateRequest ¶ added in v1.0.0
type PackCreateRequest struct {
PackName string `json:"pack_name" binding:"required"`
PackDescription string `json:"pack_description"`
}
PackCreateRequest represents the input for creating a pack (user endpoint)
type PackUpdateRequest ¶ added in v1.0.0
type PackUpdateRequest struct {
PackName string `json:"pack_name" binding:"required"`
PackDescription string `json:"pack_description"`
}
PackUpdateRequest represents the input for updating a pack
type SharedPackInfo ¶ added in v0.15.0
type SharedPackInfo struct {
}
SharedPackInfo contains public metadata about a shared pack UserID and SharingCode are intentionally not included for security Note: pack_items_count is not included as it doesn't exist in DB schema Clients can count items from the contents array
type SharedPackResponse ¶ added in v0.15.0
type SharedPackResponse struct {
}
SharedPackResponse represents the response structure for shared pack endpoint