You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
151 lines
3.7 KiB
151 lines
3.7 KiB
// Code generated by go-swagger; DO NOT EDIT.
|
|
|
|
package credit_management
|
|
|
|
// This file was generated by the swagger tool.
|
|
// Editing this file might prove futile when you re-run the swagger generate command
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/go-openapi/errors"
|
|
"github.com/go-openapi/runtime"
|
|
"github.com/go-openapi/runtime/middleware"
|
|
"github.com/go-openapi/strfmt"
|
|
"github.com/go-openapi/swag"
|
|
"github.com/go-openapi/validate"
|
|
)
|
|
|
|
// NewAddConsumptionParams creates a new AddConsumptionParams object
|
|
// no default values defined in spec.
|
|
func NewAddConsumptionParams() AddConsumptionParams {
|
|
|
|
return AddConsumptionParams{}
|
|
}
|
|
|
|
// AddConsumptionParams contains all the bound params for the add consumption operation
|
|
// typically these are obtained from a http.Request
|
|
//
|
|
// swagger:parameters addConsumption
|
|
type AddConsumptionParams struct {
|
|
|
|
// HTTP Request Object
|
|
HTTPRequest *http.Request `json:"-"`
|
|
|
|
/*Amount to be decreased
|
|
Required: true
|
|
In: query
|
|
*/
|
|
Amount float64
|
|
/*Id of the account to be checked
|
|
Required: true
|
|
In: path
|
|
*/
|
|
ID string
|
|
/*Medium (cash/credit) to be used in the accounting
|
|
Required: true
|
|
In: path
|
|
*/
|
|
Medium string
|
|
}
|
|
|
|
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
|
// for simple values it will use straight method calls.
|
|
//
|
|
// To ensure default values, the struct must have been initialized with NewAddConsumptionParams() beforehand.
|
|
func (o *AddConsumptionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
|
var res []error
|
|
|
|
o.HTTPRequest = r
|
|
|
|
qs := runtime.Values(r.URL.Query())
|
|
|
|
qAmount, qhkAmount, _ := qs.GetOK("amount")
|
|
if err := o.bindAmount(qAmount, qhkAmount, route.Formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
rID, rhkID, _ := route.Params.GetOK("id")
|
|
if err := o.bindID(rID, rhkID, route.Formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
rMedium, rhkMedium, _ := route.Params.GetOK("medium")
|
|
if err := o.bindMedium(rMedium, rhkMedium, route.Formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// bindAmount binds and validates parameter Amount from query.
|
|
func (o *AddConsumptionParams) bindAmount(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
|
if !hasKey {
|
|
return errors.Required("amount", "query", rawData)
|
|
}
|
|
var raw string
|
|
if len(rawData) > 0 {
|
|
raw = rawData[len(rawData)-1]
|
|
}
|
|
|
|
// Required: true
|
|
// AllowEmptyValue: false
|
|
if err := validate.RequiredString("amount", "query", raw); err != nil {
|
|
return err
|
|
}
|
|
|
|
value, err := swag.ConvertFloat64(raw)
|
|
if err != nil {
|
|
return errors.InvalidType("amount", "query", "float64", raw)
|
|
}
|
|
o.Amount = value
|
|
|
|
return nil
|
|
}
|
|
|
|
// bindID binds and validates parameter ID from path.
|
|
func (o *AddConsumptionParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
|
var raw string
|
|
if len(rawData) > 0 {
|
|
raw = rawData[len(rawData)-1]
|
|
}
|
|
|
|
// Required: true
|
|
// Parameter is provided by construction from the route
|
|
|
|
o.ID = raw
|
|
|
|
return nil
|
|
}
|
|
|
|
// bindMedium binds and validates parameter Medium from path.
|
|
func (o *AddConsumptionParams) bindMedium(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
|
var raw string
|
|
if len(rawData) > 0 {
|
|
raw = rawData[len(rawData)-1]
|
|
}
|
|
|
|
// Required: true
|
|
// Parameter is provided by construction from the route
|
|
|
|
o.Medium = raw
|
|
|
|
if err := o.validateMedium(formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// validateMedium carries on validations for parameter Medium
|
|
func (o *AddConsumptionParams) validateMedium(formats strfmt.Registry) error {
|
|
|
|
if err := validate.EnumCase("medium", "path", o.Medium, []interface{}{"credit", "cash"}, true); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|