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

// (c) 2012-2020 by Taxnexus, Inc.
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed

package portal_access

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

// NewGetEffectiveEntitlementsParams creates a new GetEffectiveEntitlementsParams 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 NewGetEffectiveEntitlementsParams() *GetEffectiveEntitlementsParams {
	return NewGetEffectiveEntitlementsParamsWithTimeout(cr.DefaultTimeout)
}

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

// NewGetEffectiveEntitlementsParamsWithContext creates a new GetEffectiveEntitlementsParams object
// with the ability to set a context for a request.
//
// Deprecated: use the operation call with context to pass the context instead of [GetEffectiveEntitlementsParams].
func NewGetEffectiveEntitlementsParamsWithContext(ctx context.Context) *GetEffectiveEntitlementsParams {
	return &GetEffectiveEntitlementsParams{
		inner: innerParams{
			ctx: ctx,
		},
	}
}

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

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

	for the get effective entitlements operation.

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

	// EffectiveAt.
	//
	// UTC evaluation instant; defaults to the server's current instant.
	//
	// Format: date-time
	EffectiveAt *strfmt.DateTime

	// Limit.
	//
	// Format: int64
	// Default: 100
	Limit *int64

	// Offset.
	//
	// Format: int64
	Offset *int64

	// ServiceID.
	//
	// Format: uuid
	ServiceID *strfmt.UUID

	// TenantID.
	//
	// Requested tenant; Members validates the session user membership.
	//
	// Format: uuid
	TenantID *strfmt.UUID

	// UserID.
	//
	// Optional user scope; must be the actor or authorized by tenant role.
	//
	// Format: uuid
	UserID *strfmt.UUID

	HTTPClient *http.Client

	inner innerParams
}

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

// SetDefaults hydrates default values in the get effective entitlements params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetEffectiveEntitlementsParams) SetDefaults() {
	var (
		limitDefault = int64(100)

		offsetDefault = int64(0)
	)

	val := GetEffectiveEntitlementsParams{
		Limit:  &limitDefault,
		Offset: &offsetDefault,
	}

	val.inner.timeout = o.inner.timeout
	val.inner.ctx = o.inner.ctx
	val.HTTPClient = o.HTTPClient
	*o = val
}

// WithTimeout adds the timeout to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) WithTimeout(timeout time.Duration) *GetEffectiveEntitlementsParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) SetTimeout(timeout time.Duration) {
	o.inner.timeout = timeout
}

// WithContext adds the context to the get effective entitlements params.
//
// Deprecated: use the operation call with context to pass the context instead of [GetEffectiveEntitlementsParams].
func (o *GetEffectiveEntitlementsParams) WithContext(ctx context.Context) *GetEffectiveEntitlementsParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the get effective entitlements params.
//
// Deprecated: use the operation call with context to pass the context instead of [GetEffectiveEntitlementsParams].
func (o *GetEffectiveEntitlementsParams) SetContext(ctx context.Context) {
	o.inner.ctx = ctx
}

// WithHTTPClient adds the HTTPClient to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) WithHTTPClient(client *http.Client) *GetEffectiveEntitlementsParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithEffectiveAt adds the effectiveAt to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) WithEffectiveAt(effectiveAt *strfmt.DateTime) *GetEffectiveEntitlementsParams {
	o.SetEffectiveAt(effectiveAt)
	return o
}

// SetEffectiveAt adds the effectiveAt to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) SetEffectiveAt(effectiveAt *strfmt.DateTime) {
	o.EffectiveAt = effectiveAt
}

// WithLimit adds the limit to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) WithLimit(limit *int64) *GetEffectiveEntitlementsParams {
	o.SetLimit(limit)
	return o
}

// SetLimit adds the limit to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) SetLimit(limit *int64) {
	o.Limit = limit
}

// WithOffset adds the offset to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) WithOffset(offset *int64) *GetEffectiveEntitlementsParams {
	o.SetOffset(offset)
	return o
}

// SetOffset adds the offset to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) SetOffset(offset *int64) {
	o.Offset = offset
}

// WithServiceID adds the serviceID to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) WithServiceID(serviceID *strfmt.UUID) *GetEffectiveEntitlementsParams {
	o.SetServiceID(serviceID)
	return o
}

// SetServiceID adds the serviceId to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) SetServiceID(serviceID *strfmt.UUID) {
	o.ServiceID = serviceID
}

// WithTenantID adds the tenantID to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) WithTenantID(tenantID *strfmt.UUID) *GetEffectiveEntitlementsParams {
	o.SetTenantID(tenantID)
	return o
}

// SetTenantID adds the tenantId to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) SetTenantID(tenantID *strfmt.UUID) {
	o.TenantID = tenantID
}

// WithUserID adds the userID to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) WithUserID(userID *strfmt.UUID) *GetEffectiveEntitlementsParams {
	o.SetUserID(userID)
	return o
}

// SetUserID adds the userId to the get effective entitlements params.
func (o *GetEffectiveEntitlementsParams) SetUserID(userID *strfmt.UUID) {
	o.UserID = userID
}

// WriteToRequest writes these params to a [runtime.ClientRequest].
func (o *GetEffectiveEntitlementsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
	if err := r.SetTimeout(o.inner.timeout); err != nil {
		return err
	}
	var res []error

	if o.EffectiveAt != nil {

		// query param effectiveAt
		var qrEffectiveAt strfmt.DateTime

		if o.EffectiveAt != nil {
			qrEffectiveAt = *o.EffectiveAt
		}
		qEffectiveAt := qrEffectiveAt.String()
		if qEffectiveAt != "" {

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

	if o.Limit != nil {

		// query param limit
		var qrLimit int64

		if o.Limit != nil {
			qrLimit = *o.Limit
		}
		qLimit := conv.FormatInteger(qrLimit)
		if qLimit != "" {

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

	if o.Offset != nil {

		// query param offset
		var qrOffset int64

		if o.Offset != nil {
			qrOffset = *o.Offset
		}
		qOffset := conv.FormatInteger(qrOffset)
		if qOffset != "" {

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

	if o.ServiceID != nil {

		// query param serviceId
		var qrServiceID strfmt.UUID

		if o.ServiceID != nil {
			qrServiceID = *o.ServiceID
		}
		qServiceID := qrServiceID.String()
		if qServiceID != "" {

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

	if o.TenantID != nil {

		// query param tenantId
		var qrTenantID strfmt.UUID

		if o.TenantID != nil {
			qrTenantID = *o.TenantID
		}
		qTenantID := qrTenantID.String()
		if qTenantID != "" {

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

	if o.UserID != nil {

		// query param userId
		var qrUserID strfmt.UUID

		if o.UserID != nil {
			qrUserID = *o.UserID
		}
		qUserID := qrUserID.String()
		if qUserID != "" {

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

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