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

package filters

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

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

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

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

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

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

	for the filter v1 put operation.

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

	/* FilterContext.

	     The contexts in which the filter should be applied.

	Sample: home, public
	*/
	FilterContext []string

	/* ExpiresIn.

	     Number of seconds from now that the filter should expire. If omitted, filter never expires.

	Sample: 86400
	*/
	ExpiresIn *float64

	/* ID.

	   ID of the filter.
	*/
	ID string

	/* Irreversible.

	     Should matching entities be removed from the user's timelines/views, instead of hidden? Not supported yet.

	Sample: false
	*/
	Irreversible *bool

	/* Phrase.

	     The text to be filtered.

	Sample: fnord
	*/
	Phrase string

	/* WholeWord.

	     Should the filter consider word boundaries?

	Sample: true
	*/
	WholeWord *bool

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

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

// SetDefaults hydrates default values in the filter v1 put params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *FilterV1PutParams) SetDefaults() {
	var (
		irreversibleDefault = bool(false)

		wholeWordDefault = bool(false)
	)

	val := FilterV1PutParams{
		Irreversible: &irreversibleDefault,
		WholeWord:    &wholeWordDefault,
	}

	val.timeout = o.timeout
	val.Context = o.Context
	val.HTTPClient = o.HTTPClient
	*o = val
}

// WithTimeout adds the timeout to the filter v1 put params
func (o *FilterV1PutParams) WithTimeout(timeout time.Duration) *FilterV1PutParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the filter v1 put params
func (o *FilterV1PutParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the filter v1 put params
func (o *FilterV1PutParams) WithContext(ctx context.Context) *FilterV1PutParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the filter v1 put params
func (o *FilterV1PutParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the filter v1 put params
func (o *FilterV1PutParams) WithHTTPClient(client *http.Client) *FilterV1PutParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the filter v1 put params
func (o *FilterV1PutParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithFilterContext adds the filter context to the filter v1 put params
func (o *FilterV1PutParams) WithFilterContext(context []string) *FilterV1PutParams {
	o.SetFilterContext(context)
	return o
}

// SetFilterContext adds the filter context to the filter v1 put params
func (o *FilterV1PutParams) SetFilterContext(context []string) {
	o.FilterContext = context
}

// WithExpiresIn adds the expiresIn to the filter v1 put params
func (o *FilterV1PutParams) WithExpiresIn(expiresIn *float64) *FilterV1PutParams {
	o.SetExpiresIn(expiresIn)
	return o
}

// SetExpiresIn adds the expiresIn to the filter v1 put params
func (o *FilterV1PutParams) SetExpiresIn(expiresIn *float64) {
	o.ExpiresIn = expiresIn
}

// WithID adds the id to the filter v1 put params
func (o *FilterV1PutParams) WithID(id string) *FilterV1PutParams {
	o.SetID(id)
	return o
}

// SetID adds the id to the filter v1 put params
func (o *FilterV1PutParams) SetID(id string) {
	o.ID = id
}

// WithIrreversible adds the irreversible to the filter v1 put params
func (o *FilterV1PutParams) WithIrreversible(irreversible *bool) *FilterV1PutParams {
	o.SetIrreversible(irreversible)
	return o
}

// SetIrreversible adds the irreversible to the filter v1 put params
func (o *FilterV1PutParams) SetIrreversible(irreversible *bool) {
	o.Irreversible = irreversible
}

// WithPhrase adds the phrase to the filter v1 put params
func (o *FilterV1PutParams) WithPhrase(phrase string) *FilterV1PutParams {
	o.SetPhrase(phrase)
	return o
}

// SetPhrase adds the phrase to the filter v1 put params
func (o *FilterV1PutParams) SetPhrase(phrase string) {
	o.Phrase = phrase
}

// WithWholeWord adds the wholeWord to the filter v1 put params
func (o *FilterV1PutParams) WithWholeWord(wholeWord *bool) *FilterV1PutParams {
	o.SetWholeWord(wholeWord)
	return o
}

// SetWholeWord adds the wholeWord to the filter v1 put params
func (o *FilterV1PutParams) SetWholeWord(wholeWord *bool) {
	o.WholeWord = wholeWord
}

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

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

	if o.Context != nil {

		// binding items for context[]
		joinedContext := o.bindParamContext(reg)

		// form array param context[]
		if err := r.SetFormParam("context[]", joinedContext...); err != nil {
			return err
		}
	}

	if o.ExpiresIn != nil {

		// form param expires_in
		var frExpiresIn float64
		if o.ExpiresIn != nil {
			frExpiresIn = *o.ExpiresIn
		}
		fExpiresIn := swag.FormatFloat64(frExpiresIn)
		if fExpiresIn != "" {
			if err := r.SetFormParam("expires_in", fExpiresIn); err != nil {
				return err
			}
		}
	}

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

	if o.Irreversible != nil {

		// form param irreversible
		var frIrreversible bool
		if o.Irreversible != nil {
			frIrreversible = *o.Irreversible
		}
		fIrreversible := swag.FormatBool(frIrreversible)
		if fIrreversible != "" {
			if err := r.SetFormParam("irreversible", fIrreversible); err != nil {
				return err
			}
		}
	}

	// form param phrase
	frPhrase := o.Phrase
	fPhrase := frPhrase
	if fPhrase != "" {
		if err := r.SetFormParam("phrase", fPhrase); err != nil {
			return err
		}
	}

	if o.WholeWord != nil {

		// form param whole_word
		var frWholeWord bool
		if o.WholeWord != nil {
			frWholeWord = *o.WholeWord
		}
		fWholeWord := swag.FormatBool(frWholeWord)
		if fWholeWord != "" {
			if err := r.SetFormParam("whole_word", fWholeWord); err != nil {
				return err
			}
		}
	}

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

// bindParamFilterV1Put binds the parameter context[]
func (o *FilterV1PutParams) bindParamContext(formats strfmt.Registry) []string {
	contextIR := o.FilterContext

	var contextIC []string
	for _, contextIIR := range contextIR { // explode []string

		contextIIV := contextIIR // string as string
		contextIC = append(contextIC, contextIIV)
	}

	// items.CollectionFormat: "multi"
	contextIS := swag.JoinByFormat(contextIC, "multi")

	return contextIS
}
