// Code generated by quickfix. DO NOT EDIT.
package quoteack

import (
	"time"

	"quantex.com/qfixdpl/quickfix"
	"quantex.com/qfixdpl/quickfix/gen/enum"
	"quantex.com/qfixdpl/quickfix/gen/field"
	"quantex.com/qfixdpl/quickfix/gen/fixt11"
	"quantex.com/qfixdpl/quickfix/gen/tag"
)

// QuoteAck is the fix50sp2 QuoteAck type, MsgType = CW.
type QuoteAck struct {
	fixt11.Header
	*quickfix.Body
	fixt11.Trailer
	Message *quickfix.Message
}

// FromMessage creates a QuoteAck from a quickfix.Message instance.
func FromMessage(m *quickfix.Message) QuoteAck {
	return QuoteAck{
		Header:  fixt11.Header{Header: &m.Header},
		Body:    &m.Body,
		Trailer: fixt11.Trailer{Trailer: &m.Trailer},
		Message: m,
	}
}

// ToMessage returns a quickfix.Message instance.
func (m QuoteAck) ToMessage() *quickfix.Message {
	return m.Message
}

// New returns a QuoteAck initialized with the required fields for QuoteAck.
func New(quotereqid field.QuoteReqIDField, transacttime field.TransactTimeField, quoteackstatus field.QuoteAckStatusField) (m QuoteAck) {
	m.Message = quickfix.NewMessage()
	m.Header = fixt11.NewHeader(&m.Message.Header)
	m.Body = &m.Message.Body
	m.Trailer.Trailer = &m.Message.Trailer

	m.Header.Set(field.NewMsgType("CW"))
	m.Set(quotereqid)
	m.Set(transacttime)
	m.Set(quoteackstatus)

	return
}

// A RouteOut is the callback type that should be implemented for routing Message.
type RouteOut func(msg QuoteAck, sessionID quickfix.SessionID) quickfix.MessageRejectError

// Route returns the beginstring, message type, and MessageRoute for this Message type.
func Route(router RouteOut) (string, string, quickfix.MessageRoute) {
	r := func(msg *quickfix.Message, sessionID quickfix.SessionID) quickfix.MessageRejectError {
		return router(FromMessage(msg), sessionID)
	}
	return "9", "CW", r
}

// SetText sets Text, Tag 58.
func (m QuoteAck) SetText(v string) {
	m.Set(field.NewText(v))
}

// SetTransactTime sets TransactTime, Tag 60.
func (m QuoteAck) SetTransactTime(v time.Time) {
	m.Set(field.NewTransactTime(v))
}

// SetQuoteID sets QuoteID, Tag 117.
func (m QuoteAck) SetQuoteID(v string) {
	m.Set(field.NewQuoteID(v))
}

// SetQuoteReqID sets QuoteReqID, Tag 131.
func (m QuoteAck) SetQuoteReqID(v string) {
	m.Set(field.NewQuoteReqID(v))
}

// SetQuoteCancelType sets QuoteCancelType, Tag 298.
func (m QuoteAck) SetQuoteCancelType(v enum.QuoteCancelType) {
	m.Set(field.NewQuoteCancelType(v))
}

// SetNoLegs sets NoLegs, Tag 555.
func (m QuoteAck) SetNoLegs(f NoLegsRepeatingGroup) {
	m.SetGroup(f)
}

// SetLastFragment sets LastFragment, Tag 893.
func (m QuoteAck) SetLastFragment(v bool) {
	m.Set(field.NewLastFragment(v))
}

// SetQuoteAckStatus sets QuoteAckStatus, Tag 1865.
func (m QuoteAck) SetQuoteAckStatus(v enum.QuoteAckStatus) {
	m.Set(field.NewQuoteAckStatus(v))
}

// SetTotNoOfMessages sets TotNoOfMessages, Tag 20394.
func (m QuoteAck) SetTotNoOfMessages(v int) {
	m.Set(field.NewTotNoOfMessages(v))
}

// SetMessageNo sets MessageNo, Tag 20395.
func (m QuoteAck) SetMessageNo(v int) {
	m.Set(field.NewMessageNo(v))
}

// GetText gets Text, Tag 58.
func (m QuoteAck) GetText() (v string, err quickfix.MessageRejectError) {
	var f field.TextField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetTransactTime gets TransactTime, Tag 60.
func (m QuoteAck) GetTransactTime() (v time.Time, err quickfix.MessageRejectError) {
	var f field.TransactTimeField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetQuoteID gets QuoteID, Tag 117.
func (m QuoteAck) GetQuoteID() (v string, err quickfix.MessageRejectError) {
	var f field.QuoteIDField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetQuoteReqID gets QuoteReqID, Tag 131.
func (m QuoteAck) GetQuoteReqID() (v string, err quickfix.MessageRejectError) {
	var f field.QuoteReqIDField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetQuoteCancelType gets QuoteCancelType, Tag 298.
func (m QuoteAck) GetQuoteCancelType() (v enum.QuoteCancelType, err quickfix.MessageRejectError) {
	var f field.QuoteCancelTypeField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetNoLegs gets NoLegs, Tag 555.
func (m QuoteAck) GetNoLegs() (NoLegsRepeatingGroup, quickfix.MessageRejectError) {
	f := NewNoLegsRepeatingGroup()
	err := m.GetGroup(f)
	return f, err
}

// GetLastFragment gets LastFragment, Tag 893.
func (m QuoteAck) GetLastFragment() (v bool, err quickfix.MessageRejectError) {
	var f field.LastFragmentField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetQuoteAckStatus gets QuoteAckStatus, Tag 1865.
func (m QuoteAck) GetQuoteAckStatus() (v enum.QuoteAckStatus, err quickfix.MessageRejectError) {
	var f field.QuoteAckStatusField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetTotNoOfMessages gets TotNoOfMessages, Tag 20394.
func (m QuoteAck) GetTotNoOfMessages() (v int, err quickfix.MessageRejectError) {
	var f field.TotNoOfMessagesField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetMessageNo gets MessageNo, Tag 20395.
func (m QuoteAck) GetMessageNo() (v int, err quickfix.MessageRejectError) {
	var f field.MessageNoField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// HasText returns true if Text is present, Tag 58.
func (m QuoteAck) HasText() bool {
	return m.Has(tag.Text)
}

// HasTransactTime returns true if TransactTime is present, Tag 60.
func (m QuoteAck) HasTransactTime() bool {
	return m.Has(tag.TransactTime)
}

// HasQuoteID returns true if QuoteID is present, Tag 117.
func (m QuoteAck) HasQuoteID() bool {
	return m.Has(tag.QuoteID)
}

// HasQuoteReqID returns true if QuoteReqID is present, Tag 131.
func (m QuoteAck) HasQuoteReqID() bool {
	return m.Has(tag.QuoteReqID)
}

// HasQuoteCancelType returns true if QuoteCancelType is present, Tag 298.
func (m QuoteAck) HasQuoteCancelType() bool {
	return m.Has(tag.QuoteCancelType)
}

// HasNoLegs returns true if NoLegs is present, Tag 555.
func (m QuoteAck) HasNoLegs() bool {
	return m.Has(tag.NoLegs)
}

// HasLastFragment returns true if LastFragment is present, Tag 893.
func (m QuoteAck) HasLastFragment() bool {
	return m.Has(tag.LastFragment)
}

// HasQuoteAckStatus returns true if QuoteAckStatus is present, Tag 1865.
func (m QuoteAck) HasQuoteAckStatus() bool {
	return m.Has(tag.QuoteAckStatus)
}

// HasTotNoOfMessages returns true if TotNoOfMessages is present, Tag 20394.
func (m QuoteAck) HasTotNoOfMessages() bool {
	return m.Has(tag.TotNoOfMessages)
}

// HasMessageNo returns true if MessageNo is present, Tag 20395.
func (m QuoteAck) HasMessageNo() bool {
	return m.Has(tag.MessageNo)
}

// NoLegs is a repeating group element, Tag 555.
type NoLegs struct {
	*quickfix.Group
}

// SetTradeLegRefID sets TradeLegRefID, Tag 824.
func (m NoLegs) SetTradeLegRefID(v string) {
	m.Set(field.NewTradeLegRefID(v))
}

// SetLegQuoteAckStatus sets LegQuoteAckStatus, Tag 21053.
func (m NoLegs) SetLegQuoteAckStatus(v enum.LegQuoteAckStatus) {
	m.Set(field.NewLegQuoteAckStatus(v))
}

// SetLegText sets LegText, Tag 21054.
func (m NoLegs) SetLegText(v string) {
	m.Set(field.NewLegText(v))
}

// GetTradeLegRefID gets TradeLegRefID, Tag 824.
func (m NoLegs) GetTradeLegRefID() (v string, err quickfix.MessageRejectError) {
	var f field.TradeLegRefIDField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetLegQuoteAckStatus gets LegQuoteAckStatus, Tag 21053.
func (m NoLegs) GetLegQuoteAckStatus() (v enum.LegQuoteAckStatus, err quickfix.MessageRejectError) {
	var f field.LegQuoteAckStatusField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetLegText gets LegText, Tag 21054.
func (m NoLegs) GetLegText() (v string, err quickfix.MessageRejectError) {
	var f field.LegTextField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// HasTradeLegRefID returns true if TradeLegRefID is present, Tag 824.
func (m NoLegs) HasTradeLegRefID() bool {
	return m.Has(tag.TradeLegRefID)
}

// HasLegQuoteAckStatus returns true if LegQuoteAckStatus is present, Tag 21053.
func (m NoLegs) HasLegQuoteAckStatus() bool {
	return m.Has(tag.LegQuoteAckStatus)
}

// HasLegText returns true if LegText is present, Tag 21054.
func (m NoLegs) HasLegText() bool {
	return m.Has(tag.LegText)
}

// NoLegsRepeatingGroup is a repeating group, Tag 555.
type NoLegsRepeatingGroup struct {
	*quickfix.RepeatingGroup
}

// NewNoLegsRepeatingGroup returns an initialized, NoLegsRepeatingGroup.
func NewNoLegsRepeatingGroup() NoLegsRepeatingGroup {
	return NoLegsRepeatingGroup{
		quickfix.NewRepeatingGroup(
			tag.NoLegs,
			quickfix.GroupTemplate{
				quickfix.GroupElement(tag.TradeLegRefID),
				quickfix.GroupElement(tag.LegQuoteAckStatus),
				quickfix.GroupElement(tag.LegText),
			},
		),
	}
}

// Add create and append a new NoLegs to this group.
func (m NoLegsRepeatingGroup) Add() NoLegs {
	g := m.RepeatingGroup.Add()
	return NoLegs{g}
}

// Get returns the ith NoLegs in the NoLegsRepeatinGroup.
func (m NoLegsRepeatingGroup) Get(i int) NoLegs {
	return NoLegs{m.RepeatingGroup.Get(i)}
}
