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

// (c) 2012-2020 by Taxnexus, Inc.
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed

package contracts

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

// NewGetContractsParams creates a new GetContractsParams 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 NewGetContractsParams() *GetContractsParams {
	return NewGetContractsParamsWithTimeout(cr.DefaultTimeout)
}

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

// NewGetContractsParamsWithContext creates a new GetContractsParams object
// with the ability to set a context for a request.
//
// Deprecated: use the operation call with context to pass the context instead of [GetContractsParams].
func NewGetContractsParamsWithContext(ctx context.Context) *GetContractsParams {
	return &GetContractsParams{
		inner: innerParams{
			ctx: ctx,
		},
	}
}

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

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

	for the get contracts operation.

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

	// Active.
	//
	// Only retrieve active records?
	Active *bool

	// ContractID.
	//
	// Contact record ID
	ContractID *string

	// Limit.
	//
	// How many objects to return at one time
	//
	// Format: int64
	Limit *int64

	// Offset.
	//
	// How many objects to skip?
	//
	// Format: int64
	Offset *int64

	HTTPClient *http.Client

	inner innerParams
}

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

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

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

// SetTimeout adds the timeout to the get contracts params.
func (o *GetContractsParams) SetTimeout(timeout time.Duration) {
	o.inner.timeout = timeout
}

// WithContext adds the context to the get contracts params.
//
// Deprecated: use the operation call with context to pass the context instead of [GetContractsParams].
func (o *GetContractsParams) WithContext(ctx context.Context) *GetContractsParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the get contracts params.
//
// Deprecated: use the operation call with context to pass the context instead of [GetContractsParams].
func (o *GetContractsParams) SetContext(ctx context.Context) {
	o.inner.ctx = ctx
}

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

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

// WithActive adds the active to the get contracts params.
func (o *GetContractsParams) WithActive(active *bool) *GetContractsParams {
	o.SetActive(active)
	return o
}

// SetActive adds the active to the get contracts params.
func (o *GetContractsParams) SetActive(active *bool) {
	o.Active = active
}

// WithContractID adds the contractID to the get contracts params.
func (o *GetContractsParams) WithContractID(contractID *string) *GetContractsParams {
	o.SetContractID(contractID)
	return o
}

// SetContractID adds the contractId to the get contracts params.
func (o *GetContractsParams) SetContractID(contractID *string) {
	o.ContractID = contractID
}

// WithLimit adds the limit to the get contracts params.
func (o *GetContractsParams) WithLimit(limit *int64) *GetContractsParams {
	o.SetLimit(limit)
	return o
}

// SetLimit adds the limit to the get contracts params.
func (o *GetContractsParams) SetLimit(limit *int64) {
	o.Limit = limit
}

// WithOffset adds the offset to the get contracts params.
func (o *GetContractsParams) WithOffset(offset *int64) *GetContractsParams {
	o.SetOffset(offset)
	return o
}

// SetOffset adds the offset to the get contracts params.
func (o *GetContractsParams) SetOffset(offset *int64) {
	o.Offset = offset
}

// WriteToRequest writes these params to a [runtime.ClientRequest].
func (o *GetContractsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
	if err := r.SetTimeout(o.inner.timeout); err != nil {
		return err
	}
	var res []error

	if o.Active != nil {

		// query param active
		var qrActive bool

		if o.Active != nil {
			qrActive = *o.Active
		}
		qActive := conv.FormatBool(qrActive)
		if qActive != "" {

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

	if o.ContractID != nil {

		// query param contractId
		var qrContractID string

		if o.ContractID != nil {
			qrContractID = *o.ContractID
		}
		qContractID := qrContractID
		if qContractID != "" {

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

	if o.Limit != nil {

		// query param limit
		var qrLimit int64

		if o.Limit != nil {
			qrLimit = *o.Limit
		}
		qLimit := conv.FormatInteger(qrLimit)
		if qLimit != "" {

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

	if o.Offset != nil {

		// query param offset
		var qrOffset int64

		if o.Offset != nil {
			qrOffset = *o.Offset
		}
		qOffset := conv.FormatInteger(qrOffset)
		if qOffset != "" {

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

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