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

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

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

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

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

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

	for the get apicalls operation.

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

	/* From.

	   Date before requests which client is looking for
	*/
	From *string

	/* Limit.

	   Max number of records
	*/
	Limit *int64

	/* Offset.

	   Records offset
	*/
	Offset *int64

	/* Order.

	   Sort on column with asc or desc
	*/
	Order *string

	/* Search.

	   Text search
	*/
	Search *string

	/* To.

	   Date after requests which client is looking for
	*/
	To *string

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

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

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

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

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

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

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

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

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

// WithFrom adds the from to the get apicalls params
func (o *GetApicallsParams) WithFrom(from *string) *GetApicallsParams {
	o.SetFrom(from)
	return o
}

// SetFrom adds the from to the get apicalls params
func (o *GetApicallsParams) SetFrom(from *string) {
	o.From = from
}

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

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

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

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

// WithOrder adds the order to the get apicalls params
func (o *GetApicallsParams) WithOrder(order *string) *GetApicallsParams {
	o.SetOrder(order)
	return o
}

// SetOrder adds the order to the get apicalls params
func (o *GetApicallsParams) SetOrder(order *string) {
	o.Order = order
}

// WithSearch adds the search to the get apicalls params
func (o *GetApicallsParams) WithSearch(search *string) *GetApicallsParams {
	o.SetSearch(search)
	return o
}

// SetSearch adds the search to the get apicalls params
func (o *GetApicallsParams) SetSearch(search *string) {
	o.Search = search
}

// WithTo adds the to to the get apicalls params
func (o *GetApicallsParams) WithTo(to *string) *GetApicallsParams {
	o.SetTo(to)
	return o
}

// SetTo adds the to to the get apicalls params
func (o *GetApicallsParams) SetTo(to *string) {
	o.To = to
}

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

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

	if o.From != nil {

		// query param from
		var qrFrom string

		if o.From != nil {
			qrFrom = *o.From
		}
		qFrom := qrFrom
		if qFrom != "" {

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

	if o.Limit != nil {

		// query param limit
		var qrLimit int64

		if o.Limit != nil {
			qrLimit = *o.Limit
		}
		qLimit := swag.FormatInt64(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 := swag.FormatInt64(qrOffset)
		if qOffset != "" {

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

	if o.Order != nil {

		// query param order
		var qrOrder string

		if o.Order != nil {
			qrOrder = *o.Order
		}
		qOrder := qrOrder
		if qOrder != "" {

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

	if o.Search != nil {

		// query param search
		var qrSearch string

		if o.Search != nil {
			qrSearch = *o.Search
		}
		qSearch := qrSearch
		if qSearch != "" {

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

	if o.To != nil {

		// query param to
		var qrTo string

		if o.To != nil {
			qrTo = *o.To
		}
		qTo := qrTo
		if qTo != "" {

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

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