aboutsummaryrefslogtreecommitdiffstats
path: root/api/dto
diff options
context:
space:
mode:
Diffstat (limited to 'api/dto')
-rw-r--r--api/dto/favourites.go34
-rw-r--r--api/dto/response.go21
-rw-r--r--api/dto/schedule.go10
-rw-r--r--api/dto/users.go20
4 files changed, 85 insertions, 0 deletions
diff --git a/api/dto/favourites.go b/api/dto/favourites.go
new file mode 100644
index 0000000..0f8021f
--- /dev/null
+++ b/api/dto/favourites.go
@@ -0,0 +1,34 @@
+package dto
+
+import "github.com/LMBishop/confplanner/pkg/database/sqlc"
+
+type CreateFavouritesRequest struct {
+ GUID *string `json:"eventGuid"`
+ ID *int32 `json:"eventId"`
+}
+
+type CreateFavouritesResponse struct {
+ ID int32 `json:"id"`
+}
+
+type GetFavouritesResponse struct {
+ ID int32 `json:"id"`
+ GUID *string `json:"eventGuid,omitempty"`
+ EventID *int32 `json:"eventId,omitempty"`
+}
+
+func (dst *GetFavouritesResponse) Scan(src sqlc.Favourite) {
+ dst.ID = src.ID
+ if src.EventGuid.Valid {
+ strGuid := src.EventGuid.String()
+ dst.GUID = &strGuid
+ }
+ if src.EventID.Valid {
+ dst.EventID = &src.EventID.Int32
+ }
+}
+
+type DeleteFavouritesRequest struct {
+ GUID *string `json:"eventGuid"`
+ ID *int32 `json:"eventId"`
+}
diff --git a/api/dto/response.go b/api/dto/response.go
new file mode 100644
index 0000000..43f98bd
--- /dev/null
+++ b/api/dto/response.go
@@ -0,0 +1,21 @@
+package dto
+
+import "fmt"
+
+type OkResponse struct {
+ Code int `json:"code"`
+ Data interface{} `json:"data,omitempty"`
+}
+
+type ErrorResponse struct {
+ Code int `json:"code"`
+ Message string `json:"message"`
+}
+
+func (r *OkResponse) Error() string {
+ return fmt.Sprintf("HTTP status %d", r.Code)
+}
+
+func (r *ErrorResponse) Error() string {
+ return fmt.Sprintf("HTTP status %d: %s", r.Code, r.Message)
+}
diff --git a/api/dto/schedule.go b/api/dto/schedule.go
new file mode 100644
index 0000000..0d652aa
--- /dev/null
+++ b/api/dto/schedule.go
@@ -0,0 +1,10 @@
+package dto
+
+import (
+ "time"
+)
+
+type GetScheduleResponse struct {
+ Schedule interface{} `json:"schedule"`
+ LastUpdated time.Time `json:"lastUpdated"`
+}
diff --git a/api/dto/users.go b/api/dto/users.go
new file mode 100644
index 0000000..685fa07
--- /dev/null
+++ b/api/dto/users.go
@@ -0,0 +1,20 @@
+package dto
+
+type RegisterRequest struct {
+ Username string `json:"username" validate:"required"`
+ Password string `json:"password" validate:"required"`
+}
+
+type RegisterResponse struct {
+ ID int32 `json:"id"`
+}
+
+type LoginRequest struct {
+ Username string `json:"username" validate:"required"`
+ Password string `json:"password" validate:"required"`
+}
+
+type LoginResponse struct {
+ ID int32 `json:"id"`
+ Username string `json:"username"`
+}