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

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

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

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

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

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

	for the filter v1 post operation.

	Typically these are written to a http.Request.
*/
type FilterV1PostParams 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

	/* 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 post params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *FilterV1PostParams) WithDefaults() *FilterV1PostParams {
	o.SetDefaults()
	return o
}

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

		wholeWordDefault = bool(false)
	)

	val := FilterV1PostParams{
		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 post params
func (o *FilterV1PostParams) WithTimeout(timeout time.Duration) *FilterV1PostParams {
	o.SetTimeout(timeout)
	return o
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// WriteToRequest writes these params to a swagger request
func (o *FilterV1PostParams) 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
			}
		}
	}

	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
}

// bindParamFilterV1Post binds the parameter context[]
func (o *FilterV1PostParams) 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
}
