func NewReturnMessage(amqpReturn *amqp.Return) *ReturnMessage {
	return &ReturnMessage{
		ReplyCode:       amqpReturn.ReplyCode,
		ReplyText:       amqpReturn.ReplyText,
		Exchange:        amqpReturn.Exchange,
		RoutingKey:      amqpReturn.RoutingKey,
		ContentType:     amqpReturn.ContentType,
		ContentEncoding: amqpReturn.ContentEncoding,
		Headers:         amqpReturn.Headers,
		DeliveryMode:    amqpReturn.DeliveryMode,
		Priority:        amqpReturn.Priority,
		CorrelationID:   amqpReturn.CorrelationId,
		ReplyTo:         amqpReturn.ReplyTo,
		Expiration:      amqpReturn.Expiration,
		MessageID:       amqpReturn.MessageId,
		Timestamp:       amqpReturn.Timestamp,
		Type:            amqpReturn.Type,
		UserID:          amqpReturn.UserId,
		AppID:           amqpReturn.AppId,
	}
}
NewReturnMessage creates a new ReturnMessage.
package models
import (
	"errors"
	"fmt"
	"time"
	"github.com/streadway/amqp"
)
type Notification struct {
	LetterID     uint64
	FailedLetter *Letter
	Success      bool
	Error        error
}
func (not *Notification) ToString() string {
	if not.Success {
		return fmt.Sprintf("[LetterID: %d] - Successful.\r\n", not.LetterID)
	}
	return fmt.Sprintf("[LetterID: %d] - Failed.\r\nError: %s\r\n", not.LetterID, not.Error.Error())
}
type Message struct {
	IsAckable   bool
	Body        []byte
	deliveryTag uint64
	amqpChan    *amqp.Channel
}
func NewMessage(
	isAckable bool,
	body []byte,
	deliveryTag uint64,
	amqpChan *amqp.Channel) *Message {
	return &Message{
		IsAckable:   isAckable,
		Body:        body,
		deliveryTag: deliveryTag,
		amqpChan:    amqpChan,
	}
}
func (msg *Message) Acknowledge() error {
	if !msg.IsAckable {
		return errors.New("can't acknowledge, not an ackable message")
	}
	if msg.amqpChan == nil {
		return errors.New("can't acknowledge, internal channel is nil")
	}
	return msg.amqpChan.Ack(msg.deliveryTag, false)
}
func (msg *Message) Nack(requeue bool) error {
	if !msg.IsAckable {
		return errors.New("can't nack, not an ackable message")
	}
	if msg.amqpChan == nil {
		return errors.New("can't nack, internal channel is nil")
	}
	return msg.amqpChan.Nack(msg.deliveryTag, false, requeue)
}
func (msg *Message) Reject(requeue bool) error {
	if !msg.IsAckable {
		return errors.New("can't reject, not an ackable message")
	}
	if msg.amqpChan == nil {
		return errors.New("can't reject, internal channel is nil")
	}
	return msg.amqpChan.Reject(msg.deliveryTag, requeue)
}
type ErrorMessage struct {
	Code    int
	Reason  string
	Server  bool
	Recover bool
}
func NewErrorMessage(amqpError *amqp.Error) *ErrorMessage {
	return &ErrorMessage{
		Code:    amqpError.Code,
		Reason:  amqpError.Reason,
		Server:  amqpError.Server,
		Recover: amqpError.Recover,
	}
}
func (em *ErrorMessage) Error() string {
	return fmt.Sprintf("[ErrorCode: %d] Reason: %s \r\n[Server Initiated: %v]\r\n[Recoverable: %v]\r\n", em.Code, em.Reason, em.Server, em.Recover)
}
type ReturnMessage struct {
	ReplyCode  uint16  
	ReplyText  string  
	Exchange   string  
	RoutingKey string  
	ContentType     string                  
	ContentEncoding string                  
	Headers         map[string]interface{}  
	DeliveryMode    uint8                   
	Priority        uint8                   
	CorrelationID   string                  
	ReplyTo         string                  
	Expiration      string                  
	MessageID       string                  
	Timestamp       time.Time               
	Type            string                  
	UserID          string                  
	AppID           string                  
	Body []byte
}