// Code generated by ogen, DO NOT EDIT.

package gsn

import (
	"net/http"

	"github.com/ogen-go/ogen/middleware"
	"github.com/ogen-go/ogen/ogenerrors"
	"github.com/ogen-go/ogen/uri"
)

// PerformPredictionParams is parameters of performPrediction operation.
type PerformPredictionParams struct {
	Parameters OptPredictionParameters
}

func unpackPerformPredictionParams(packed middleware.Parameters) (params PerformPredictionParams) {
	{
		key := middleware.ParameterKey{
			Name: "parameters",
			In:   "query",
		}
		if v, ok := packed[key]; ok {
			params.Parameters = v.(OptPredictionParameters)
		}
	}
	return params
}

func decodePerformPredictionParams(args [0]string, argsEscaped bool, r *http.Request) (params PerformPredictionParams, _ error) {
	q := uri.NewQueryDecoder(r.URL.Query())
	// Decode query: parameters.
	if err := func() error {
		cfg := uri.QueryParameterDecodingConfig{
			Name:    "parameters",
			Style:   uri.QueryStyleForm,
			Explode: true,
			Fields:  []uri.QueryParameterObjectField{{Name: "launch_latitude", Required: false}, {Name: "launch_longitude", Required: false}, {Name: "launch_datetime", Required: false}, {Name: "launch_altitude", Required: false}, {Name: "profile", Required: false}, {Name: "ascent_rate", Required: false}, {Name: "burst_altitude", Required: false}, {Name: "descent_rate", Required: false}, {Name: "float_altitude", Required: false}, {Name: "stop_datetime", Required: false}, {Name: "ascent_curve", Required: false}, {Name: "descent_curve", Required: false}, {Name: "interpolate", Required: false}, {Name: "format", Required: false}, {Name: "dataset", Required: false}},
		}

		if err := q.HasParam(cfg); err == nil {
			if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
				var paramsDotParametersVal PredictionParameters
				if err := func() error {
					return paramsDotParametersVal.DecodeURI(d)
				}(); err != nil {
					return err
				}
				params.Parameters.SetTo(paramsDotParametersVal)
				return nil
			}); err != nil {
				return err
			}
			if err := func() error {
				if value, ok := params.Parameters.Get(); ok {
					if err := func() error {
						if err := value.Validate(); err != nil {
							return err
						}
						return nil
					}(); err != nil {
						return err
					}
				}
				return nil
			}(); err != nil {
				return err
			}
		}
		return nil
	}(); err != nil {
		return params, &ogenerrors.DecodeParamError{
			Name: "parameters",
			In:   "query",
			Err:  err,
		}
	}
	return params, nil
}
