From 40cc71589824a3d6fb9e6a590850f5e99e911b28 Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Sun, 18 Dec 2022 20:51:26 +0100 Subject: [PATCH] Init --- README.md | 3 +++ go.mod | 3 +++ http/basket.go | 9 +++++++++ http/catalog.go | 17 +++++++++++++++++ http/error.go | 9 +++++++++ http/health.go | 5 +++++ http/identity.go | 10 ++++++++++ http/order.go | 8 ++++++++ http/pricing.go | 9 +++++++++ model/basket.go | 11 +++++++++++ model/pricing.go | 1 + 11 files changed, 85 insertions(+) create mode 100644 README.md create mode 100644 go.mod create mode 100644 http/basket.go create mode 100644 http/catalog.go create mode 100644 http/error.go create mode 100644 http/health.go create mode 100644 http/identity.go create mode 100644 http/order.go create mode 100644 http/pricing.go create mode 100644 model/basket.go create mode 100644 model/pricing.go diff --git a/README.md b/README.md new file mode 100644 index 0000000..323b366 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# api-entities + +API Entities. diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..37606e2 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module git.pbiernat.dev/egommerce/api-entities + +go 1.19 diff --git a/http/basket.go b/http/basket.go new file mode 100644 index 0000000..b14b8e0 --- /dev/null +++ b/http/basket.go @@ -0,0 +1,9 @@ +package http + +type BasketCheckoutRequest struct { + BasketID string `json:"basket_id"` +} + +type BasketCheckoutResponse struct { + ID string `json:"order_id"` +} diff --git a/http/catalog.go b/http/catalog.go new file mode 100644 index 0000000..e527b78 --- /dev/null +++ b/http/catalog.go @@ -0,0 +1,17 @@ +package http + +type AddProductToBasketRequest struct { + ProductID int `json:"product_id"` +} + +type ProductAddToBasketResponse struct { + BasketID string `json:"basket_id"` +} + +type RemoveProductFromBasketRequest struct { + ProductID int `json:"product_id"` +} + +type RemoveProductFromBasketResponse struct { + BasketID string `json:"basket_id"` +} diff --git a/http/error.go b/http/error.go new file mode 100644 index 0000000..242e86a --- /dev/null +++ b/http/error.go @@ -0,0 +1,9 @@ +package http + +type ErrorResponse struct { + Error string `json:"error"` +} + +func Error(err string) *ErrorResponse { + return &ErrorResponse{err} +} diff --git a/http/health.go b/http/health.go new file mode 100644 index 0000000..ec996a1 --- /dev/null +++ b/http/health.go @@ -0,0 +1,5 @@ +package http + +type HealthResponse struct { + Status string `json:"status,omitempty"` +} diff --git a/http/identity.go b/http/identity.go new file mode 100644 index 0000000..bb15239 --- /dev/null +++ b/http/identity.go @@ -0,0 +1,10 @@ +package http + +type AuthLoginRequest struct { + Username string `json:"username"` + Password string `json:"password"` +} + +type AuthLoginResponse struct { + Token string `json:"jwt_token"` +} diff --git a/http/order.go b/http/order.go new file mode 100644 index 0000000..498a3bf --- /dev/null +++ b/http/order.go @@ -0,0 +1,8 @@ +package http + +type UpdateOrderStatusRequest struct { + Status string `json:"status"` +} + +type UpdateOrderStatusResponse struct { +} diff --git a/http/pricing.go b/http/pricing.go new file mode 100644 index 0000000..ee42dc2 --- /dev/null +++ b/http/pricing.go @@ -0,0 +1,9 @@ +package http + +type ProductPriceRequest struct { + ProductId int `json:"product_id"` +} + +type ProductPriceResponse struct { + Price float64 `json:"price"` +} diff --git a/model/basket.go b/model/basket.go new file mode 100644 index 0000000..7219154 --- /dev/null +++ b/model/basket.go @@ -0,0 +1,11 @@ +package definition + +import ( + "github.com/jackc/pgtype" +) + +type BasketModel struct { + ID string `db:"id"` + CreatedAt pgtype.Timestamp `db:"created_at"` + UpdatedAt pgtype.Timestamp `db:"updated_at"` +} diff --git a/model/pricing.go b/model/pricing.go new file mode 100644 index 0000000..acf40ad --- /dev/null +++ b/model/pricing.go @@ -0,0 +1 @@ +package definition