-
Notifications
You must be signed in to change notification settings - Fork 2
/
service3.getScheduledProducts.go
209 lines (182 loc) · 6.74 KB
/
service3.getScheduledProducts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// Copyright 2022 V Kontakte LLC
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
// Code generated by vktl/cmd/tlgen2; DO NOT EDIT.
package tlService3GetScheduledProducts
import (
"github.com/vkcom/tl/internal/tlcodegen/test/gen/schema/internal"
"github.com/vkcom/tl/internal/tlcodegen/test/gen/schema/internal/tl/tlBuiltinVectorInt"
"github.com/vkcom/tl/internal/tlcodegen/test/gen/schema/internal/tl/tlVectorService3Product0Maybe"
"github.com/vkcom/tl/pkg/basictl"
)
var _ = basictl.NatWrite
var _ = internal.ErrorInvalidEnumTag
type Service3GetScheduledProducts struct {
UserId int32
Types []int32
}
func (Service3GetScheduledProducts) TLName() string { return "service3.getScheduledProducts" }
func (Service3GetScheduledProducts) TLTag() uint32 { return 0xf53ad7bd }
func (item *Service3GetScheduledProducts) Reset() {
item.UserId = 0
item.Types = item.Types[:0]
}
func (item *Service3GetScheduledProducts) Read(w []byte) (_ []byte, err error) {
if w, err = basictl.IntRead(w, &item.UserId); err != nil {
return w, err
}
return tlBuiltinVectorInt.BuiltinVectorIntRead(w, &item.Types)
}
// This method is general version of Write, use it instead!
func (item *Service3GetScheduledProducts) WriteGeneral(w []byte) (_ []byte, err error) {
return item.Write(w), nil
}
func (item *Service3GetScheduledProducts) Write(w []byte) []byte {
w = basictl.IntWrite(w, item.UserId)
w = tlBuiltinVectorInt.BuiltinVectorIntWrite(w, item.Types)
return w
}
func (item *Service3GetScheduledProducts) ReadBoxed(w []byte) (_ []byte, err error) {
if w, err = basictl.NatReadExactTag(w, 0xf53ad7bd); err != nil {
return w, err
}
return item.Read(w)
}
// This method is general version of WriteBoxed, use it instead!
func (item *Service3GetScheduledProducts) WriteBoxedGeneral(w []byte) (_ []byte, err error) {
return item.WriteBoxed(w), nil
}
func (item *Service3GetScheduledProducts) WriteBoxed(w []byte) []byte {
w = basictl.NatWrite(w, 0xf53ad7bd)
return item.Write(w)
}
func (item *Service3GetScheduledProducts) ReadResult(w []byte, ret *tlVectorService3Product0Maybe.VectorService3Product0Maybe) (_ []byte, err error) {
return ret.ReadBoxed(w)
}
func (item *Service3GetScheduledProducts) WriteResult(w []byte, ret tlVectorService3Product0Maybe.VectorService3Product0Maybe) (_ []byte, err error) {
w = ret.WriteBoxed(w)
return w, nil
}
func (item *Service3GetScheduledProducts) ReadResultJSON(legacyTypeNames bool, in *basictl.JsonLexer, ret *tlVectorService3Product0Maybe.VectorService3Product0Maybe) error {
if err := ret.ReadJSON(legacyTypeNames, in); err != nil {
return err
}
return nil
}
func (item *Service3GetScheduledProducts) WriteResultJSON(w []byte, ret tlVectorService3Product0Maybe.VectorService3Product0Maybe) (_ []byte, err error) {
return item.writeResultJSON(true, false, w, ret)
}
func (item *Service3GetScheduledProducts) writeResultJSON(newTypeNames bool, short bool, w []byte, ret tlVectorService3Product0Maybe.VectorService3Product0Maybe) (_ []byte, err error) {
w = ret.WriteJSONOpt(newTypeNames, short, w)
return w, nil
}
func (item *Service3GetScheduledProducts) ReadResultWriteResultJSON(r []byte, w []byte) (_ []byte, _ []byte, err error) {
var ret tlVectorService3Product0Maybe.VectorService3Product0Maybe
if r, err = item.ReadResult(r, &ret); err != nil {
return r, w, err
}
w, err = item.WriteResultJSON(w, ret)
return r, w, err
}
func (item *Service3GetScheduledProducts) ReadResultWriteResultJSONOpt(newTypeNames bool, short bool, r []byte, w []byte) (_ []byte, _ []byte, err error) {
var ret tlVectorService3Product0Maybe.VectorService3Product0Maybe
if r, err = item.ReadResult(r, &ret); err != nil {
return r, w, err
}
w, err = item.writeResultJSON(newTypeNames, short, w, ret)
return r, w, err
}
func (item *Service3GetScheduledProducts) ReadResultJSONWriteResult(r []byte, w []byte) ([]byte, []byte, error) {
var ret tlVectorService3Product0Maybe.VectorService3Product0Maybe
err := item.ReadResultJSON(true, &basictl.JsonLexer{Data: r}, &ret)
if err != nil {
return r, w, err
}
w, err = item.WriteResult(w, ret)
return r, w, err
}
func (item Service3GetScheduledProducts) String() string {
return string(item.WriteJSON(nil))
}
func (item *Service3GetScheduledProducts) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error {
var propUserIdPresented bool
var propTypesPresented bool
if in != nil {
in.Delim('{')
if !in.Ok() {
return in.Error()
}
for !in.IsDelim('}') {
key := in.UnsafeFieldName(true)
in.WantColon()
switch key {
case "user_id":
if propUserIdPresented {
return internal.ErrorInvalidJSONWithDuplicatingKeys("service3.getScheduledProducts", "user_id")
}
if err := internal.Json2ReadInt32(in, &item.UserId); err != nil {
return err
}
propUserIdPresented = true
case "types":
if propTypesPresented {
return internal.ErrorInvalidJSONWithDuplicatingKeys("service3.getScheduledProducts", "types")
}
if err := tlBuiltinVectorInt.BuiltinVectorIntReadJSON(legacyTypeNames, in, &item.Types); err != nil {
return err
}
propTypesPresented = true
default:
return internal.ErrorInvalidJSONExcessElement("service3.getScheduledProducts", key)
}
in.WantComma()
}
in.Delim('}')
if !in.Ok() {
return in.Error()
}
}
if !propUserIdPresented {
item.UserId = 0
}
if !propTypesPresented {
item.Types = item.Types[:0]
}
return nil
}
// This method is general version of WriteJSON, use it instead!
func (item *Service3GetScheduledProducts) WriteJSONGeneral(w []byte) (_ []byte, err error) {
return item.WriteJSONOpt(true, false, w), nil
}
func (item *Service3GetScheduledProducts) WriteJSON(w []byte) []byte {
return item.WriteJSONOpt(true, false, w)
}
func (item *Service3GetScheduledProducts) WriteJSONOpt(newTypeNames bool, short bool, w []byte) []byte {
w = append(w, '{')
backupIndexUserId := len(w)
w = basictl.JSONAddCommaIfNeeded(w)
w = append(w, `"user_id":`...)
w = basictl.JSONWriteInt32(w, item.UserId)
if (item.UserId != 0) == false {
w = w[:backupIndexUserId]
}
backupIndexTypes := len(w)
w = basictl.JSONAddCommaIfNeeded(w)
w = append(w, `"types":`...)
w = tlBuiltinVectorInt.BuiltinVectorIntWriteJSONOpt(newTypeNames, short, w, item.Types)
if (len(item.Types) != 0) == false {
w = w[:backupIndexTypes]
}
return append(w, '}')
}
func (item *Service3GetScheduledProducts) MarshalJSON() ([]byte, error) {
return item.WriteJSON(nil), nil
}
func (item *Service3GetScheduledProducts) UnmarshalJSON(b []byte) error {
if err := item.ReadJSON(true, &basictl.JsonLexer{Data: b}); err != nil {
return internal.ErrorInvalidJSON("service3.getScheduledProducts", err.Error())
}
return nil
}