// 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 company_products

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

// NewGetCompanyProductsParams creates a new GetCompanyProductsParams 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 NewGetCompanyProductsParams() *GetCompanyProductsParams {
	return NewGetCompanyProductsParamsWithTimeout(cr.DefaultTimeout)
}

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

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

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

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

	for the get company products operation.

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

	// AccountID.
	//
	// Record Id of an Account
	AccountID *string

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

	// CompanyProductID.
	//
	// CompanyProduct record ID
	CompanyProductID *string

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

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

	// Slug.
	//
	// The Slug of this Object
	Slug *string

	HTTPClient *http.Client

	inner innerParams
}

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

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

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

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

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

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

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

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

// WithAccountID adds the accountID to the get company products params.
func (o *GetCompanyProductsParams) WithAccountID(accountID *string) *GetCompanyProductsParams {
	o.SetAccountID(accountID)
	return o
}

// SetAccountID adds the accountId to the get company products params.
func (o *GetCompanyProductsParams) SetAccountID(accountID *string) {
	o.AccountID = accountID
}

// WithActive adds the active to the get company products params.
func (o *GetCompanyProductsParams) WithActive(active *bool) *GetCompanyProductsParams {
	o.SetActive(active)
	return o
}

// SetActive adds the active to the get company products params.
func (o *GetCompanyProductsParams) SetActive(active *bool) {
	o.Active = active
}

// WithCompanyProductID adds the companyProductID to the get company products params.
func (o *GetCompanyProductsParams) WithCompanyProductID(companyProductID *string) *GetCompanyProductsParams {
	o.SetCompanyProductID(companyProductID)
	return o
}

// SetCompanyProductID adds the companyProductId to the get company products params.
func (o *GetCompanyProductsParams) SetCompanyProductID(companyProductID *string) {
	o.CompanyProductID = companyProductID
}

// WithLimit adds the limit to the get company products params.
func (o *GetCompanyProductsParams) WithLimit(limit *int64) *GetCompanyProductsParams {
	o.SetLimit(limit)
	return o
}

// SetLimit adds the limit to the get company products params.
func (o *GetCompanyProductsParams) SetLimit(limit *int64) {
	o.Limit = limit
}

// WithOffset adds the offset to the get company products params.
func (o *GetCompanyProductsParams) WithOffset(offset *int64) *GetCompanyProductsParams {
	o.SetOffset(offset)
	return o
}

// SetOffset adds the offset to the get company products params.
func (o *GetCompanyProductsParams) SetOffset(offset *int64) {
	o.Offset = offset
}

// WithSlug adds the slug to the get company products params.
func (o *GetCompanyProductsParams) WithSlug(slug *string) *GetCompanyProductsParams {
	o.SetSlug(slug)
	return o
}

// SetSlug adds the slug to the get company products params.
func (o *GetCompanyProductsParams) SetSlug(slug *string) {
	o.Slug = slug
}

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

	if o.AccountID != nil {

		// query param accountId
		var qrAccountID string

		if o.AccountID != nil {
			qrAccountID = *o.AccountID
		}
		qAccountID := qrAccountID
		if qAccountID != "" {

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

	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.CompanyProductID != nil {

		// query param companyProductId
		var qrCompanyProductID string

		if o.CompanyProductID != nil {
			qrCompanyProductID = *o.CompanyProductID
		}
		qCompanyProductID := qrCompanyProductID
		if qCompanyProductID != "" {

			if err := r.SetQueryParam("companyProductId", qCompanyProductID); 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 o.Slug != nil {

		// query param slug
		var qrSlug string

		if o.Slug != nil {
			qrSlug = *o.Slug
		}
		qSlug := qrSlug
		if qSlug != "" {

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

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