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

package polls

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

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

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

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

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

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

	for the poll vote operation.

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

	/* Choices.

	   Poll choice indices on which to vote.
	*/
	Choices []int64

	/* ID.

	   Target poll ID.
	*/
	ID string

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

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

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

// WithTimeout adds the timeout to the poll vote params
func (o *PollVoteParams) WithTimeout(timeout time.Duration) *PollVoteParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the poll vote params
func (o *PollVoteParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the poll vote params
func (o *PollVoteParams) WithContext(ctx context.Context) *PollVoteParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the poll vote params
func (o *PollVoteParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the poll vote params
func (o *PollVoteParams) WithHTTPClient(client *http.Client) *PollVoteParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the poll vote params
func (o *PollVoteParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithChoices adds the choices to the poll vote params
func (o *PollVoteParams) WithChoices(choices []int64) *PollVoteParams {
	o.SetChoices(choices)
	return o
}

// SetChoices adds the choices to the poll vote params
func (o *PollVoteParams) SetChoices(choices []int64) {
	o.Choices = choices
}

// WithID adds the id to the poll vote params
func (o *PollVoteParams) WithID(id string) *PollVoteParams {
	o.SetID(id)
	return o
}

// SetID adds the id to the poll vote params
func (o *PollVoteParams) SetID(id string) {
	o.ID = id
}

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

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

	if o.Choices != nil {

		// binding items for choices
		joinedChoices := o.bindParamChoices(reg)

		// form array param choices
		if err := r.SetFormParam("choices", joinedChoices...); err != nil {
			return err
		}
	}

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

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

// bindParamPollVote binds the parameter choices
func (o *PollVoteParams) bindParamChoices(formats strfmt.Registry) []string {
	choicesIR := o.Choices

	var choicesIC []string
	for _, choicesIIR := range choicesIR { // explode []int64

		choicesIIV := swag.FormatInt64(choicesIIR) // int64 as string
		choicesIC = append(choicesIC, choicesIIV)
	}

	// items.CollectionFormat: ""
	choicesIS := swag.JoinByFormat(choicesIC, "")

	return choicesIS
}
