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

import (
	"time"

	"github.com/shopspring/decimal"

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

// Quote is the fix40 Quote type, MsgType = S.
type Quote struct {
	fix40.Header
	*quickfix.Body
	fix40.Trailer
	Message *quickfix.Message
}

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

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

// New returns a Quote initialized with the required fields for Quote.
func New(quoteid field.QuoteIDField, symbol field.SymbolField, bidpx field.BidPxField) (m Quote) {
	m.Message = quickfix.NewMessage()
	m.Header = fix40.NewHeader(&m.Message.Header)
	m.Body = &m.Message.Body
	m.Trailer.Trailer = &m.Message.Trailer

	m.Header.Set(field.NewMsgType("S"))
	m.Set(quoteid)
	m.Set(symbol)
	m.Set(bidpx)

	return
}

// A RouteOut is the callback type that should be implemented for routing Message.
type RouteOut func(msg Quote, 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 "FIX.4.0", "S", r
}

// SetIDSource sets IDSource, Tag 22.
func (m Quote) SetIDSource(v enum.IDSource) {
	m.Set(field.NewIDSource(v))
}

// SetSecurityID sets SecurityID, Tag 48.
func (m Quote) SetSecurityID(v string) {
	m.Set(field.NewSecurityID(v))
}

// SetSymbol sets Symbol, Tag 55.
func (m Quote) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}

// SetValidUntilTime sets ValidUntilTime, Tag 62.
func (m Quote) SetValidUntilTime(v time.Time) {
	m.Set(field.NewValidUntilTime(v))
}

// SetSymbolSfx sets SymbolSfx, Tag 65.
func (m Quote) SetSymbolSfx(v enum.SymbolSfx) {
	m.Set(field.NewSymbolSfx(v))
}

// SetIssuer sets Issuer, Tag 106.
func (m Quote) SetIssuer(v string) {
	m.Set(field.NewIssuer(v))
}

// SetSecurityDesc sets SecurityDesc, Tag 107.
func (m Quote) SetSecurityDesc(v string) {
	m.Set(field.NewSecurityDesc(v))
}

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

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

// SetBidPx sets BidPx, Tag 132.
func (m Quote) SetBidPx(value decimal.Decimal, scale int32) {
	m.Set(field.NewBidPx(value, scale))
}

// SetOfferPx sets OfferPx, Tag 133.
func (m Quote) SetOfferPx(value decimal.Decimal, scale int32) {
	m.Set(field.NewOfferPx(value, scale))
}

// SetBidSize sets BidSize, Tag 134.
func (m Quote) SetBidSize(value decimal.Decimal, scale int32) {
	m.Set(field.NewBidSize(value, scale))
}

// SetOfferSize sets OfferSize, Tag 135.
func (m Quote) SetOfferSize(value decimal.Decimal, scale int32) {
	m.Set(field.NewOfferSize(value, scale))
}

// GetIDSource gets IDSource, Tag 22.
func (m Quote) GetIDSource() (v enum.IDSource, err quickfix.MessageRejectError) {
	var f field.IDSourceField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetSecurityID gets SecurityID, Tag 48.
func (m Quote) GetSecurityID() (v string, err quickfix.MessageRejectError) {
	var f field.SecurityIDField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetSymbol gets Symbol, Tag 55.
func (m Quote) GetSymbol() (v string, err quickfix.MessageRejectError) {
	var f field.SymbolField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetValidUntilTime gets ValidUntilTime, Tag 62.
func (m Quote) GetValidUntilTime() (v time.Time, err quickfix.MessageRejectError) {
	var f field.ValidUntilTimeField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetSymbolSfx gets SymbolSfx, Tag 65.
func (m Quote) GetSymbolSfx() (v enum.SymbolSfx, err quickfix.MessageRejectError) {
	var f field.SymbolSfxField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetIssuer gets Issuer, Tag 106.
func (m Quote) GetIssuer() (v string, err quickfix.MessageRejectError) {
	var f field.IssuerField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetSecurityDesc gets SecurityDesc, Tag 107.
func (m Quote) GetSecurityDesc() (v string, err quickfix.MessageRejectError) {
	var f field.SecurityDescField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetQuoteID gets QuoteID, Tag 117.
func (m Quote) 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 Quote) GetQuoteReqID() (v string, err quickfix.MessageRejectError) {
	var f field.QuoteReqIDField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetBidPx gets BidPx, Tag 132.
func (m Quote) GetBidPx() (v decimal.Decimal, err quickfix.MessageRejectError) {
	var f field.BidPxField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetOfferPx gets OfferPx, Tag 133.
func (m Quote) GetOfferPx() (v decimal.Decimal, err quickfix.MessageRejectError) {
	var f field.OfferPxField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetBidSize gets BidSize, Tag 134.
func (m Quote) GetBidSize() (v decimal.Decimal, err quickfix.MessageRejectError) {
	var f field.BidSizeField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// GetOfferSize gets OfferSize, Tag 135.
func (m Quote) GetOfferSize() (v decimal.Decimal, err quickfix.MessageRejectError) {
	var f field.OfferSizeField
	if err = m.Get(&f); err == nil {
		v = f.Value()
	}
	return
}

// HasIDSource returns true if IDSource is present, Tag 22.
func (m Quote) HasIDSource() bool {
	return m.Has(tag.IDSource)
}

// HasSecurityID returns true if SecurityID is present, Tag 48.
func (m Quote) HasSecurityID() bool {
	return m.Has(tag.SecurityID)
}

// HasSymbol returns true if Symbol is present, Tag 55.
func (m Quote) HasSymbol() bool {
	return m.Has(tag.Symbol)
}

// HasValidUntilTime returns true if ValidUntilTime is present, Tag 62.
func (m Quote) HasValidUntilTime() bool {
	return m.Has(tag.ValidUntilTime)
}

// HasSymbolSfx returns true if SymbolSfx is present, Tag 65.
func (m Quote) HasSymbolSfx() bool {
	return m.Has(tag.SymbolSfx)
}

// HasIssuer returns true if Issuer is present, Tag 106.
func (m Quote) HasIssuer() bool {
	return m.Has(tag.Issuer)
}

// HasSecurityDesc returns true if SecurityDesc is present, Tag 107.
func (m Quote) HasSecurityDesc() bool {
	return m.Has(tag.SecurityDesc)
}

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

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

// HasBidPx returns true if BidPx is present, Tag 132.
func (m Quote) HasBidPx() bool {
	return m.Has(tag.BidPx)
}

// HasOfferPx returns true if OfferPx is present, Tag 133.
func (m Quote) HasOfferPx() bool {
	return m.Has(tag.OfferPx)
}

// HasBidSize returns true if BidSize is present, Tag 134.
func (m Quote) HasBidSize() bool {
	return m.Has(tag.BidSize)
}

// HasOfferSize returns true if OfferSize is present, Tag 135.
func (m Quote) HasOfferSize() bool {
	return m.Has(tag.OfferSize)
}
