// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.

package postback

import (
	json "encoding/json"
	models "source.offmarket.win/aleagle/eaglecast/models"
	easyjson "github.com/zerodha/easyjson"
	jlexer "github.com/zerodha/easyjson/jlexer"
	jwriter "github.com/zerodha/easyjson/jwriter"
	textproto "net/textproto"
)

// suppress unused package warning
var (
	_ *json.RawMessage
	_ *jlexer.Lexer
	_ *jwriter.Writer
	_ easyjson.Marshaler
)

func easyjsonDf11841fDecodeGithubComKnadhEagleCastInternalMessengerPostback(in *jlexer.Lexer, out *postback) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		if isTopLevel {
			in.Consumed()
		}
		in.Skip()
		return
	}
	in.Delim('{')
	for !in.IsDelim('}') {
		key := in.UnsafeFieldName(false)
		in.WantColon()
		if in.IsNull() {
			in.Skip()
			in.WantComma()
			continue
		}
		switch key {
		case "subject":
			out.Subject = string(in.String())
		case "from_email":
			out.FromEmail = string(in.String())
		case "content_type":
			out.ContentType = string(in.String())
		case "body":
			out.Body = string(in.String())
		case "recipients":
			if in.IsNull() {
				in.Skip()
				out.Recipients = nil
			} else {
				in.Delim('[')
				if out.Recipients == nil {
					if !in.IsDelim(']') {
						out.Recipients = make([]recipient, 0, 0)
					} else {
						out.Recipients = []recipient{}
					}
				} else {
					out.Recipients = (out.Recipients)[:0]
				}
				for !in.IsDelim(']') {
					var v1 recipient
					easyjsonDf11841fDecodeGithubComKnadhEagleCastInternalMessengerPostback1(in, &v1)
					out.Recipients = append(out.Recipients, v1)
					in.WantComma()
				}
				in.Delim(']')
			}
		case "campaign":
			if in.IsNull() {
				in.Skip()
				out.Campaign = nil
			} else {
				if out.Campaign == nil {
					out.Campaign = new(campaign)
				}
				easyjsonDf11841fDecodeGithubComKnadhEagleCastInternalMessengerPostback2(in, out.Campaign)
			}
		case "attachments":
			if in.IsNull() {
				in.Skip()
				out.Attachments = nil
			} else {
				in.Delim('[')
				if out.Attachments == nil {
					if !in.IsDelim(']') {
						out.Attachments = make([]attachment, 0, 1)
					} else {
						out.Attachments = []attachment{}
					}
				} else {
					out.Attachments = (out.Attachments)[:0]
				}
				for !in.IsDelim(']') {
					var v2 attachment
					easyjsonDf11841fDecodeGithubComKnadhEagleCastInternalMessengerPostback3(in, &v2)
					out.Attachments = append(out.Attachments, v2)
					in.WantComma()
				}
				in.Delim(']')
			}
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjsonDf11841fEncodeGithubComKnadhEagleCastInternalMessengerPostback(out *jwriter.Writer, in postback) {
	out.RawByte('{')
	first := true
	_ = first
	{
		const prefix string = ",\"subject\":"
		out.RawString(prefix[1:])
		out.String(string(in.Subject))
	}
	{
		const prefix string = ",\"from_email\":"
		out.RawString(prefix)
		out.String(string(in.FromEmail))
	}
	{
		const prefix string = ",\"content_type\":"
		out.RawString(prefix)
		out.String(string(in.ContentType))
	}
	{
		const prefix string = ",\"body\":"
		out.RawString(prefix)
		out.String(string(in.Body))
	}
	{
		const prefix string = ",\"recipients\":"
		out.RawString(prefix)
		if in.Recipients == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
			out.RawString("null")
		} else {
			out.RawByte('[')
			for v3, v4 := range in.Recipients {
				if v3 > 0 {
					out.RawByte(',')
				}
				easyjsonDf11841fEncodeGithubComKnadhEagleCastInternalMessengerPostback1(out, v4)
			}
			out.RawByte(']')
		}
	}
	{
		const prefix string = ",\"campaign\":"
		out.RawString(prefix)
		if in.Campaign == nil {
			out.RawString("null")
		} else {
			easyjsonDf11841fEncodeGithubComKnadhEagleCastInternalMessengerPostback2(out, *in.Campaign)
		}
	}
	{
		const prefix string = ",\"attachments\":"
		out.RawString(prefix)
		if in.Attachments == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
			out.RawString("null")
		} else {
			out.RawByte('[')
			for v5, v6 := range in.Attachments {
				if v5 > 0 {
					out.RawByte(',')
				}
				easyjsonDf11841fEncodeGithubComKnadhEagleCastInternalMessengerPostback3(out, v6)
			}
			out.RawByte(']')
		}
	}
	out.RawByte('}')
}

// MarshalJSON supports json.Marshaler interface
func (v postback) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{FloatFmt: ""}
	easyjsonDf11841fEncodeGithubComKnadhEagleCastInternalMessengerPostback(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

// MarshalEasyJSON supports easyjson.Marshaler interface
func (v postback) MarshalEasyJSON(w *jwriter.Writer) {
	easyjsonDf11841fEncodeGithubComKnadhEagleCastInternalMessengerPostback(w, v)
}

// UnmarshalJSON supports json.Unmarshaler interface
func (v *postback) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjsonDf11841fDecodeGithubComKnadhEagleCastInternalMessengerPostback(&r, v)
	return r.Error()
}

// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *postback) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjsonDf11841fDecodeGithubComKnadhEagleCastInternalMessengerPostback(l, v)
}
func easyjsonDf11841fDecodeGithubComKnadhEagleCastInternalMessengerPostback3(in *jlexer.Lexer, out *attachment) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		if isTopLevel {
			in.Consumed()
		}
		in.Skip()
		return
	}
	in.Delim('{')
	for !in.IsDelim('}') {
		key := in.UnsafeFieldName(false)
		in.WantColon()
		if in.IsNull() {
			in.Skip()
			in.WantComma()
			continue
		}
		switch key {
		case "name":
			out.Name = string(in.String())
		case "header":
			if in.IsNull() {
				in.Skip()
			} else {
				in.Delim('{')
				out.Header = make(textproto.MIMEHeader)
				for !in.IsDelim('}') {
					key := string(in.String())
					in.WantColon()
					var v7 []string
					if in.IsNull() {
						in.Skip()
						v7 = nil
					} else {
						in.Delim('[')
						if v7 == nil {
							if !in.IsDelim(']') {
								v7 = make([]string, 0, 4)
							} else {
								v7 = []string{}
							}
						} else {
							v7 = (v7)[:0]
						}
						for !in.IsDelim(']') {
							var v8 string
							v8 = string(in.String())
							v7 = append(v7, v8)
							in.WantComma()
						}
						in.Delim(']')
					}
					(out.Header)[key] = v7
					in.WantComma()
				}
				in.Delim('}')
			}
		case "content":
			if in.IsNull() {
				in.Skip()
				out.Content = nil
			} else {
				out.Content = in.Bytes()
			}
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjsonDf11841fEncodeGithubComKnadhEagleCastInternalMessengerPostback3(out *jwriter.Writer, in attachment) {
	out.RawByte('{')
	first := true
	_ = first
	{
		const prefix string = ",\"name\":"
		out.RawString(prefix[1:])
		out.String(string(in.Name))
	}
	{
		const prefix string = ",\"header\":"
		out.RawString(prefix)
		if in.Header == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 {
			out.RawString(`null`)
		} else {
			out.RawByte('{')
			v10First := true
			for v10Name, v10Value := range in.Header {
				if v10First {
					v10First = false
				} else {
					out.RawByte(',')
				}
				out.String(string(v10Name))
				out.RawByte(':')
				if v10Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
					out.RawString("null")
				} else {
					out.RawByte('[')
					for v11, v12 := range v10Value {
						if v11 > 0 {
							out.RawByte(',')
						}
						out.String(string(v12))
					}
					out.RawByte(']')
				}
			}
			out.RawByte('}')
		}
	}
	{
		const prefix string = ",\"content\":"
		out.RawString(prefix)
		out.Base64Bytes(in.Content)
	}
	out.RawByte('}')
}
func easyjsonDf11841fDecodeGithubComKnadhEagleCastInternalMessengerPostback2(in *jlexer.Lexer, out *campaign) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		if isTopLevel {
			in.Consumed()
		}
		in.Skip()
		return
	}
	in.Delim('{')
	for !in.IsDelim('}') {
		key := in.UnsafeFieldName(false)
		in.WantColon()
		if in.IsNull() {
			in.Skip()
			in.WantComma()
			continue
		}
		switch key {
		case "from_email":
			out.FromEmail = string(in.String())
		case "uuid":
			out.UUID = string(in.String())
		case "name":
			out.Name = string(in.String())
		case "headers":
			if in.IsNull() {
				in.Skip()
				out.Headers = nil
			} else {
				in.Delim('[')
				if out.Headers == nil {
					if !in.IsDelim(']') {
						out.Headers = make(models.Headers, 0, 8)
					} else {
						out.Headers = models.Headers{}
					}
				} else {
					out.Headers = (out.Headers)[:0]
				}
				for !in.IsDelim(']') {
					var v15 map[string]string
					if in.IsNull() {
						in.Skip()
					} else {
						in.Delim('{')
						v15 = make(map[string]string)
						for !in.IsDelim('}') {
							key := string(in.String())
							in.WantColon()
							var v16 string
							v16 = string(in.String())
							(v15)[key] = v16
							in.WantComma()
						}
						in.Delim('}')
					}
					out.Headers = append(out.Headers, v15)
					in.WantComma()
				}
				in.Delim(']')
			}
		case "tags":
			if in.IsNull() {
				in.Skip()
				out.Tags = nil
			} else {
				in.Delim('[')
				if out.Tags == nil {
					if !in.IsDelim(']') {
						out.Tags = make([]string, 0, 4)
					} else {
						out.Tags = []string{}
					}
				} else {
					out.Tags = (out.Tags)[:0]
				}
				for !in.IsDelim(']') {
					var v17 string
					v17 = string(in.String())
					out.Tags = append(out.Tags, v17)
					in.WantComma()
				}
				in.Delim(']')
			}
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjsonDf11841fEncodeGithubComKnadhEagleCastInternalMessengerPostback2(out *jwriter.Writer, in campaign) {
	out.RawByte('{')
	first := true
	_ = first
	{
		const prefix string = ",\"from_email\":"
		out.RawString(prefix[1:])
		out.String(string(in.FromEmail))
	}
	{
		const prefix string = ",\"uuid\":"
		out.RawString(prefix)
		out.String(string(in.UUID))
	}
	{
		const prefix string = ",\"name\":"
		out.RawString(prefix)
		out.String(string(in.Name))
	}
	{
		const prefix string = ",\"headers\":"
		out.RawString(prefix)
		if in.Headers == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
			out.RawString("null")
		} else {
			out.RawByte('[')
			for v18, v19 := range in.Headers {
				if v18 > 0 {
					out.RawByte(',')
				}
				if v19 == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 {
					out.RawString(`null`)
				} else {
					out.RawByte('{')
					v20First := true
					for v20Name, v20Value := range v19 {
						if v20First {
							v20First = false
						} else {
							out.RawByte(',')
						}
						out.String(string(v20Name))
						out.RawByte(':')
						out.String(string(v20Value))
					}
					out.RawByte('}')
				}
			}
			out.RawByte(']')
		}
	}
	{
		const prefix string = ",\"tags\":"
		out.RawString(prefix)
		if in.Tags == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
			out.RawString("null")
		} else {
			out.RawByte('[')
			for v21, v22 := range in.Tags {
				if v21 > 0 {
					out.RawByte(',')
				}
				out.String(string(v22))
			}
			out.RawByte(']')
		}
	}
	out.RawByte('}')
}
func easyjsonDf11841fDecodeGithubComKnadhEagleCastInternalMessengerPostback1(in *jlexer.Lexer, out *recipient) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		if isTopLevel {
			in.Consumed()
		}
		in.Skip()
		return
	}
	in.Delim('{')
	for !in.IsDelim('}') {
		key := in.UnsafeFieldName(false)
		in.WantColon()
		if in.IsNull() {
			in.Skip()
			in.WantComma()
			continue
		}
		switch key {
		case "uuid":
			out.UUID = string(in.String())
		case "email":
			out.Email = string(in.String())
		case "name":
			out.Name = string(in.String())
		case "attribs":
			if in.IsNull() {
				in.Skip()
			} else {
				in.Delim('{')
				out.Attribs = make(models.JSON)
				for !in.IsDelim('}') {
					key := string(in.String())
					in.WantColon()
					var v23 interface{}
					if m, ok := v23.(easyjson.Unmarshaler); ok {
						m.UnmarshalEasyJSON(in)
					} else if m, ok := v23.(json.Unmarshaler); ok {
						_ = m.UnmarshalJSON(in.Raw())
					} else {
						v23 = in.Interface()
					}
					(out.Attribs)[key] = v23
					in.WantComma()
				}
				in.Delim('}')
			}
		case "status":
			out.Status = string(in.String())
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjsonDf11841fEncodeGithubComKnadhEagleCastInternalMessengerPostback1(out *jwriter.Writer, in recipient) {
	out.RawByte('{')
	first := true
	_ = first
	{
		const prefix string = ",\"uuid\":"
		out.RawString(prefix[1:])
		out.String(string(in.UUID))
	}
	{
		const prefix string = ",\"email\":"
		out.RawString(prefix)
		out.String(string(in.Email))
	}
	{
		const prefix string = ",\"name\":"
		out.RawString(prefix)
		out.String(string(in.Name))
	}
	{
		const prefix string = ",\"attribs\":"
		out.RawString(prefix)
		if in.Attribs == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 {
			out.RawString(`null`)
		} else {
			out.RawByte('{')
			v24First := true
			for v24Name, v24Value := range in.Attribs {
				if v24First {
					v24First = false
				} else {
					out.RawByte(',')
				}
				out.String(string(v24Name))
				out.RawByte(':')
				if m, ok := v24Value.(easyjson.Marshaler); ok {
					m.MarshalEasyJSON(out)
				} else if m, ok := v24Value.(json.Marshaler); ok {
					out.Raw(m.MarshalJSON())
				} else {
					out.Raw(json.Marshal(v24Value))
				}
			}
			out.RawByte('}')
		}
	}
	{
		const prefix string = ",\"status\":"
		out.RawString(prefix)
		out.String(string(in.Status))
	}
	out.RawByte('}')
}
