// Code generated by go-swagger; DO NOT EDIT.

package operations

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"
	"net/http"
	"time"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/runtime"
	cr "github.com/go-openapi/runtime/client"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// NewGetEcuStatsVinDbcParams creates a new GetEcuStatsVinDbcParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewGetEcuStatsVinDbcParams() *GetEcuStatsVinDbcParams {
	return &GetEcuStatsVinDbcParams{
		timeout: cr.DefaultTimeout,
	}
}

// NewGetEcuStatsVinDbcParamsWithTimeout creates a new GetEcuStatsVinDbcParams object
// with the ability to set a timeout on a request.
func NewGetEcuStatsVinDbcParamsWithTimeout(timeout time.Duration) *GetEcuStatsVinDbcParams {
	return &GetEcuStatsVinDbcParams{
		timeout: timeout,
	}
}

// NewGetEcuStatsVinDbcParamsWithContext creates a new GetEcuStatsVinDbcParams object
// with the ability to set a context for a request.
func NewGetEcuStatsVinDbcParamsWithContext(ctx context.Context) *GetEcuStatsVinDbcParams {
	return &GetEcuStatsVinDbcParams{
		Context: ctx,
	}
}

// NewGetEcuStatsVinDbcParamsWithHTTPClient creates a new GetEcuStatsVinDbcParams object
// with the ability to set a custom HTTPClient for a request.
func NewGetEcuStatsVinDbcParamsWithHTTPClient(client *http.Client) *GetEcuStatsVinDbcParams {
	return &GetEcuStatsVinDbcParams{
		HTTPClient: client,
	}
}

/*
GetEcuStatsVinDbcParams contains all the parameters to send to the API endpoint

	for the get ecu stats vin dbc operation.

	Typically these are written to a http.Request.
*/
type GetEcuStatsVinDbcParams struct {

	/* Dbc.

	   DBC hash
	*/
	Dbc string

	/* Ecus.

	   ECU names
	*/
	Ecus []string

	/* Hours.

	   Past hours  that must be included into the request
	*/
	Hours int64

	/* MinOutOfRangePct.

	   Minimum out of range percent
	*/
	MinOutOfRangePct int64

	/* MinZeroPct.

	   Minimum zero values percent
	*/
	MinZeroPct float64

	/* Vin.

	   VIN
	*/
	Vin string

	timeout    time.Duration
	Context    context.Context
	HTTPClient *http.Client
}

// WithDefaults hydrates default values in the get ecu stats vin dbc params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetEcuStatsVinDbcParams) WithDefaults() *GetEcuStatsVinDbcParams {
	o.SetDefaults()
	return o
}

// SetDefaults hydrates default values in the get ecu stats vin dbc params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetEcuStatsVinDbcParams) SetDefaults() {
	// no default values defined for this parameter
}

// WithTimeout adds the timeout to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) WithTimeout(timeout time.Duration) *GetEcuStatsVinDbcParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) WithContext(ctx context.Context) *GetEcuStatsVinDbcParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) WithHTTPClient(client *http.Client) *GetEcuStatsVinDbcParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithDbc adds the dbc to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) WithDbc(dbc string) *GetEcuStatsVinDbcParams {
	o.SetDbc(dbc)
	return o
}

// SetDbc adds the dbc to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) SetDbc(dbc string) {
	o.Dbc = dbc
}

// WithEcus adds the ecus to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) WithEcus(ecus []string) *GetEcuStatsVinDbcParams {
	o.SetEcus(ecus)
	return o
}

// SetEcus adds the ecus to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) SetEcus(ecus []string) {
	o.Ecus = ecus
}

// WithHours adds the hours to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) WithHours(hours int64) *GetEcuStatsVinDbcParams {
	o.SetHours(hours)
	return o
}

// SetHours adds the hours to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) SetHours(hours int64) {
	o.Hours = hours
}

// WithMinOutOfRangePct adds the minOutOfRangePct to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) WithMinOutOfRangePct(minOutOfRangePct int64) *GetEcuStatsVinDbcParams {
	o.SetMinOutOfRangePct(minOutOfRangePct)
	return o
}

// SetMinOutOfRangePct adds the minOutOfRangePct to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) SetMinOutOfRangePct(minOutOfRangePct int64) {
	o.MinOutOfRangePct = minOutOfRangePct
}

// WithMinZeroPct adds the minZeroPct to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) WithMinZeroPct(minZeroPct float64) *GetEcuStatsVinDbcParams {
	o.SetMinZeroPct(minZeroPct)
	return o
}

// SetMinZeroPct adds the minZeroPct to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) SetMinZeroPct(minZeroPct float64) {
	o.MinZeroPct = minZeroPct
}

// WithVin adds the vin to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) WithVin(vin string) *GetEcuStatsVinDbcParams {
	o.SetVin(vin)
	return o
}

// SetVin adds the vin to the get ecu stats vin dbc params
func (o *GetEcuStatsVinDbcParams) SetVin(vin string) {
	o.Vin = vin
}

// WriteToRequest writes these params to a swagger request
func (o *GetEcuStatsVinDbcParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {

	if err := r.SetTimeout(o.timeout); err != nil {
		return err
	}
	var res []error

	// path param dbc
	if err := r.SetPathParam("dbc", o.Dbc); err != nil {
		return err
	}

	if o.Ecus != nil {

		// binding items for ecus
		joinedEcus := o.bindParamEcus(reg)

		// query array param ecus
		if err := r.SetQueryParam("ecus", joinedEcus...); err != nil {
			return err
		}
	}

	// query param hours
	qrHours := o.Hours
	qHours := swag.FormatInt64(qrHours)
	if qHours != "" {

		if err := r.SetQueryParam("hours", qHours); err != nil {
			return err
		}
	}

	// query param min_out_of_range_pct
	qrMinOutOfRangePct := o.MinOutOfRangePct
	qMinOutOfRangePct := swag.FormatInt64(qrMinOutOfRangePct)
	if qMinOutOfRangePct != "" {

		if err := r.SetQueryParam("min_out_of_range_pct", qMinOutOfRangePct); err != nil {
			return err
		}
	}

	// query param min_zero_pct
	qrMinZeroPct := o.MinZeroPct
	qMinZeroPct := swag.FormatFloat64(qrMinZeroPct)
	if qMinZeroPct != "" {

		if err := r.SetQueryParam("min_zero_pct", qMinZeroPct); err != nil {
			return err
		}
	}

	// path param vin
	if err := r.SetPathParam("vin", o.Vin); err != nil {
		return err
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

// bindParamGetEcuStatsVinDbc binds the parameter ecus
func (o *GetEcuStatsVinDbcParams) bindParamEcus(formats strfmt.Registry) []string {
	ecusIR := o.Ecus

	var ecusIC []string
	for _, ecusIIR := range ecusIR { // explode []string

		ecusIIV := ecusIIR // string as string
		ecusIC = append(ecusIC, ecusIIV)
	}

	// items.CollectionFormat: ""
	ecusIS := swag.JoinByFormat(ecusIC, "")

	return ecusIS
}
