From b57f03381e4bccba2963cebabe51a9cf32bd96dd Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Thu, 7 May 2026 12:44:21 -0400 Subject: implement POST /validate-cover --- cover.go | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'cover.go') diff --git a/cover.go b/cover.go index 30be2d6..e5845a7 100644 --- a/cover.go +++ b/cover.go @@ -6,7 +6,7 @@ import ( "strconv" ) -//go:generate go run github.com/yawnak/string-enumer -t Unit --text -o ./cover_gen.go . +//go:generate go run github.com/yawnak/string-enumer -t Unit -t CoverValidationStatus --text -o ./cover_gen.go . // Unit is a unit of length measurement. type Unit string @@ -17,6 +17,17 @@ const ( Inches Unit = "inch" ) +// CoverValidationStatus is the status of a validation job for a cover +// file that is running on the server. +type CoverValidationStatus string + +const ( + CoverStatusNull CoverValidationStatus = "NULL" // file validation is not started yet + CoverStatusNormalizing CoverValidationStatus = "NORMALIZING" // file validation is still running + CoverStatusNormalized CoverValidationStatus = "NORMALIZED" // file validation finished without any errors + CoverStatusError CoverValidationStatus = "ERROR" // file is invalid, list of errors is included in the response +) + // coverDimensionsReq is the json body of a /cover-dimensions/ request. type coverDimensionsReq struct { PkgId PkgId `json:"pod_package_id"` @@ -24,6 +35,13 @@ type coverDimensionsReq struct { Unit Unit `json:"unit"` } +// validateCoverReq is the json body of a /validate-cover/ request. +type validateCoverReq struct { + SrcUrl string `json:"source_url"` + PkgId PkgId `json:"pod_package_id"` + NPages uint `json:"interior_page_count"` +} + type CoverDimensions struct { Width, Height float64 Unit Unit @@ -53,3 +71,12 @@ func (cd *CoverDimensions) UnmarshalJSON(data []byte) error { cd.Unit = alias.Unit return nil } + +// CoverValidationRecord contains the validation status of a cover file. +type CoverValidationRecord struct { + Id uint + SrcUrl string `json:"source_url"` + NPages uint `json:"page_count"` + Errors string + Status CoverValidationStatus +} -- cgit v1.2.3