<commit_before>package siri

import (
	"bytes"
	rxml "encoding/xml"
	"fmt"
	"text/template"
	"time"

	"github.com/af83/edwig/model"
	"github.com/jbowtie/gokogiri"
	"github.com/jbowtie/gokogiri/xml"
)

type XMLGeneralMessageResponse struct {
	ResponseXMLStructure

	xmlGeneralMessages []*XMLGeneralMessage
}

type XMLGeneralMessage struct {
	XMLStructure

	recordedAtTime        time.Time
	validUntilTime        time.Time
	itemIdentifier        string
	infoMessageIdentifier string
	infoMessageVersion    int
	infoChannelRef        string
	format                string
	content               interface{}
}

type IDFGeneralMessageStructure struct {
	XMLStructure

	messages          []*model.Message
	lineRef           string
	stopPointRef      string
	journeyPatternRef string
	destinationRef    string
	routeRef          string
	format            string
	groupOfLinesRef   string
	lineSection       IDFLineSectionStructure
}

type IDFLineSectionStructure struct {
	XMLStructure

	firstStop string
	lastStop  string
	lineRef   string
}

type SIRIGeneralMessageResponse struct {
	SIRIGeneralMessageDelivery

	Address                   string
	ProducerRef               string
	ResponseMessageIdentifier string
}

type SIRIGeneralMessageDelivery struct {
	RequestMessageRef string
	Status            bool
	ErrorType         string
	ErrorNumber       int
	ErrorText         string
	ResponseTimestamp time.Time

	GeneralMessages []*SIRIGeneralMessage
}

type SIRIGeneralMessage struct {
	RecordedAtTime        time.Time
	ValidUntilTime        time.Time
	ItemIdentifier        string
	InfoMessageIdentifier string
	InfoMessageVersion    int64
	InfoChannelRef        string

	LineRefContent    string
	StopPointRef      string
	JourneyPatternRef string
	DestinationRef    string
	RouteRef          string
	GroupOfLinesRef   string

	Messages []*model.Message

	FirstStop string
	LastStop  string
	LineRef   string
}

const generalMessageTemplate = `<ns3:GeneralMessageDelivery version="2.0:FR-IDF-2.4">
				  <ns3:ResponseTimestamp>{{ .ResponseTimestamp }}</ns3:ResponseTimestamp>
					<ns3:Status>{{.Status}}</ns3:Status>{{range .GeneralMessages}}
					<ns3:GeneralMessage formatRef="FRANCE">
						<ns3:RecordedAtTime>{{ .RecordedAtTime.Format "2006-01-02T15:04:05.000Z07:00" }}</ns3:RecordedAtTime>
						<ns3:InfoMessageIdentifier>{{.InfoMessageIdentifier}}</ns3:InfoMessageIdentifier>
						<ns3:InfoMessageVersion>{{.InfoMessageVersion}}</ns3:InfoMessageVersion>
						<ns3:InfoChannelRef>{{.InfoChannelRef}}</ns3:InfoChannelRef>
						<ns3:ValidUntilTime>{{ .ValidUntilTime.Format "2006-01-02T15:04:05.000Z07:00" }}</ns3:ValidUntilTime>
						<ns3:Content xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
						xsi:type="ns9:IDFLineSectionStructure">{{range .Messages}}
							<Message>
								<MessageType>{{ .Type }}</MessageType><commit_msg>Fix ResponseTimestamp Format in generalMessageTemplate<commit_after>package siri

import (
	"bytes"
	rxml "encoding/xml"
	"fmt"
	"text/template"
	"time"

	"github.com/af83/edwig/model"
	"github.com/jbowtie/gokogiri"
	"github.com/jbowtie/gokogiri/xml"
)

type XMLGeneralMessageResponse struct {
	ResponseXMLStructure

	xmlGeneralMessages []*XMLGeneralMessage
}

type XMLGeneralMessage struct {
	XMLStructure

	recordedAtTime        time.Time
	validUntilTime        time.Time
	itemIdentifier        string
	infoMessageIdentifier string
	infoMessageVersion    int
	infoChannelRef        string
	format                string
	content               interface{}
}

type IDFGeneralMessageStructure struct {
	XMLStructure

	messages          []*model.Message
	lineRef           string
	stopPointRef      string
	journeyPatternRef string
	destinationRef    string
	routeRef          string
	format            string
	groupOfLinesRef   string
	lineSection       IDFLineSectionStructure
}

type IDFLineSectionStructure struct {
	XMLStructure

	firstStop string
	lastStop  string
	lineRef   string
}

type SIRIGeneralMessageResponse struct {
	SIRIGeneralMessageDelivery

	Address                   string
	ProducerRef               string
	ResponseMessageIdentifier string
}

type SIRIGeneralMessageDelivery struct {
	RequestMessageRef string
	Status            bool
	ErrorType         string
	ErrorNumber       int
	ErrorText         string
	ResponseTimestamp time.Time

	GeneralMessages []*SIRIGeneralMessage
}

type SIRIGeneralMessage struct {
	RecordedAtTime        time.Time
	ValidUntilTime        time.Time
	ItemIdentifier        string
	InfoMessageIdentifier string
	InfoMessageVersion    int64
	InfoChannelRef        string

	LineRefContent    string
	StopPointRef      string
	JourneyPatternRef string
	DestinationRef    string
	RouteRef          string
	GroupOfLinesRef   string

	Messages []*model.Message

	FirstStop string
	LastStop  string
	LineRef   string
}

const generalMessageTemplate = `<ns3:GeneralMessageDelivery version="2.0:FR-IDF-2.4">
				  <ns3:ResponseTimestamp>{{ .ResponseTimestamp.Format "2006-01-02T15:04:05.000Z07:00" }}</ns3:ResponseTimestamp>
					<ns3:Status>{{.Status}}</ns3:Status>{{range .GeneralMessages}}
					<ns3:GeneralMessage formatRef="FRANCE">
						<ns3:RecordedAtTime>{{ .RecordedAtTime.Format "2006-01-02T15:04:05.000Z07:00" }}</ns3:RecordedAtTime>
						<ns3:InfoMessageIdentifier>{{.InfoMessageIdentifier}}</ns3:InfoMessageIdentifier>
						<ns3:InfoMessageVersion>{{.InfoMessageVersion}}</ns3:InfoMessageVersion>
						<ns3:InfoChannelRef>{{.InfoChannelRef}}</ns3:InfoChannelRef>
						<ns3:ValidUntilTime>{{ .ValidUntilTime.Format "2006-01-02T15:04:05.000Z07:00" }}</ns3:ValidUntilTime>
						<ns3:Content xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
						xsi:type="ns9:IDFLineSectionStructure">{{range .Messages}}
							<Message>
								<MessageType>{{ .Type }}</MessageType>
{'fraction_non_alphanumeric': 0.08183391003460208, 'fraction_numerical': 0.02889273356401384, 'mean_word_length': 3.580824088748019, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4916819', 'n_tokens_mistral': 1970, 'n_tokens_neox': 1721, 'n_words': 328}