-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoints.go
More file actions
458 lines (395 loc) · 12.9 KB
/
Copy pathpoints.go
File metadata and controls
458 lines (395 loc) · 12.9 KB
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
// Code generated by Fern. DO NOT EDIT.
package api
import (
json "encoding/json"
fmt "fmt"
internal "github.com/trophyso/trophy-go/internal"
big "math/big"
)
var (
pointsBoostsRequestFieldIncludeFinished = big.NewInt(1 << 0)
)
type PointsBoostsRequest struct {
// When set to 'true', boosts that have finished (past their end date) will be included in the response. By default, finished boosts are excluded.
IncludeFinished *bool `json:"-" url:"includeFinished,omitempty"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
}
func (p *PointsBoostsRequest) require(field *big.Int) {
if p.explicitFields == nil {
p.explicitFields = big.NewInt(0)
}
p.explicitFields.Or(p.explicitFields, field)
}
// SetIncludeFinished sets the IncludeFinished field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PointsBoostsRequest) SetIncludeFinished(includeFinished *bool) {
p.IncludeFinished = includeFinished
p.require(pointsBoostsRequestFieldIncludeFinished)
}
var (
pointsSummaryRequestFieldUserAttributes = big.NewInt(1 << 0)
)
type PointsSummaryRequest struct {
// Optional colon-delimited user attribute filters in the format attribute:value,attribute:value. Only users matching ALL specified attributes will be included in the points breakdown.
UserAttributes *string `json:"-" url:"userAttributes,omitempty"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
}
func (p *PointsSummaryRequest) require(field *big.Int) {
if p.explicitFields == nil {
p.explicitFields = big.NewInt(0)
}
p.explicitFields.Or(p.explicitFields, field)
}
// SetUserAttributes sets the UserAttributes field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PointsSummaryRequest) SetUserAttributes(userAttributes *string) {
p.UserAttributes = userAttributes
p.require(pointsSummaryRequestFieldUserAttributes)
}
// A breakdown of users by level in a points system.
type PointsLevelSummaryResponse = []*PointsLevelSummaryResponseItem
var (
pointsLevelSummaryResponseItemFieldLevel = big.NewInt(1 << 0)
pointsLevelSummaryResponseItemFieldUsers = big.NewInt(1 << 1)
)
type PointsLevelSummaryResponseItem struct {
Level *PointsLevel `json:"level" url:"level"`
// The number of users currently at this level
Users int `json:"users" url:"users"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (p *PointsLevelSummaryResponseItem) GetLevel() *PointsLevel {
if p == nil {
return nil
}
return p.Level
}
func (p *PointsLevelSummaryResponseItem) GetUsers() int {
if p == nil {
return 0
}
return p.Users
}
func (p *PointsLevelSummaryResponseItem) GetExtraProperties() map[string]interface{} {
if p == nil {
return nil
}
return p.extraProperties
}
func (p *PointsLevelSummaryResponseItem) require(field *big.Int) {
if p.explicitFields == nil {
p.explicitFields = big.NewInt(0)
}
p.explicitFields.Or(p.explicitFields, field)
}
// SetLevel sets the Level field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PointsLevelSummaryResponseItem) SetLevel(level *PointsLevel) {
p.Level = level
p.require(pointsLevelSummaryResponseItemFieldLevel)
}
// SetUsers sets the Users field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PointsLevelSummaryResponseItem) SetUsers(users int) {
p.Users = users
p.require(pointsLevelSummaryResponseItemFieldUsers)
}
func (p *PointsLevelSummaryResponseItem) UnmarshalJSON(data []byte) error {
type unmarshaler PointsLevelSummaryResponseItem
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*p = PointsLevelSummaryResponseItem(value)
extraProperties, err := internal.ExtractExtraProperties(data, *p)
if err != nil {
return err
}
p.extraProperties = extraProperties
p.rawJSON = json.RawMessage(data)
return nil
}
func (p *PointsLevelSummaryResponseItem) MarshalJSON() ([]byte, error) {
type embed PointsLevelSummaryResponseItem
var marshaler = struct {
embed
}{
embed: embed(*p),
}
explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields)
return json.Marshal(explicitMarshaler)
}
func (p *PointsLevelSummaryResponseItem) String() string {
if p == nil {
return "<nil>"
}
if len(p.rawJSON) > 0 {
if value, err := internal.StringifyJSON(p.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(p); err == nil {
return value
}
return fmt.Sprintf("%#v", p)
}
var (
pointsRangeFieldFrom = big.NewInt(1 << 0)
pointsRangeFieldTo = big.NewInt(1 << 1)
pointsRangeFieldUsers = big.NewInt(1 << 2)
)
type PointsRange struct {
// The start of the points range. Inclusive.
From int `json:"from" url:"from"`
// The end of the points range. Inclusive.
To int `json:"to" url:"to"`
// The number of users in this points range.
Users int `json:"users" url:"users"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (p *PointsRange) GetFrom() int {
if p == nil {
return 0
}
return p.From
}
func (p *PointsRange) GetTo() int {
if p == nil {
return 0
}
return p.To
}
func (p *PointsRange) GetUsers() int {
if p == nil {
return 0
}
return p.Users
}
func (p *PointsRange) GetExtraProperties() map[string]interface{} {
if p == nil {
return nil
}
return p.extraProperties
}
func (p *PointsRange) require(field *big.Int) {
if p.explicitFields == nil {
p.explicitFields = big.NewInt(0)
}
p.explicitFields.Or(p.explicitFields, field)
}
// SetFrom sets the From field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PointsRange) SetFrom(from int) {
p.From = from
p.require(pointsRangeFieldFrom)
}
// SetTo sets the To field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PointsRange) SetTo(to int) {
p.To = to
p.require(pointsRangeFieldTo)
}
// SetUsers sets the Users field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PointsRange) SetUsers(users int) {
p.Users = users
p.require(pointsRangeFieldUsers)
}
func (p *PointsRange) UnmarshalJSON(data []byte) error {
type unmarshaler PointsRange
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*p = PointsRange(value)
extraProperties, err := internal.ExtractExtraProperties(data, *p)
if err != nil {
return err
}
p.extraProperties = extraProperties
p.rawJSON = json.RawMessage(data)
return nil
}
func (p *PointsRange) MarshalJSON() ([]byte, error) {
type embed PointsRange
var marshaler = struct {
embed
}{
embed: embed(*p),
}
explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields)
return json.Marshal(explicitMarshaler)
}
func (p *PointsRange) String() string {
if p == nil {
return "<nil>"
}
if len(p.rawJSON) > 0 {
if value, err := internal.StringifyJSON(p.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(p); err == nil {
return value
}
return fmt.Sprintf("%#v", p)
}
// A list of eleven points ranges, with the first starting and ending at 0, and the remaining 10 being calculated as 10 equally sized ranges from 1 to the greatest number of points a user has, rounded up to the nearest power of 10.
type PointsSummaryResponse = []*PointsRange
var (
pointsSystemResponseFieldId = big.NewInt(1 << 0)
pointsSystemResponseFieldName = big.NewInt(1 << 1)
pointsSystemResponseFieldDescription = big.NewInt(1 << 2)
pointsSystemResponseFieldBadgeUrl = big.NewInt(1 << 3)
pointsSystemResponseFieldMaxPoints = big.NewInt(1 << 4)
pointsSystemResponseFieldTriggers = big.NewInt(1 << 5)
)
type PointsSystemResponse struct {
// The unique ID of the points system.
Id string `json:"id" url:"id"`
// The name of the points system.
Name string `json:"name" url:"name"`
// The description of the points system.
Description *string `json:"description,omitempty" url:"description,omitempty"`
// The URL of the badge image for the points system, if one has been uploaded.
BadgeUrl *string `json:"badgeUrl,omitempty" url:"badgeUrl,omitempty"`
// The maximum number of points a user can be awarded in this points system
MaxPoints *float64 `json:"maxPoints,omitempty" url:"maxPoints,omitempty"`
// Array of active triggers for this points system.
Triggers []*PointsTrigger `json:"triggers" url:"triggers"`
// Private bitmask of fields set to an explicit value and therefore not to be omitted
explicitFields *big.Int `json:"-" url:"-"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (p *PointsSystemResponse) GetId() string {
if p == nil {
return ""
}
return p.Id
}
func (p *PointsSystemResponse) GetName() string {
if p == nil {
return ""
}
return p.Name
}
func (p *PointsSystemResponse) GetDescription() *string {
if p == nil {
return nil
}
return p.Description
}
func (p *PointsSystemResponse) GetBadgeUrl() *string {
if p == nil {
return nil
}
return p.BadgeUrl
}
func (p *PointsSystemResponse) GetMaxPoints() *float64 {
if p == nil {
return nil
}
return p.MaxPoints
}
func (p *PointsSystemResponse) GetTriggers() []*PointsTrigger {
if p == nil {
return nil
}
return p.Triggers
}
func (p *PointsSystemResponse) GetExtraProperties() map[string]interface{} {
if p == nil {
return nil
}
return p.extraProperties
}
func (p *PointsSystemResponse) require(field *big.Int) {
if p.explicitFields == nil {
p.explicitFields = big.NewInt(0)
}
p.explicitFields.Or(p.explicitFields, field)
}
// SetId sets the Id field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PointsSystemResponse) SetId(id string) {
p.Id = id
p.require(pointsSystemResponseFieldId)
}
// SetName sets the Name field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PointsSystemResponse) SetName(name string) {
p.Name = name
p.require(pointsSystemResponseFieldName)
}
// SetDescription sets the Description field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PointsSystemResponse) SetDescription(description *string) {
p.Description = description
p.require(pointsSystemResponseFieldDescription)
}
// SetBadgeUrl sets the BadgeUrl field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PointsSystemResponse) SetBadgeUrl(badgeUrl *string) {
p.BadgeUrl = badgeUrl
p.require(pointsSystemResponseFieldBadgeUrl)
}
// SetMaxPoints sets the MaxPoints field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PointsSystemResponse) SetMaxPoints(maxPoints *float64) {
p.MaxPoints = maxPoints
p.require(pointsSystemResponseFieldMaxPoints)
}
// SetTriggers sets the Triggers field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PointsSystemResponse) SetTriggers(triggers []*PointsTrigger) {
p.Triggers = triggers
p.require(pointsSystemResponseFieldTriggers)
}
func (p *PointsSystemResponse) UnmarshalJSON(data []byte) error {
type unmarshaler PointsSystemResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*p = PointsSystemResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *p)
if err != nil {
return err
}
p.extraProperties = extraProperties
p.rawJSON = json.RawMessage(data)
return nil
}
func (p *PointsSystemResponse) MarshalJSON() ([]byte, error) {
type embed PointsSystemResponse
var marshaler = struct {
embed
}{
embed: embed(*p),
}
explicitMarshaler := internal.HandleExplicitFields(marshaler, p.explicitFields)
return json.Marshal(explicitMarshaler)
}
func (p *PointsSystemResponse) String() string {
if p == nil {
return "<nil>"
}
if len(p.rawJSON) > 0 {
if value, err := internal.StringifyJSON(p.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(p); err == nil {
return value
}
return fmt.Sprintf("%#v", p)
}