// 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"
)

// NewGetCarstateParams creates a new GetCarstateParams 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 NewGetCarstateParams() *GetCarstateParams {
	return &GetCarstateParams{
		timeout: cr.DefaultTimeout,
	}
}

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

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

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

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

	for the get carstate operation.

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

	/* Vin.

	   Car vin
	*/
	Vin *string

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

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

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

// WithTimeout adds the timeout to the get carstate params
func (o *GetCarstateParams) WithTimeout(timeout time.Duration) *GetCarstateParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the get carstate params
func (o *GetCarstateParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the get carstate params
func (o *GetCarstateParams) WithContext(ctx context.Context) *GetCarstateParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the get carstate params
func (o *GetCarstateParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the get carstate params
func (o *GetCarstateParams) WithHTTPClient(client *http.Client) *GetCarstateParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the get carstate params
func (o *GetCarstateParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithVin adds the vin to the get carstate params
func (o *GetCarstateParams) WithVin(vin *string) *GetCarstateParams {
	o.SetVin(vin)
	return o
}

// SetVin adds the vin to the get carstate params
func (o *GetCarstateParams) SetVin(vin *string) {
	o.Vin = vin
}

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

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

	if o.Vin != nil {

		// query param vin
		var qrVin string

		if o.Vin != nil {
			qrVin = *o.Vin
		}
		qVin := qrVin
		if qVin != "" {

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

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