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

// APIDeviceQueueItem api device queue item
//
// swagger:model apiDeviceQueueItem
type APIDeviceQueueItem struct {

	// Confirmed.
	Confirmed bool `json:"confirmed,omitempty"`

	// Data.
	// Or use the json_object field when a codec has been configured.
	// Format: byte
	Data strfmt.Base64 `json:"data,omitempty"`

	// Device EUI (EUI64).
	DevEui string `json:"devEui,omitempty"`

	// Expires at (optional).
	// Expired queue-items will be automatically removed from the queue.
	// Format: date-time
	ExpiresAt strfmt.DateTime `json:"expiresAt,omitempty"`

	// Downlink frame-counter.
	// Do not set this for plain-text data payloads. It will be automatically set
	// by ChirpStack when the payload has been sent as downlink.
	FCntDown int64 `json:"fCntDown,omitempty"`

	// FPort (must be > 0).
	// On enqueue and if using a JavaScript codec, this value might be
	// automatically set by the codec function.
	FPort int64 `json:"fPort,omitempty"`

	// ID (UUID).
	// This is automatically generated on enqueue.
	ID string `json:"id,omitempty"`

	// Is encrypted.
	// This must be set to true if the end-application has already encrypted
	// the data payload. In this case, the f_cnt_down field must be set to
	// the corresponding frame-counter which has been used during the encryption.
	IsEncrypted bool `json:"isEncrypted,omitempty"`

	// Is pending.
	// This is set by ChirpStack to true when the downlink is pending (e.g. it
	// has been sent, but a confirmation is still pending).
	IsPending bool `json:"isPending,omitempty"`

	// Only use this when a codec has been configured that can encode this
	// object to bytes.
	Object interface{} `json:"object,omitempty"`
}

// Validate validates this api device queue item
func (m *APIDeviceQueueItem) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *APIDeviceQueueItem) validateExpiresAt(formats strfmt.Registry) error {
	if swag.IsZero(m.ExpiresAt) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validates this api device queue item based on context it is used
func (m *APIDeviceQueueItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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