package ga

import "net/url"

//WARNING: This file was generated. Do not edit.

//Timing Hit Type
type Timing struct {
	userTimingCategory        string
	userTimingCategorySet     bool
	userTimingVariableName    string
	userTimingVariableNameSet bool
	userTimingTime            int64
	userTimingTimeSet         bool
	userTimingLabel           string
	userTimingLabelSet        bool
	pageLoadTime              int64
	pageLoadTimeSet           bool
	dNSTime                   int64
	dNSTimeSet                bool
	pageDownloadTime          int64
	pageDownloadTimeSet       bool
	redirectResponseTime      int64
	redirectResponseTimeSet   bool
	tCPConnectTime            int64
	tCPConnectTimeSet         bool
	serverResponseTime        int64
	serverResponseTimeSet     bool
	dOMInteractiveTime        int64
	dOMInteractiveTimeSet     bool
	contentLoadTime           int64
	contentLoadTimeSet        bool
}

// NewTiming creates a new Timing Hit Type.

func NewTiming() *Timing {
	h := &Timing{}
	return h
}

func (h *Timing) addFields(v url.Values) error {
	if h.userTimingCategorySet {
		v.Add("utc", h.userTimingCategory)
	}
	if h.userTimingVariableNameSet {
		v.Add("utv", h.userTimingVariableName)
	}
	if h.userTimingTimeSet {
		v.Add("utt", int2str(h.userTimingTime))
	}
	if h.userTimingLabelSet {
		v.Add("utl", h.userTimingLabel)
	}
	if h.pageLoadTimeSet {
		v.Add("plt", int2str(h.pageLoadTime))
	}
	if h.dNSTimeSet {
		v.Add("dns", int2str(h.dNSTime))
	}
	if h.pageDownloadTimeSet {
		v.Add("pdt", int2str(h.pageDownloadTime))
	}
	if h.redirectResponseTimeSet {
		v.Add("rrt", int2str(h.redirectResponseTime))
	}
	if h.tCPConnectTimeSet {
		v.Add("tcp", int2str(h.tCPConnectTime))
	}
	if h.serverResponseTimeSet {
		v.Add("srt", int2str(h.serverResponseTime))
	}
	if h.dOMInteractiveTimeSet {
		v.Add("dit", int2str(h.dOMInteractiveTime))
	}
	if h.contentLoadTimeSet {
		v.Add("clt", int2str(h.contentLoadTime))
	}
	return nil
}

// Specifies the user timing category.
func (h *Timing) UserTimingCategory(userTimingCategory string) *Timing {
	h.userTimingCategory = userTimingCategory
	h.userTimingCategorySet = true
	return h
}

// Specifies the user timing variable.
func (h *Timing) UserTimingVariableName(userTimingVariableName string) *Timing {
	h.userTimingVariableName = userTimingVariableName
	h.userTimingVariableNameSet = true
	return h
}

// Specifies the user timing value. The value is in milliseconds.
func (h *Timing) UserTimingTime(userTimingTime int64) *Timing {
	h.userTimingTime = userTimingTime
	h.userTimingTimeSet = true
	return h
}

// Specifies the user timing label.
func (h *Timing) UserTimingLabel(userTimingLabel string) *Timing {
	h.userTimingLabel = userTimingLabel
	h.userTimingLabelSet = true
	return h
}

// Specifies the time it took for a page to load. The value
// is in milliseconds.
func (h *Timing) PageLoadTime(pageLoadTime int64) *Timing {
	h.pageLoadTime = pageLoadTime
	h.pageLoadTimeSet = true
	return h
}

// Specifies the time it took to do a DNS lookup.The value
// is in milliseconds.
func (h *Timing) DNSTime(dNSTime int64) *Timing {
	h.dNSTime = dNSTime
	h.dNSTimeSet = true
	return h
}

// Specifies the time it took for the page to be downloaded.
// The value is in milliseconds.
func (h *Timing) PageDownloadTime(pageDownloadTime int64) *Timing {
	h.pageDownloadTime = pageDownloadTime
	h.pageDownloadTimeSet = true
	return h
}

// Specifies the time it took for any redirects to happen.
// The value is in milliseconds.
func (h *Timing) RedirectResponseTime(redirectResponseTime int64) *Timing {
	h.redirectResponseTime = redirectResponseTime
	h.redirectResponseTimeSet = true
	return h
}

// Specifies the time it took for a TCP connection to be made.
// The value is in milliseconds.
func (h *Timing) TCPConnectTime(tCPConnectTime int64) *Timing {
	h.tCPConnectTime = tCPConnectTime
	h.tCPConnectTimeSet = true
	return h
}

// Specifies the time it took for the server to respond after
// the connect time. The value is in milliseconds.
func (h *Timing) ServerResponseTime(serverResponseTime int64) *Timing {
	h.serverResponseTime = serverResponseTime
	h.serverResponseTimeSet = true
	return h
}

// Specifies the time it took for Document.readyState to be
// 'interactive'. The value is in milliseconds.
func (h *Timing) DOMInteractiveTime(dOMInteractiveTime int64) *Timing {
	h.dOMInteractiveTime = dOMInteractiveTime
	h.dOMInteractiveTimeSet = true
	return h
}

// Specifies the time it took for the DOMContentLoaded Event
// to fire. The value is in milliseconds.
func (h *Timing) ContentLoadTime(contentLoadTime int64) *Timing {
	h.contentLoadTime = contentLoadTime
	h.contentLoadTimeSet = true
	return h
}

func (h *Timing) Copy() *Timing {
	c := *h
	return &c
}
