upvotes
This commit is contained in:
@@ -30,7 +30,7 @@ func NewUpvoteFeedback(ctx *middleware.Context, handler UpvoteFeedbackHandler) *
|
||||
}
|
||||
|
||||
/*
|
||||
UpvoteFeedback swagger:route POST /feedback/{feedback_uuid}/upvote feedback upvoteFeedback
|
||||
UpvoteFeedback swagger:route POST /feedback/{feedback_uuid}/vote feedback upvoteFeedback
|
||||
|
||||
# Upvote a feedback
|
||||
|
||||
|
||||
@@ -32,6 +32,11 @@ type UpvoteFeedbackParams struct {
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: query
|
||||
*/
|
||||
Action string
|
||||
/*Feedback UUID
|
||||
Required: true
|
||||
In: path
|
||||
@@ -55,6 +60,11 @@ func (o *UpvoteFeedbackParams) BindRequest(r *http.Request, route *middleware.Ma
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
qAction, qhkAction, _ := qs.GetOK("action")
|
||||
if err := o.bindAction(qAction, qhkAction, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rFeedbackUUID, rhkFeedbackUUID, _ := route.Params.GetOK("feedback_uuid")
|
||||
if err := o.bindFeedbackUUID(rFeedbackUUID, rhkFeedbackUUID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
@@ -70,6 +80,41 @@ func (o *UpvoteFeedbackParams) BindRequest(r *http.Request, route *middleware.Ma
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindAction binds and validates parameter Action from query.
|
||||
func (o *UpvoteFeedbackParams) bindAction(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("action", "query", rawData)
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if err := validate.RequiredString("action", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
o.Action = raw
|
||||
|
||||
if err := o.validateAction(formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateAction carries on validations for parameter Action
|
||||
func (o *UpvoteFeedbackParams) validateAction(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.EnumCase("action", "query", o.Action, []interface{}{"upvote", "downvote"}, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindFeedbackUUID binds and validates parameter FeedbackUUID from path.
|
||||
func (o *UpvoteFeedbackParams) bindFeedbackUUID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
type UpvoteFeedbackURL struct {
|
||||
FeedbackUUID string
|
||||
|
||||
Action string
|
||||
SessionUUID string
|
||||
|
||||
_basePath string
|
||||
@@ -42,7 +43,7 @@ func (o *UpvoteFeedbackURL) SetBasePath(bp string) {
|
||||
func (o *UpvoteFeedbackURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/feedback/{feedback_uuid}/upvote"
|
||||
var _path = "/feedback/{feedback_uuid}/vote"
|
||||
|
||||
feedbackUUID := o.FeedbackUUID
|
||||
if feedbackUUID != "" {
|
||||
@@ -59,6 +60,11 @@ func (o *UpvoteFeedbackURL) Build() (*url.URL, error) {
|
||||
|
||||
qs := make(url.Values)
|
||||
|
||||
actionQ := o.Action
|
||||
if actionQ != "" {
|
||||
qs.Set("action", actionQ)
|
||||
}
|
||||
|
||||
sessionUUIDQ := o.SessionUUID
|
||||
if sessionUUIDQ != "" {
|
||||
qs.Set("session_uuid", sessionUUIDQ)
|
||||
|
||||
@@ -292,7 +292,7 @@ func (o *GeraldAPI) initHandlerCache() {
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/feedback/{feedback_uuid}/upvote"] = feedback.NewUpvoteFeedback(o.context, o.FeedbackUpvoteFeedbackHandler)
|
||||
o.handlers["POST"]["/feedback/{feedback_uuid}/vote"] = feedback.NewUpvoteFeedback(o.context, o.FeedbackUpvoteFeedbackHandler)
|
||||
}
|
||||
|
||||
// Serve creates a http handler to serve the API over HTTP
|
||||
|
||||
Reference in New Issue
Block a user