postback_easyjson.go 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. // Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
  2. package postback
  3. import (
  4. json "encoding/json"
  5. models "github.com/knadh/listmonk/models"
  6. easyjson "github.com/mailru/easyjson"
  7. jlexer "github.com/mailru/easyjson/jlexer"
  8. jwriter "github.com/mailru/easyjson/jwriter"
  9. )
  10. // suppress unused package warning
  11. var (
  12. _ *json.RawMessage
  13. _ *jlexer.Lexer
  14. _ *jwriter.Writer
  15. _ easyjson.Marshaler
  16. )
  17. func easyjsonDf11841fDecodeGithubComKnadhListmonkInternalMessengerPostback(in *jlexer.Lexer, out *postback) {
  18. isTopLevel := in.IsStart()
  19. if in.IsNull() {
  20. if isTopLevel {
  21. in.Consumed()
  22. }
  23. in.Skip()
  24. return
  25. }
  26. in.Delim('{')
  27. for !in.IsDelim('}') {
  28. key := in.UnsafeFieldName(false)
  29. in.WantColon()
  30. if in.IsNull() {
  31. in.Skip()
  32. in.WantComma()
  33. continue
  34. }
  35. switch key {
  36. case "subject":
  37. out.Subject = string(in.String())
  38. case "content_type":
  39. out.ContentType = string(in.String())
  40. case "body":
  41. out.Body = string(in.String())
  42. case "recipients":
  43. if in.IsNull() {
  44. in.Skip()
  45. out.Recipients = nil
  46. } else {
  47. in.Delim('[')
  48. if out.Recipients == nil {
  49. if !in.IsDelim(']') {
  50. out.Recipients = make([]recipient, 0, 0)
  51. } else {
  52. out.Recipients = []recipient{}
  53. }
  54. } else {
  55. out.Recipients = (out.Recipients)[:0]
  56. }
  57. for !in.IsDelim(']') {
  58. var v1 recipient
  59. easyjsonDf11841fDecodeGithubComKnadhListmonkInternalMessengerPostback1(in, &v1)
  60. out.Recipients = append(out.Recipients, v1)
  61. in.WantComma()
  62. }
  63. in.Delim(']')
  64. }
  65. case "campaign":
  66. if in.IsNull() {
  67. in.Skip()
  68. out.Campaign = nil
  69. } else {
  70. if out.Campaign == nil {
  71. out.Campaign = new(campaign)
  72. }
  73. easyjsonDf11841fDecodeGithubComKnadhListmonkInternalMessengerPostback2(in, out.Campaign)
  74. }
  75. default:
  76. in.SkipRecursive()
  77. }
  78. in.WantComma()
  79. }
  80. in.Delim('}')
  81. if isTopLevel {
  82. in.Consumed()
  83. }
  84. }
  85. func easyjsonDf11841fEncodeGithubComKnadhListmonkInternalMessengerPostback(out *jwriter.Writer, in postback) {
  86. out.RawByte('{')
  87. first := true
  88. _ = first
  89. {
  90. const prefix string = ",\"subject\":"
  91. out.RawString(prefix[1:])
  92. out.String(string(in.Subject))
  93. }
  94. {
  95. const prefix string = ",\"content_type\":"
  96. out.RawString(prefix)
  97. out.String(string(in.ContentType))
  98. }
  99. {
  100. const prefix string = ",\"body\":"
  101. out.RawString(prefix)
  102. out.String(string(in.Body))
  103. }
  104. {
  105. const prefix string = ",\"recipients\":"
  106. out.RawString(prefix)
  107. if in.Recipients == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
  108. out.RawString("null")
  109. } else {
  110. out.RawByte('[')
  111. for v2, v3 := range in.Recipients {
  112. if v2 > 0 {
  113. out.RawByte(',')
  114. }
  115. easyjsonDf11841fEncodeGithubComKnadhListmonkInternalMessengerPostback1(out, v3)
  116. }
  117. out.RawByte(']')
  118. }
  119. }
  120. {
  121. const prefix string = ",\"campaign\":"
  122. out.RawString(prefix)
  123. if in.Campaign == nil {
  124. out.RawString("null")
  125. } else {
  126. easyjsonDf11841fEncodeGithubComKnadhListmonkInternalMessengerPostback2(out, *in.Campaign)
  127. }
  128. }
  129. out.RawByte('}')
  130. }
  131. // MarshalJSON supports json.Marshaler interface
  132. func (v postback) MarshalJSON() ([]byte, error) {
  133. w := jwriter.Writer{}
  134. easyjsonDf11841fEncodeGithubComKnadhListmonkInternalMessengerPostback(&w, v)
  135. return w.Buffer.BuildBytes(), w.Error
  136. }
  137. // MarshalEasyJSON supports easyjson.Marshaler interface
  138. func (v postback) MarshalEasyJSON(w *jwriter.Writer) {
  139. easyjsonDf11841fEncodeGithubComKnadhListmonkInternalMessengerPostback(w, v)
  140. }
  141. // UnmarshalJSON supports json.Unmarshaler interface
  142. func (v *postback) UnmarshalJSON(data []byte) error {
  143. r := jlexer.Lexer{Data: data}
  144. easyjsonDf11841fDecodeGithubComKnadhListmonkInternalMessengerPostback(&r, v)
  145. return r.Error()
  146. }
  147. // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
  148. func (v *postback) UnmarshalEasyJSON(l *jlexer.Lexer) {
  149. easyjsonDf11841fDecodeGithubComKnadhListmonkInternalMessengerPostback(l, v)
  150. }
  151. func easyjsonDf11841fDecodeGithubComKnadhListmonkInternalMessengerPostback2(in *jlexer.Lexer, out *campaign) {
  152. isTopLevel := in.IsStart()
  153. if in.IsNull() {
  154. if isTopLevel {
  155. in.Consumed()
  156. }
  157. in.Skip()
  158. return
  159. }
  160. in.Delim('{')
  161. for !in.IsDelim('}') {
  162. key := in.UnsafeFieldName(false)
  163. in.WantColon()
  164. if in.IsNull() {
  165. in.Skip()
  166. in.WantComma()
  167. continue
  168. }
  169. switch key {
  170. case "uuid":
  171. out.UUID = string(in.String())
  172. case "name":
  173. out.Name = string(in.String())
  174. case "tags":
  175. if in.IsNull() {
  176. in.Skip()
  177. out.Tags = nil
  178. } else {
  179. in.Delim('[')
  180. if out.Tags == nil {
  181. if !in.IsDelim(']') {
  182. out.Tags = make([]string, 0, 4)
  183. } else {
  184. out.Tags = []string{}
  185. }
  186. } else {
  187. out.Tags = (out.Tags)[:0]
  188. }
  189. for !in.IsDelim(']') {
  190. var v4 string
  191. v4 = string(in.String())
  192. out.Tags = append(out.Tags, v4)
  193. in.WantComma()
  194. }
  195. in.Delim(']')
  196. }
  197. default:
  198. in.SkipRecursive()
  199. }
  200. in.WantComma()
  201. }
  202. in.Delim('}')
  203. if isTopLevel {
  204. in.Consumed()
  205. }
  206. }
  207. func easyjsonDf11841fEncodeGithubComKnadhListmonkInternalMessengerPostback2(out *jwriter.Writer, in campaign) {
  208. out.RawByte('{')
  209. first := true
  210. _ = first
  211. {
  212. const prefix string = ",\"uuid\":"
  213. out.RawString(prefix[1:])
  214. out.String(string(in.UUID))
  215. }
  216. {
  217. const prefix string = ",\"name\":"
  218. out.RawString(prefix)
  219. out.String(string(in.Name))
  220. }
  221. {
  222. const prefix string = ",\"tags\":"
  223. out.RawString(prefix)
  224. if in.Tags == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
  225. out.RawString("null")
  226. } else {
  227. out.RawByte('[')
  228. for v5, v6 := range in.Tags {
  229. if v5 > 0 {
  230. out.RawByte(',')
  231. }
  232. out.String(string(v6))
  233. }
  234. out.RawByte(']')
  235. }
  236. }
  237. out.RawByte('}')
  238. }
  239. func easyjsonDf11841fDecodeGithubComKnadhListmonkInternalMessengerPostback1(in *jlexer.Lexer, out *recipient) {
  240. isTopLevel := in.IsStart()
  241. if in.IsNull() {
  242. if isTopLevel {
  243. in.Consumed()
  244. }
  245. in.Skip()
  246. return
  247. }
  248. in.Delim('{')
  249. for !in.IsDelim('}') {
  250. key := in.UnsafeFieldName(false)
  251. in.WantColon()
  252. if in.IsNull() {
  253. in.Skip()
  254. in.WantComma()
  255. continue
  256. }
  257. switch key {
  258. case "uuid":
  259. out.UUID = string(in.String())
  260. case "email":
  261. out.Email = string(in.String())
  262. case "name":
  263. out.Name = string(in.String())
  264. case "attribs":
  265. if in.IsNull() {
  266. in.Skip()
  267. } else {
  268. in.Delim('{')
  269. out.Attribs = make(models.SubscriberAttribs)
  270. for !in.IsDelim('}') {
  271. key := string(in.String())
  272. in.WantColon()
  273. var v7 interface{}
  274. if m, ok := v7.(easyjson.Unmarshaler); ok {
  275. m.UnmarshalEasyJSON(in)
  276. } else if m, ok := v7.(json.Unmarshaler); ok {
  277. _ = m.UnmarshalJSON(in.Raw())
  278. } else {
  279. v7 = in.Interface()
  280. }
  281. (out.Attribs)[key] = v7
  282. in.WantComma()
  283. }
  284. in.Delim('}')
  285. }
  286. case "status":
  287. out.Status = string(in.String())
  288. default:
  289. in.SkipRecursive()
  290. }
  291. in.WantComma()
  292. }
  293. in.Delim('}')
  294. if isTopLevel {
  295. in.Consumed()
  296. }
  297. }
  298. func easyjsonDf11841fEncodeGithubComKnadhListmonkInternalMessengerPostback1(out *jwriter.Writer, in recipient) {
  299. out.RawByte('{')
  300. first := true
  301. _ = first
  302. {
  303. const prefix string = ",\"uuid\":"
  304. out.RawString(prefix[1:])
  305. out.String(string(in.UUID))
  306. }
  307. {
  308. const prefix string = ",\"email\":"
  309. out.RawString(prefix)
  310. out.String(string(in.Email))
  311. }
  312. {
  313. const prefix string = ",\"name\":"
  314. out.RawString(prefix)
  315. out.String(string(in.Name))
  316. }
  317. {
  318. const prefix string = ",\"attribs\":"
  319. out.RawString(prefix)
  320. if in.Attribs == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 {
  321. out.RawString(`null`)
  322. } else {
  323. out.RawByte('{')
  324. v8First := true
  325. for v8Name, v8Value := range in.Attribs {
  326. if v8First {
  327. v8First = false
  328. } else {
  329. out.RawByte(',')
  330. }
  331. out.String(string(v8Name))
  332. out.RawByte(':')
  333. if m, ok := v8Value.(easyjson.Marshaler); ok {
  334. m.MarshalEasyJSON(out)
  335. } else if m, ok := v8Value.(json.Marshaler); ok {
  336. out.Raw(m.MarshalJSON())
  337. } else {
  338. out.Raw(json.Marshal(v8Value))
  339. }
  340. }
  341. out.RawByte('}')
  342. }
  343. }
  344. {
  345. const prefix string = ",\"status\":"
  346. out.RawString(prefix)
  347. out.String(string(in.Status))
  348. }
  349. out.RawByte('}')
  350. }