aboutsummaryrefslogtreecommitdiffstats
path: root/lulu.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2026-05-07 11:53:51 -0400
committerSam Anthony <sam@samanthony.xyz>2026-05-07 11:53:51 -0400
commitf2ee817ba1423b10b382f6b759a19184db8eeacc (patch)
tree57d7660024b9b21d2a9ac80c351b2911b5c573e7 /lulu.go
parent09c91d21b083abc976a4cc6439899fb00438a630 (diff)
downloadlulu-f2ee817ba1423b10b382f6b759a19184db8eeacc.zip
refactor
Diffstat (limited to 'lulu.go')
-rw-r--r--lulu.go87
1 files changed, 0 insertions, 87 deletions
diff --git a/lulu.go b/lulu.go
index af425f0..1fdf7a3 100644
--- a/lulu.go
+++ b/lulu.go
@@ -9,7 +9,6 @@ import (
"io"
"net/http"
"net/url"
- "strconv"
"golang.org/x/oauth2/clientcredentials"
)
@@ -29,92 +28,6 @@ const (
// you are ready to deploy.
var ApiUrl = SandboxUrl
-// Unit is a unit of length measurement.
-type Unit string
-
-const (
- Points Unit = "pt"
- Millimeters Unit = "mm"
- Inches Unit = "inch"
-)
-
-type ValidationStatus string
-
-const (
- StatusNull ValidationStatus = "NULL" // file validation is not started yet
- StatusValidating ValidationStatus = "VALIDATING" // file validation is still running
- StatusValidated ValidationStatus = "VALIDATED" // file validation finished without any errors
- StatusNormalizing ValidationStatus = "NORMALIZING" // file normalization (next step of validation, available only if pod_package_id is was passed in the payload) is still running
- StatusNormalized ValidationStatus = "NORMALIZED" // file normalization finished without any errors
- StatusError ValidationStatus = "ERROR" // file is invalid, list of errors is included in the response
-)
-
-func (s ValidationStatus) IsFinal() bool {
- switch s {
- case StatusValidated, StatusNormalized, StatusError:
- return true
- }
- return false
-}
-
-// validateInteriorReq is the json body of a /validate-interior/ request.
-type validateInteriorReq struct {
- SrcUrl string `json:"source_url"`
- PkgId PkgId `json:"pod_package_id"`
-}
-
-// validateInteriorReq is the json body of a /validate-interior/ request without the optional pod_package_id.
-type validateInteriorBasicReq struct {
- SrcUrl string `json:"source_url"`
-}
-
-// InteriorValidationRecord contains the validation status of an interior file.
-type InteriorValidationRecord struct {
- Id uint
- SrcUrl string `json:"source_url"`
- NPages uint `json:"page_count"`
- Errors string
- Status ValidationStatus
- ValidPkgIds []PkgId `json:"valid_pod_package_ids"`
-}
-
-// coverDimensionsReq is the json body of a /cover-dimensions/ request.
-type coverDimensionsReq struct {
- PkgId PkgId `json:"pod_package_id"`
- NPages uint `json:"interior_page_count"`
- Unit Unit `json:"unit"`
-}
-
-type CoverDimensions struct {
- Width, Height float64
- Unit Unit
-}
-
-func (cd *CoverDimensions) UnmarshalJSON(data []byte) error {
- s := string(data)
- var alias struct {
- Width, Height string
- Unit Unit
- }
- if err := json.Unmarshal(data, &alias); err != nil {
- return fmt.Errorf("malformed %T: %q: %w", cd, s, err)
- }
-
- w, err := strconv.ParseFloat(alias.Width, 64)
- if err != nil {
- return fmt.Errorf("malformed %T.Width: %q: %w", cd, s, err)
- }
- h, err := strconv.ParseFloat(alias.Height, 64)
- if err != nil {
- return fmt.Errorf("malformed %T.Height: %q: %w", cd, s, err)
- }
-
- cd.Width = w
- cd.Height = h
- cd.Unit = alias.Unit
- return nil
-}
-
type Client struct {
c *http.Client
}