From 742bea615e518ba4204987667255c16be7e22fb6 Mon Sep 17 00:00:00 2001 From: Viktor Patchev Date: Thu, 13 Jan 2022 19:55:38 +0100 Subject: [PATCH 1/2] Get TXS endpoint --- cmd/main.go | 1 + pkg/controllers/gettxs.go | 15 +++++++++++++++ pkg/database/models/invoice.go | 26 +++++++++++++------------- 3 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 pkg/controllers/gettxs.go diff --git a/cmd/main.go b/cmd/main.go index e09da84..7c9eb0f 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -49,6 +49,7 @@ func main() { e.POST("/create", controllers.CreateUserController{}.CreateUser) e.POST("/addinvoice", controllers.AddInvoiceController{}.AddInvoice, middleware.JWT([]byte("secret"))) e.POST("/payinvoice", controllers.PayInvoiceController{}.PayInvoice, middleware.JWT([]byte("secret"))) + e.GET("/gettxs", controllers.GetTXSController{}.GetTXS, middleware.JWT([]byte("secret"))) // Start server go func() { diff --git a/pkg/controllers/gettxs.go b/pkg/controllers/gettxs.go new file mode 100644 index 0000000..a057015 --- /dev/null +++ b/pkg/controllers/gettxs.go @@ -0,0 +1,15 @@ +package controllers + +import ( + "github.com/bumi/lndhub.go/pkg/database/models" + "github.com/labstack/echo/v4" + "net/http" +) + +// GetTXSController : GetTXSController struct +type GetTXSController struct{} + +// GetTXS : Get TXS Controller +func (GetTXSController) GetTXS(c echo.Context) error { + return c.JSON(http.StatusOK, &models.Invoice{}) +} diff --git a/pkg/database/models/invoice.go b/pkg/database/models/invoice.go index f04917c..0f618f5 100644 --- a/pkg/database/models/invoice.go +++ b/pkg/database/models/invoice.go @@ -4,17 +4,17 @@ import "time" // Invoice : Invoice Model type Invoice struct { - ID uint `gorm:"primary_key"` - Type string - UserID uint - TransactionEntryID uint - Amount uint - Memo string - DescriptionHash string - PaymentRequest string - RHash string - State string - CreatedAt time.Time - UpdatedAt time.Time - SettledAt time.Time + ID uint `gorm:"primary_key" json:"id"` + Type string `json:"type"` + UserID uint `json:"user_id"` + TransactionEntryID uint `json:"transaction_entry_id"` + Amount uint `json:"amount"` + Memo string `json:"memo"` + DescriptionHash string `json:"description_hash"` + PaymentRequest string `json:"payment_request"` + RHash string `json:"r_hash"` + State string `json:"state"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + SettledAt time.Time `json:"settled_at"` } From f61ffba5454b47dab69d66a60a3865edb7cffecb Mon Sep 17 00:00:00 2001 From: Viktor Patchev Date: Thu, 13 Jan 2022 20:02:31 +0100 Subject: [PATCH 2/2] Consistent file naming --- pkg/controllers/{gettxs.go => gettxs.ctrl.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pkg/controllers/{gettxs.go => gettxs.ctrl.go} (100%) diff --git a/pkg/controllers/gettxs.go b/pkg/controllers/gettxs.ctrl.go similarity index 100% rename from pkg/controllers/gettxs.go rename to pkg/controllers/gettxs.ctrl.go