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

package device_service

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

import (
	"context"
	"encoding/json"
	"fmt"
	"io"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/runtime"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"

	"git.huangwc.com/pig/pig-farm-controller/internal/infra/transport/lora/chirp_stack_proto/models"
)

// DeviceServiceActivateReader is a Reader for the DeviceServiceActivate structure.
type DeviceServiceActivateReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *DeviceServiceActivateReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewDeviceServiceActivateOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	default:
		result := NewDeviceServiceActivateDefault(response.Code())
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		if response.Code()/100 == 2 {
			return result, nil
		}
		return nil, result
	}
}

// NewDeviceServiceActivateOK creates a DeviceServiceActivateOK with default headers values
func NewDeviceServiceActivateOK() *DeviceServiceActivateOK {
	return &DeviceServiceActivateOK{}
}

/*
DeviceServiceActivateOK describes a response with status code 200, with default header values.

A successful response.
*/
type DeviceServiceActivateOK struct {
	Payload interface{}
}

// IsSuccess returns true when this device service activate o k response has a 2xx status code
func (o *DeviceServiceActivateOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this device service activate o k response has a 3xx status code
func (o *DeviceServiceActivateOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this device service activate o k response has a 4xx status code
func (o *DeviceServiceActivateOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this device service activate o k response has a 5xx status code
func (o *DeviceServiceActivateOK) IsServerError() bool {
	return false
}

// IsCode returns true when this device service activate o k response a status code equal to that given
func (o *DeviceServiceActivateOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the device service activate o k response
func (o *DeviceServiceActivateOK) Code() int {
	return 200
}

func (o *DeviceServiceActivateOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /api/devices/{deviceActivation.devEui}/activate][%d] deviceServiceActivateOK %s", 200, payload)
}

func (o *DeviceServiceActivateOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /api/devices/{deviceActivation.devEui}/activate][%d] deviceServiceActivateOK %s", 200, payload)
}

func (o *DeviceServiceActivateOK) GetPayload() interface{} {
	return o.Payload
}

func (o *DeviceServiceActivateOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	// response payload
	if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
		return err
	}

	return nil
}

// NewDeviceServiceActivateDefault creates a DeviceServiceActivateDefault with default headers values
func NewDeviceServiceActivateDefault(code int) *DeviceServiceActivateDefault {
	return &DeviceServiceActivateDefault{
		_statusCode: code,
	}
}

/*
DeviceServiceActivateDefault describes a response with status code -1, with default header values.

An unexpected error response.
*/
type DeviceServiceActivateDefault struct {
	_statusCode int

	Payload *models.RPCStatus
}

// IsSuccess returns true when this device service activate default response has a 2xx status code
func (o *DeviceServiceActivateDefault) IsSuccess() bool {
	return o._statusCode/100 == 2
}

// IsRedirect returns true when this device service activate default response has a 3xx status code
func (o *DeviceServiceActivateDefault) IsRedirect() bool {
	return o._statusCode/100 == 3
}

// IsClientError returns true when this device service activate default response has a 4xx status code
func (o *DeviceServiceActivateDefault) IsClientError() bool {
	return o._statusCode/100 == 4
}

// IsServerError returns true when this device service activate default response has a 5xx status code
func (o *DeviceServiceActivateDefault) IsServerError() bool {
	return o._statusCode/100 == 5
}

// IsCode returns true when this device service activate default response a status code equal to that given
func (o *DeviceServiceActivateDefault) IsCode(code int) bool {
	return o._statusCode == code
}

// Code gets the status code for the device service activate default response
func (o *DeviceServiceActivateDefault) Code() int {
	return o._statusCode
}

func (o *DeviceServiceActivateDefault) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /api/devices/{deviceActivation.devEui}/activate][%d] DeviceService_Activate default %s", o._statusCode, payload)
}

func (o *DeviceServiceActivateDefault) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /api/devices/{deviceActivation.devEui}/activate][%d] DeviceService_Activate default %s", o._statusCode, payload)
}

func (o *DeviceServiceActivateDefault) GetPayload() *models.RPCStatus {
	return o.Payload
}

func (o *DeviceServiceActivateDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	o.Payload = new(models.RPCStatus)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
		return err
	}

	return nil
}

/*
DeviceServiceActivateBody device service activate body
swagger:model DeviceServiceActivateBody
*/
type DeviceServiceActivateBody struct {

	// device activation
	DeviceActivation *DeviceServiceActivateParamsBodyDeviceActivation `json:"deviceActivation,omitempty"`
}

// Validate validates this device service activate body
func (o *DeviceServiceActivateBody) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (o *DeviceServiceActivateBody) validateDeviceActivation(formats strfmt.Registry) error {
	if swag.IsZero(o.DeviceActivation) { // not required
		return nil
	}

	if o.DeviceActivation != nil {
		if err := o.DeviceActivation.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("body" + "." + "deviceActivation")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("body" + "." + "deviceActivation")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this device service activate body based on the context it is used
func (o *DeviceServiceActivateBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := o.contextValidateDeviceActivation(ctx, formats); err != nil {
		res = append(res, err)
	}

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

func (o *DeviceServiceActivateBody) contextValidateDeviceActivation(ctx context.Context, formats strfmt.Registry) error {

	if o.DeviceActivation != nil {

		if swag.IsZero(o.DeviceActivation) { // not required
			return nil
		}

		if err := o.DeviceActivation.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("body" + "." + "deviceActivation")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("body" + "." + "deviceActivation")
			}
			return err
		}
	}

	return nil
}

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

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

/*
DeviceServiceActivateParamsBodyDeviceActivation Device activation object.
swagger:model DeviceServiceActivateParamsBodyDeviceActivation
*/
type DeviceServiceActivateParamsBodyDeviceActivation struct {

	// Downlink application frame-counter.
	AFCntDown int64 `json:"aFCntDown,omitempty"`

	// Application session key (HEX encoded).
	AppSKey string `json:"appSKey,omitempty"`

	// Device address (HEX encoded).
	DevAddr string `json:"devAddr,omitempty"`

	// Uplink frame-counter.
	FCntUp int64 `json:"fCntUp,omitempty"`

	// Forwarding network session integrity key (HEX encoded).
	// Note: For LoRaWAN 1.0.x devices, set this to the NwkSKey.
	FNwkSIntKey string `json:"fNwkSIntKey,omitempty"`

	// Downlink network frame-counter.
	NFCntDown int64 `json:"nFCntDown,omitempty"`

	// Network session encryption key (HEX encoded).
	// Note: For LoRaWAN 1.0.x devices, set this to the NwkSKey.
	NwkSEncKey string `json:"nwkSEncKey,omitempty"`

	// Serving network session integrity key (HEX encoded).
	// Note: For LoRaWAN 1.0.x devices, set this to the NwkSKey.
	SNwkSIntKey string `json:"sNwkSIntKey,omitempty"`
}

// Validate validates this device service activate params body device activation
func (o *DeviceServiceActivateParamsBodyDeviceActivation) Validate(formats strfmt.Registry) error {
	return nil
}

// ContextValidate validates this device service activate params body device activation based on context it is used
func (o *DeviceServiceActivateParamsBodyDeviceActivation) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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