Split transactions and assignments export into two endpoints
This commit is contained in:
@ -67,7 +67,8 @@ func (h *Handler) LoadRoutes(router *gin.Engine) {
|
||||
authenticated.GET("/budget/:budgetid/autocomplete/categories", h.autocompleteCategories)
|
||||
authenticated.DELETE("/budget/:budgetid", h.deleteBudget)
|
||||
authenticated.POST("/budget/:budgetid/import/ynab", h.importYNAB)
|
||||
authenticated.POST("/budget/:budgetid/export/ynab", h.exportYNAB)
|
||||
authenticated.POST("/budget/:budgetid/export/ynab/transactions", h.exportYNABTransactions)
|
||||
authenticated.POST("/budget/:budgetid/export/ynab/assignments", h.exportYNABAssignments)
|
||||
authenticated.POST("/budget/:budgetid/settings/clear", h.clearBudget)
|
||||
|
||||
budget := authenticated.Group("/budget")
|
||||
|
@ -64,7 +64,7 @@ func (h *Handler) importYNAB(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handler) exportYNAB(c *gin.Context) {
|
||||
func (h *Handler) exportYNABTransactions(c *gin.Context) {
|
||||
budgetID, succ := c.Params.Get("budgetid")
|
||||
if !succ {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"no budget_id specified"})
|
||||
@ -88,6 +88,26 @@ func (h *Handler) exportYNAB(c *gin.Context) {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handler) exportYNABAssignments(c *gin.Context) {
|
||||
budgetID, succ := c.Params.Get("budgetid")
|
||||
if !succ {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"no budget_id specified"})
|
||||
return
|
||||
}
|
||||
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if !succ {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
ynab, err := postgres.NewYNABExport(c.Request.Context(), h.Service.Queries, budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
err = ynab.ExportAssignments(c.Request.Context(), c.Writer)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user