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

package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
	"github.com/go-openapi/validate"
)

// TokenDTO token DTO
//
// swagger:model TokenDTO
type TokenDTO struct {

	// created
	// Example: 2022-03-23T10:31:02Z
	// Format: date-time
	Created strfmt.DateTime `json:"created,omitempty"`

	// expiration
	// Example: 2022-03-23T10:31:02Z
	// Format: date-time
	Expiration strfmt.DateTime `json:"expiration,omitempty"`

	// has expired
	// Example: false
	HasExpired bool `json:"hasExpired,omitempty"`

	// id
	// Example: 1
	ID int64 `json:"id,omitempty"`

	// is revoked
	// Example: false
	IsRevoked bool `json:"isRevoked,omitempty"`

	// last used at
	// Example: 2022-03-23T10:31:02Z
	// Format: date-time
	LastUsedAt strfmt.DateTime `json:"lastUsedAt,omitempty"`

	// name
	// Example: grafana
	Name string `json:"name,omitempty"`

	// seconds until expiration
	// Example: 0
	SecondsUntilExpiration float64 `json:"secondsUntilExpiration,omitempty"`
}

// Validate validates this token DTO
func (m *TokenDTO) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateCreated(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateExpiration(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateLastUsedAt(formats); err != nil {
		res = append(res, err)
	}

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

func (m *TokenDTO) validateCreated(formats strfmt.Registry) error {
	if swag.IsZero(m.Created) { // not required
		return nil
	}

	if err := validate.FormatOf("created", "body", "date-time", m.Created.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *TokenDTO) validateExpiration(formats strfmt.Registry) error {
	if swag.IsZero(m.Expiration) { // not required
		return nil
	}

	if err := validate.FormatOf("expiration", "body", "date-time", m.Expiration.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *TokenDTO) validateLastUsedAt(formats strfmt.Registry) error {
	if swag.IsZero(m.LastUsedAt) { // not required
		return nil
	}

	if err := validate.FormatOf("lastUsedAt", "body", "date-time", m.LastUsedAt.String(), formats); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this token DTO based on context it is used
func (m *TokenDTO) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

// MarshalBinary interface implementation
func (m *TokenDTO) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *TokenDTO) UnmarshalBinary(b []byte) error {
	var res TokenDTO
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
