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

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

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

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

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

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

	for the filter v2 post operation.

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

	/* FilterAction.

	     The action to be taken when a status matches this filter.

	Sample: warn

	     Default: "warn"
	*/
	FilterAction *string

	/* KeywordsAttributesKeyword.

	   Keywords to be added (if not using id param) or updated (if using id param).
	*/
	KeywordsAttributesKeyword []string

	/* KeywordsAttributesWholeWord.

	   Should each keyword consider word boundaries?
	*/
	KeywordsAttributesWholeWord []bool

	/* StatusesAttributesStatusID.

	   Statuses to be added to the filter.
	*/
	StatusesAttributesStatusID []string

	/* Title.

	     The name of the filter.

	Sample: illuminati nonsense
	*/
	Title string

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

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

// SetDefaults hydrates default values in the filter v2 post params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *FilterV2PostParams) SetDefaults() {
	var (
		filterActionDefault = string("warn")
	)

	val := FilterV2PostParams{
		FilterAction: &filterActionDefault,
	}

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

// WithTimeout adds the timeout to the filter v2 post params
func (o *FilterV2PostParams) WithTimeout(timeout time.Duration) *FilterV2PostParams {
	o.SetTimeout(timeout)
	return o
}

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

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

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

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

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

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

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

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

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

// WithFilterAction adds the filterAction to the filter v2 post params
func (o *FilterV2PostParams) WithFilterAction(filterAction *string) *FilterV2PostParams {
	o.SetFilterAction(filterAction)
	return o
}

// SetFilterAction adds the filterAction to the filter v2 post params
func (o *FilterV2PostParams) SetFilterAction(filterAction *string) {
	o.FilterAction = filterAction
}

// WithKeywordsAttributesKeyword adds the keywordsAttributesKeyword to the filter v2 post params
func (o *FilterV2PostParams) WithKeywordsAttributesKeyword(keywordsAttributesKeyword []string) *FilterV2PostParams {
	o.SetKeywordsAttributesKeyword(keywordsAttributesKeyword)
	return o
}

// SetKeywordsAttributesKeyword adds the keywordsAttributesKeyword to the filter v2 post params
func (o *FilterV2PostParams) SetKeywordsAttributesKeyword(keywordsAttributesKeyword []string) {
	o.KeywordsAttributesKeyword = keywordsAttributesKeyword
}

// WithKeywordsAttributesWholeWord adds the keywordsAttributesWholeWord to the filter v2 post params
func (o *FilterV2PostParams) WithKeywordsAttributesWholeWord(keywordsAttributesWholeWord []bool) *FilterV2PostParams {
	o.SetKeywordsAttributesWholeWord(keywordsAttributesWholeWord)
	return o
}

// SetKeywordsAttributesWholeWord adds the keywordsAttributesWholeWord to the filter v2 post params
func (o *FilterV2PostParams) SetKeywordsAttributesWholeWord(keywordsAttributesWholeWord []bool) {
	o.KeywordsAttributesWholeWord = keywordsAttributesWholeWord
}

// WithStatusesAttributesStatusID adds the statusesAttributesStatusID to the filter v2 post params
func (o *FilterV2PostParams) WithStatusesAttributesStatusID(statusesAttributesStatusID []string) *FilterV2PostParams {
	o.SetStatusesAttributesStatusID(statusesAttributesStatusID)
	return o
}

// SetStatusesAttributesStatusID adds the statusesAttributesStatusId to the filter v2 post params
func (o *FilterV2PostParams) SetStatusesAttributesStatusID(statusesAttributesStatusID []string) {
	o.StatusesAttributesStatusID = statusesAttributesStatusID
}

// WithTitle adds the title to the filter v2 post params
func (o *FilterV2PostParams) WithTitle(title string) *FilterV2PostParams {
	o.SetTitle(title)
	return o
}

// SetTitle adds the title to the filter v2 post params
func (o *FilterV2PostParams) SetTitle(title string) {
	o.Title = title
}

// WriteToRequest writes these params to a swagger request
func (o *FilterV2PostParams) 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.FilterAction != nil {

		// form param filter_action
		var frFilterAction string
		if o.FilterAction != nil {
			frFilterAction = *o.FilterAction
		}
		fFilterAction := frFilterAction
		if fFilterAction != "" {
			if err := r.SetFormParam("filter_action", fFilterAction); err != nil {
				return err
			}
		}
	}

	if o.KeywordsAttributesKeyword != nil {

		// binding items for keywords_attributes[][keyword]
		joinedKeywordsAttributesKeyword := o.bindParamKeywordsAttributesKeyword(reg)

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

	if o.KeywordsAttributesWholeWord != nil {

		// binding items for keywords_attributes[][whole_word]
		joinedKeywordsAttributesWholeWord := o.bindParamKeywordsAttributesWholeWord(reg)

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

	if o.StatusesAttributesStatusID != nil {

		// binding items for statuses_attributes[][status_id]
		joinedStatusesAttributesStatusID := o.bindParamStatusesAttributesStatusID(reg)

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

	// form param title
	frTitle := o.Title
	fTitle := frTitle
	if fTitle != "" {
		if err := r.SetFormParam("title", fTitle); err != nil {
			return err
		}
	}

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

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

// bindParamFilterV2Post binds the parameter keywords_attributes[][keyword]
func (o *FilterV2PostParams) bindParamKeywordsAttributesKeyword(formats strfmt.Registry) []string {
	keywordsAttributesKeywordIR := o.KeywordsAttributesKeyword

	var keywordsAttributesKeywordIC []string
	for _, keywordsAttributesKeywordIIR := range keywordsAttributesKeywordIR { // explode []string

		keywordsAttributesKeywordIIV := keywordsAttributesKeywordIIR // string as string
		keywordsAttributesKeywordIC = append(keywordsAttributesKeywordIC, keywordsAttributesKeywordIIV)
	}

	// items.CollectionFormat: "multi"
	keywordsAttributesKeywordIS := swag.JoinByFormat(keywordsAttributesKeywordIC, "multi")

	return keywordsAttributesKeywordIS
}

// bindParamFilterV2Post binds the parameter keywords_attributes[][whole_word]
func (o *FilterV2PostParams) bindParamKeywordsAttributesWholeWord(formats strfmt.Registry) []string {
	keywordsAttributesWholeWordIR := o.KeywordsAttributesWholeWord

	var keywordsAttributesWholeWordIC []string
	for _, keywordsAttributesWholeWordIIR := range keywordsAttributesWholeWordIR { // explode []bool

		keywordsAttributesWholeWordIIV := swag.FormatBool(keywordsAttributesWholeWordIIR) // bool as string
		keywordsAttributesWholeWordIC = append(keywordsAttributesWholeWordIC, keywordsAttributesWholeWordIIV)
	}

	// items.CollectionFormat: "multi"
	keywordsAttributesWholeWordIS := swag.JoinByFormat(keywordsAttributesWholeWordIC, "multi")

	return keywordsAttributesWholeWordIS
}

// bindParamFilterV2Post binds the parameter statuses_attributes[][status_id]
func (o *FilterV2PostParams) bindParamStatusesAttributesStatusID(formats strfmt.Registry) []string {
	statusesAttributesStatusIDIR := o.StatusesAttributesStatusID

	var statusesAttributesStatusIDIC []string
	for _, statusesAttributesStatusIDIIR := range statusesAttributesStatusIDIR { // explode []string

		statusesAttributesStatusIDIIV := statusesAttributesStatusIDIIR // string as string
		statusesAttributesStatusIDIC = append(statusesAttributesStatusIDIC, statusesAttributesStatusIDIIV)
	}

	// items.CollectionFormat: "multi"
	statusesAttributesStatusIDIS := swag.JoinByFormat(statusesAttributesStatusIDIC, "multi")

	return statusesAttributesStatusIDIS
}
