// Code generated by fixgen. DO NOT EDIT.

package fix44

import (
	"github.com/b2broker/simplefix-go/fix"
	"github.com/b2broker/simplefix-go/session/messages"
)

const MsgTypeMarketDataRequest = "V"

type MarketDataRequest struct {
	*fix.Message
}

func makeMarketDataRequest() *MarketDataRequest {
	msg := &MarketDataRequest{
		Message: fix.NewMessage(FieldBeginString, FieldBodyLength, FieldCheckSum, FieldMsgType, beginString, MsgTypeMarketDataRequest).
			SetBody(
				fix.NewKeyValue(FieldMDReqID, &fix.String{}),
				fix.NewKeyValue(FieldSubscriptionRequestType, &fix.String{}),
				fix.NewKeyValue(FieldMarketDepth, &fix.Int{}),
				fix.NewKeyValue(FieldMDUpdateType, &fix.String{}),
				fix.NewKeyValue(FieldAggregatedBook, &fix.Bool{}),
				fix.NewKeyValue(FieldOpenCloseSettlFlag, &fix.String{}),
				fix.NewKeyValue(FieldScope, &fix.String{}),
				fix.NewKeyValue(FieldMDImplicitDelete, &fix.Bool{}),
				NewMDEntryTypesGrp().Group,
				NewRelatedSymGrp().Group,
			),
	}

	msg.SetHeader(makeHeader().AsComponent())
	msg.SetTrailer(makeTrailer().AsComponent())

	return msg
}

func CreateMarketDataRequest(mDReqID string, subscriptionRequestType string, marketDepth int, noMDEntryTypes *MDEntryTypesGrp, noRelatedSym *RelatedSymGrp) *MarketDataRequest {
	msg := makeMarketDataRequest().
		SetMDReqID(mDReqID).
		SetSubscriptionRequestType(subscriptionRequestType).
		SetMarketDepth(marketDepth).
		SetMDEntryTypesGrp(noMDEntryTypes).
		SetRelatedSymGrp(noRelatedSym)

	return msg
}

func NewMarketDataRequest() *MarketDataRequest {
	m := makeMarketDataRequest()
	return &MarketDataRequest{
		fix.NewMessage(FieldBeginString, FieldBodyLength, FieldCheckSum, FieldMsgType, beginString, MsgTypeMarketDataRequest).
			SetBody(m.Body()...).
			SetHeader(m.Header().AsComponent()).
			SetTrailer(m.Trailer().AsComponent()),
	}
}

func (marketDataRequest *MarketDataRequest) Header() *Header {
	header := marketDataRequest.Message.Header()

	return &Header{header}
}

func (marketDataRequest *MarketDataRequest) HeaderBuilder() messages.HeaderBuilder {
	return marketDataRequest.Header()
}

func (marketDataRequest *MarketDataRequest) Trailer() *Trailer {
	trailer := marketDataRequest.Message.Trailer()

	return &Trailer{trailer}
}

func (marketDataRequest *MarketDataRequest) MDReqID() string {
	kv := marketDataRequest.Get(0)
	v := kv.(*fix.KeyValue).Load().Value()
	return v.(string)
}

func (marketDataRequest *MarketDataRequest) SetMDReqID(mDReqID string) *MarketDataRequest {
	kv := marketDataRequest.Get(0).(*fix.KeyValue)
	_ = kv.Load().Set(mDReqID)
	return marketDataRequest
}

func (marketDataRequest *MarketDataRequest) SubscriptionRequestType() string {
	kv := marketDataRequest.Get(1)
	v := kv.(*fix.KeyValue).Load().Value()
	return v.(string)
}

func (marketDataRequest *MarketDataRequest) SetSubscriptionRequestType(subscriptionRequestType string) *MarketDataRequest {
	kv := marketDataRequest.Get(1).(*fix.KeyValue)
	_ = kv.Load().Set(subscriptionRequestType)
	return marketDataRequest
}

func (marketDataRequest *MarketDataRequest) MarketDepth() int {
	kv := marketDataRequest.Get(2)
	v := kv.(*fix.KeyValue).Load().Value()
	return v.(int)
}

func (marketDataRequest *MarketDataRequest) SetMarketDepth(marketDepth int) *MarketDataRequest {
	kv := marketDataRequest.Get(2).(*fix.KeyValue)
	_ = kv.Load().Set(marketDepth)
	return marketDataRequest
}

func (marketDataRequest *MarketDataRequest) MDUpdateType() string {
	kv := marketDataRequest.Get(3)
	v := kv.(*fix.KeyValue).Load().Value()
	return v.(string)
}

func (marketDataRequest *MarketDataRequest) SetMDUpdateType(mDUpdateType string) *MarketDataRequest {
	kv := marketDataRequest.Get(3).(*fix.KeyValue)
	_ = kv.Load().Set(mDUpdateType)
	return marketDataRequest
}

func (marketDataRequest *MarketDataRequest) AggregatedBook() bool {
	kv := marketDataRequest.Get(4)
	v := kv.(*fix.KeyValue).Load().Value()
	return v.(bool)
}

func (marketDataRequest *MarketDataRequest) SetAggregatedBook(aggregatedBook bool) *MarketDataRequest {
	kv := marketDataRequest.Get(4).(*fix.KeyValue)
	_ = kv.Load().Set(aggregatedBook)
	return marketDataRequest
}

func (marketDataRequest *MarketDataRequest) OpenCloseSettlFlag() string {
	kv := marketDataRequest.Get(5)
	v := kv.(*fix.KeyValue).Load().Value()
	return v.(string)
}

func (marketDataRequest *MarketDataRequest) SetOpenCloseSettlFlag(openCloseSettlFlag string) *MarketDataRequest {
	kv := marketDataRequest.Get(5).(*fix.KeyValue)
	_ = kv.Load().Set(openCloseSettlFlag)
	return marketDataRequest
}

func (marketDataRequest *MarketDataRequest) Scope() string {
	kv := marketDataRequest.Get(6)
	v := kv.(*fix.KeyValue).Load().Value()
	return v.(string)
}

func (marketDataRequest *MarketDataRequest) SetScope(scope string) *MarketDataRequest {
	kv := marketDataRequest.Get(6).(*fix.KeyValue)
	_ = kv.Load().Set(scope)
	return marketDataRequest
}

func (marketDataRequest *MarketDataRequest) MDImplicitDelete() bool {
	kv := marketDataRequest.Get(7)
	v := kv.(*fix.KeyValue).Load().Value()
	return v.(bool)
}

func (marketDataRequest *MarketDataRequest) SetMDImplicitDelete(mDImplicitDelete bool) *MarketDataRequest {
	kv := marketDataRequest.Get(7).(*fix.KeyValue)
	_ = kv.Load().Set(mDImplicitDelete)
	return marketDataRequest
}

func (marketDataRequest *MarketDataRequest) MDEntryTypesGrp() *MDEntryTypesGrp {
	group := marketDataRequest.Get(8).(*fix.Group)

	return &MDEntryTypesGrp{group}
}

func (marketDataRequest *MarketDataRequest) SetMDEntryTypesGrp(noMDEntryTypes *MDEntryTypesGrp) *MarketDataRequest {
	marketDataRequest.Set(8, noMDEntryTypes.Group)

	return marketDataRequest
}

func (marketDataRequest *MarketDataRequest) RelatedSymGrp() *RelatedSymGrp {
	group := marketDataRequest.Get(9).(*fix.Group)

	return &RelatedSymGrp{group}
}

func (marketDataRequest *MarketDataRequest) SetRelatedSymGrp(noRelatedSym *RelatedSymGrp) *MarketDataRequest {
	marketDataRequest.Set(9, noRelatedSym.Group)

	return marketDataRequest
}

// New is a plane message constructor
func (MarketDataRequest) New() messages.MarketDataRequestBuilder {
	return makeMarketDataRequest()
}

// Build provides an opportunity to customize message during building outgoing message
func (MarketDataRequest) Build() messages.MarketDataRequestBuilder {
	return makeMarketDataRequest()
}
