[BREAKING] Bump à version 3 #15

Merged
vlbeaudoin merged 5 commits from breaking/remove-membre-route into main 2023-06-08 21:11:28 -04:00
3 changed files with 0 additions and 68 deletions
Showing only changes of commit 5915e3ca7b - Show all commits

View file

@ -59,8 +59,6 @@ var apiCmd = &cobra.Command{
e.GET("/v2/health/", handlers.GetHealth) e.GET("/v2/health/", handlers.GetHealth)
e.GET("/v2/membres/:membre_id/", handlers.GetMembre)
e.GET("/v2/transactions/", handlers.GetTransactions) e.GET("/v2/transactions/", handlers.GetTransactions)
e.POST("/v2/transactions/", handlers.PostTransactions) e.POST("/v2/transactions/", handlers.PostTransactions)

View file

@ -1,56 +0,0 @@
package handlers
import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/spf13/viper"
"git.agecem.com/agecem/bottin-agenda/responses"
bottindata "git.agecem.com/agecem/bottin/v5/data"
)
func GetMembre(c echo.Context) error {
bottinApiKey := viper.GetString("bottin.api.key")
bottinApiHost := viper.GetString("bottin.api.host")
bottinApiProtocol := viper.GetString("bottin.api.protocol")
bottinApiPort := viper.GetInt("bottin.api.port")
// Using bottin's API client
bottinConnection := bottindata.NewApiClient(
bottinApiKey,
bottinApiHost,
bottinApiProtocol,
bottinApiPort,
)
membreID := c.Param("membre_id")
getMembreResponse := responses.GetMembreResponse{}
membre, err := bottinConnection.GetMembre(membreID)
if err != nil {
getMembreResponse.Message = err.Error()
var statusCode int
switch err.Error() {
case "Veuillez fournir un numéro étudiant à rechercher":
statusCode = http.StatusBadRequest
case "Ce numéro étudiant ne correspond à aucunE membre":
statusCode = http.StatusNotFound
default:
statusCode = http.StatusInternalServerError
}
getMembreResponse.Data.Membre = membre
return c.JSON(statusCode, getMembreResponse)
}
getMembreResponse.Data.Membre = membre
getMembreResponse.Message = "Read successful"
return c.JSON(http.StatusOK, getMembreResponse)
}

View file

@ -2,22 +2,12 @@ package responses
import ( import (
"git.agecem.com/agecem/bottin-agenda/models" "git.agecem.com/agecem/bottin-agenda/models"
bottinmodels "git.agecem.com/agecem/bottin/v5/models"
) )
type PostSeedResponse struct { type PostSeedResponse struct {
Message string `json:"message"` Message string `json:"message"`
} }
type GetMembreResponseData struct {
Membre bottinmodels.Membre `json:"membre"`
}
type GetMembreResponse struct {
Message string `json:"message"`
Data GetMembreResponseData `json:"data"`
}
type PostTransactionsResponseData struct { type PostTransactionsResponseData struct {
Transactions []models.Transaction `json:"transactions"` Transactions []models.Transaction `json:"transactions"`
} }