in api.go [238:258]
func (h apiHandlers) postOrder(c *gin.Context) {
type line struct {
ID int `json:"id" binding:"required"`
Amount int `json:"amount" binding:"required"`
}
var order struct {
CustomerID int `json:"customer_id" binding:"required"`
Lines []line `json:"lines" binding:"required"`
}
if err := c.BindJSON(&order); err != nil {
return
}
lines := make([]ProductOrderLine, len(order.Lines))
for i, line := range order.Lines {
lines[i] = ProductOrderLine{
Product: Product{ID: line.ID},
Amount: line.Amount,
}
}
h.postOrderCommon(c, order.CustomerID, lines)
}