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

package notifications

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

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

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

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

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

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

	for the notifications operation.

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

	/* ExcludeTypes.

	   Types of notifications to exclude.
	*/
	ExcludeTypes []string

	/* Limit.

	   Number of notifications to return.

	   Default: 20
	*/
	Limit *int64

	/* MaxID.

	   Return only notifications *OLDER* than the given max notification ID. The notification with the specified ID will not be included in the response.
	*/
	MaxID *string

	/* MinID.

	   Return only notifications *immediately newer* than the given since notification ID. The notification with the specified ID will not be included in the response.
	*/
	MinID *string

	/* SinceID.

	   Return only notifications *newer* than the given since notification ID. The notification with the specified ID will not be included in the response.
	*/
	SinceID *string

	/* Types.

	   Types of notifications to include. If not provided, all notification types will be included.
	*/
	Types []string

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

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

// SetDefaults hydrates default values in the notifications params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *NotificationsParams) SetDefaults() {
	var (
		limitDefault = int64(20)
	)

	val := NotificationsParams{
		Limit: &limitDefault,
	}

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

// WithTimeout adds the timeout to the notifications params
func (o *NotificationsParams) WithTimeout(timeout time.Duration) *NotificationsParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the notifications params
func (o *NotificationsParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the notifications params
func (o *NotificationsParams) WithContext(ctx context.Context) *NotificationsParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the notifications params
func (o *NotificationsParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

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

// SetHTTPClient adds the HTTPClient to the notifications params
func (o *NotificationsParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithExcludeTypes adds the excludeTypes to the notifications params
func (o *NotificationsParams) WithExcludeTypes(excludeTypes []string) *NotificationsParams {
	o.SetExcludeTypes(excludeTypes)
	return o
}

// SetExcludeTypes adds the excludeTypes to the notifications params
func (o *NotificationsParams) SetExcludeTypes(excludeTypes []string) {
	o.ExcludeTypes = excludeTypes
}

// WithLimit adds the limit to the notifications params
func (o *NotificationsParams) WithLimit(limit *int64) *NotificationsParams {
	o.SetLimit(limit)
	return o
}

// SetLimit adds the limit to the notifications params
func (o *NotificationsParams) SetLimit(limit *int64) {
	o.Limit = limit
}

// WithMaxID adds the maxID to the notifications params
func (o *NotificationsParams) WithMaxID(maxID *string) *NotificationsParams {
	o.SetMaxID(maxID)
	return o
}

// SetMaxID adds the maxId to the notifications params
func (o *NotificationsParams) SetMaxID(maxID *string) {
	o.MaxID = maxID
}

// WithMinID adds the minID to the notifications params
func (o *NotificationsParams) WithMinID(minID *string) *NotificationsParams {
	o.SetMinID(minID)
	return o
}

// SetMinID adds the minId to the notifications params
func (o *NotificationsParams) SetMinID(minID *string) {
	o.MinID = minID
}

// WithSinceID adds the sinceID to the notifications params
func (o *NotificationsParams) WithSinceID(sinceID *string) *NotificationsParams {
	o.SetSinceID(sinceID)
	return o
}

// SetSinceID adds the sinceId to the notifications params
func (o *NotificationsParams) SetSinceID(sinceID *string) {
	o.SinceID = sinceID
}

// WithTypes adds the types to the notifications params
func (o *NotificationsParams) WithTypes(types []string) *NotificationsParams {
	o.SetTypes(types)
	return o
}

// SetTypes adds the types to the notifications params
func (o *NotificationsParams) SetTypes(types []string) {
	o.Types = types
}

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

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

	if o.ExcludeTypes != nil {

		// binding items for exclude_types[]
		joinedExcludeTypes := o.bindParamExcludeTypes(reg)

		// query array param exclude_types[]
		if err := r.SetQueryParam("exclude_types[]", joinedExcludeTypes...); 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.MaxID != nil {

		// query param max_id
		var qrMaxID string

		if o.MaxID != nil {
			qrMaxID = *o.MaxID
		}
		qMaxID := qrMaxID
		if qMaxID != "" {

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

	if o.MinID != nil {

		// query param min_id
		var qrMinID string

		if o.MinID != nil {
			qrMinID = *o.MinID
		}
		qMinID := qrMinID
		if qMinID != "" {

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

	if o.SinceID != nil {

		// query param since_id
		var qrSinceID string

		if o.SinceID != nil {
			qrSinceID = *o.SinceID
		}
		qSinceID := qrSinceID
		if qSinceID != "" {

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

	if o.Types != nil {

		// binding items for types[]
		joinedTypes := o.bindParamTypes(reg)

		// query array param types[]
		if err := r.SetQueryParam("types[]", joinedTypes...); err != nil {
			return err
		}
	}

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

// bindParamNotifications binds the parameter exclude_types[]
func (o *NotificationsParams) bindParamExcludeTypes(formats strfmt.Registry) []string {
	excludeTypesIR := o.ExcludeTypes

	var excludeTypesIC []string
	for _, excludeTypesIIR := range excludeTypesIR { // explode []string

		excludeTypesIIV := excludeTypesIIR // string as string
		excludeTypesIC = append(excludeTypesIC, excludeTypesIIV)
	}

	// items.CollectionFormat: ""
	excludeTypesIS := swag.JoinByFormat(excludeTypesIC, "")

	return excludeTypesIS
}

// bindParamNotifications binds the parameter types[]
func (o *NotificationsParams) bindParamTypes(formats strfmt.Registry) []string {
	typesIR := o.Types

	var typesIC []string
	for _, typesIIR := range typesIR { // explode []string

		typesIIV := typesIIR // string as string
		typesIC = append(typesIC, typesIIV)
	}

	// items.CollectionFormat: ""
	typesIS := swag.JoinByFormat(typesIC, "")

	return typesIS
}
