-
Notifications
You must be signed in to change notification settings - Fork 1
/
events.go
694 lines (611 loc) · 18 KB
/
events.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
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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
// This file was auto-generated by Fern from our API Definition.
package square
import (
json "encoding/json"
fmt "fmt"
internal "github.com/square/square-go-sdk/internal"
)
type ListEventTypesRequest struct {
// The API version for which to list event types. Setting this field overrides the default version used by the application.
APIVersion *string `json:"-" url:"api_version,omitempty"`
}
type SearchEventsRequest struct {
// A pagination cursor returned by a previous call to this endpoint. Provide this cursor to retrieve the next set of events for your original query.
//
// For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).
Cursor *string `json:"cursor,omitempty" url:"-"`
// The maximum number of events to return in a single page. The response might contain fewer events. The default value is 100, which is also the maximum allowed value.
//
// For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).
//
// Default: 100
Limit *int `json:"limit,omitempty" url:"-"`
// The filtering and sorting criteria for the search request. To retrieve additional pages using a cursor, you must use the original query.
Query *SearchEventsQuery `json:"query,omitempty" url:"-"`
}
// Defines the fields that are included in the response body of
// a request to the [DisableEvents](api-endpoint:Events-DisableEvents) endpoint.
//
// Note: if there are errors processing the request, the events field will not be
// present.
type DisableEventsResponse struct {
// Information on errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (d *DisableEventsResponse) GetErrors() []*Error {
if d == nil {
return nil
}
return d.Errors
}
func (d *DisableEventsResponse) GetExtraProperties() map[string]interface{} {
return d.extraProperties
}
func (d *DisableEventsResponse) UnmarshalJSON(data []byte) error {
type unmarshaler DisableEventsResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*d = DisableEventsResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *d)
if err != nil {
return err
}
d.extraProperties = extraProperties
d.rawJSON = json.RawMessage(data)
return nil
}
func (d *DisableEventsResponse) String() string {
if len(d.rawJSON) > 0 {
if value, err := internal.StringifyJSON(d.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(d); err == nil {
return value
}
return fmt.Sprintf("%#v", d)
}
// Defines the fields that are included in the response body of
// a request to the [EnableEvents](api-endpoint:Events-EnableEvents) endpoint.
//
// Note: if there are errors processing the request, the events field will not be
// present.
type EnableEventsResponse struct {
// Information on errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (e *EnableEventsResponse) GetErrors() []*Error {
if e == nil {
return nil
}
return e.Errors
}
func (e *EnableEventsResponse) GetExtraProperties() map[string]interface{} {
return e.extraProperties
}
func (e *EnableEventsResponse) UnmarshalJSON(data []byte) error {
type unmarshaler EnableEventsResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*e = EnableEventsResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *e)
if err != nil {
return err
}
e.extraProperties = extraProperties
e.rawJSON = json.RawMessage(data)
return nil
}
func (e *EnableEventsResponse) String() string {
if len(e.rawJSON) > 0 {
if value, err := internal.StringifyJSON(e.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(e); err == nil {
return value
}
return fmt.Sprintf("%#v", e)
}
type Event struct {
// The ID of the target merchant associated with the event.
MerchantID *string `json:"merchant_id,omitempty" url:"merchant_id,omitempty"`
// The ID of the target location associated with the event.
LocationID *string `json:"location_id,omitempty" url:"location_id,omitempty"`
// The type of event this represents.
Type *string `json:"type,omitempty" url:"type,omitempty"`
// A unique ID for the event.
EventID *string `json:"event_id,omitempty" url:"event_id,omitempty"`
// Timestamp of when the event was created, in RFC 3339 format.
CreatedAt *string `json:"created_at,omitempty" url:"created_at,omitempty"`
// The data associated with the event.
Data *EventData `json:"data,omitempty" url:"data,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (e *Event) GetMerchantID() *string {
if e == nil {
return nil
}
return e.MerchantID
}
func (e *Event) GetLocationID() *string {
if e == nil {
return nil
}
return e.LocationID
}
func (e *Event) GetType() *string {
if e == nil {
return nil
}
return e.Type
}
func (e *Event) GetEventID() *string {
if e == nil {
return nil
}
return e.EventID
}
func (e *Event) GetCreatedAt() *string {
if e == nil {
return nil
}
return e.CreatedAt
}
func (e *Event) GetData() *EventData {
if e == nil {
return nil
}
return e.Data
}
func (e *Event) GetExtraProperties() map[string]interface{} {
return e.extraProperties
}
func (e *Event) UnmarshalJSON(data []byte) error {
type unmarshaler Event
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*e = Event(value)
extraProperties, err := internal.ExtractExtraProperties(data, *e)
if err != nil {
return err
}
e.extraProperties = extraProperties
e.rawJSON = json.RawMessage(data)
return nil
}
func (e *Event) String() string {
if len(e.rawJSON) > 0 {
if value, err := internal.StringifyJSON(e.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(e); err == nil {
return value
}
return fmt.Sprintf("%#v", e)
}
type EventData struct {
// The name of the affected object’s type.
Type *string `json:"type,omitempty" url:"type,omitempty"`
// The ID of the affected object.
ID *string `json:"id,omitempty" url:"id,omitempty"`
// This is true if the affected object has been deleted; otherwise, it's absent.
Deleted *bool `json:"deleted,omitempty" url:"deleted,omitempty"`
// An object containing fields and values relevant to the event. It is absent if the affected object has been deleted.
Object map[string]interface{} `json:"object,omitempty" url:"object,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (e *EventData) GetType() *string {
if e == nil {
return nil
}
return e.Type
}
func (e *EventData) GetID() *string {
if e == nil {
return nil
}
return e.ID
}
func (e *EventData) GetDeleted() *bool {
if e == nil {
return nil
}
return e.Deleted
}
func (e *EventData) GetObject() map[string]interface{} {
if e == nil {
return nil
}
return e.Object
}
func (e *EventData) GetExtraProperties() map[string]interface{} {
return e.extraProperties
}
func (e *EventData) UnmarshalJSON(data []byte) error {
type unmarshaler EventData
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*e = EventData(value)
extraProperties, err := internal.ExtractExtraProperties(data, *e)
if err != nil {
return err
}
e.extraProperties = extraProperties
e.rawJSON = json.RawMessage(data)
return nil
}
func (e *EventData) String() string {
if len(e.rawJSON) > 0 {
if value, err := internal.StringifyJSON(e.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(e); err == nil {
return value
}
return fmt.Sprintf("%#v", e)
}
// Contains metadata about a particular [Event](entity:Event).
type EventMetadata struct {
// A unique ID for the event.
EventID *string `json:"event_id,omitempty" url:"event_id,omitempty"`
// The API version of the event. This corresponds to the default API version of the developer application at the time when the event was created.
APIVersion *string `json:"api_version,omitempty" url:"api_version,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (e *EventMetadata) GetEventID() *string {
if e == nil {
return nil
}
return e.EventID
}
func (e *EventMetadata) GetAPIVersion() *string {
if e == nil {
return nil
}
return e.APIVersion
}
func (e *EventMetadata) GetExtraProperties() map[string]interface{} {
return e.extraProperties
}
func (e *EventMetadata) UnmarshalJSON(data []byte) error {
type unmarshaler EventMetadata
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*e = EventMetadata(value)
extraProperties, err := internal.ExtractExtraProperties(data, *e)
if err != nil {
return err
}
e.extraProperties = extraProperties
e.rawJSON = json.RawMessage(data)
return nil
}
func (e *EventMetadata) String() string {
if len(e.rawJSON) > 0 {
if value, err := internal.StringifyJSON(e.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(e); err == nil {
return value
}
return fmt.Sprintf("%#v", e)
}
// Defines the fields that are included in the response body of
// a request to the [ListEventTypes](api-endpoint:Events-ListEventTypes) endpoint.
//
// Note: if there are errors processing the request, the event types field will not be
// present.
type ListEventTypesResponse struct {
// Information on errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The list of event types.
EventTypes []string `json:"event_types,omitempty" url:"event_types,omitempty"`
// Contains the metadata of an event type. For more information, see [EventTypeMetadata](entity:EventTypeMetadata).
Metadata []*EventTypeMetadata `json:"metadata,omitempty" url:"metadata,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (l *ListEventTypesResponse) GetErrors() []*Error {
if l == nil {
return nil
}
return l.Errors
}
func (l *ListEventTypesResponse) GetEventTypes() []string {
if l == nil {
return nil
}
return l.EventTypes
}
func (l *ListEventTypesResponse) GetMetadata() []*EventTypeMetadata {
if l == nil {
return nil
}
return l.Metadata
}
func (l *ListEventTypesResponse) GetExtraProperties() map[string]interface{} {
return l.extraProperties
}
func (l *ListEventTypesResponse) UnmarshalJSON(data []byte) error {
type unmarshaler ListEventTypesResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*l = ListEventTypesResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *l)
if err != nil {
return err
}
l.extraProperties = extraProperties
l.rawJSON = json.RawMessage(data)
return nil
}
func (l *ListEventTypesResponse) String() string {
if len(l.rawJSON) > 0 {
if value, err := internal.StringifyJSON(l.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(l); err == nil {
return value
}
return fmt.Sprintf("%#v", l)
}
// Criteria to filter events by.
type SearchEventsFilter struct {
// Filter events by event types.
EventTypes []string `json:"event_types,omitempty" url:"event_types,omitempty"`
// Filter events by merchant.
MerchantIDs []string `json:"merchant_ids,omitempty" url:"merchant_ids,omitempty"`
// Filter events by location.
LocationIDs []string `json:"location_ids,omitempty" url:"location_ids,omitempty"`
// Filter events by when they were created.
CreatedAt *TimeRange `json:"created_at,omitempty" url:"created_at,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (s *SearchEventsFilter) GetEventTypes() []string {
if s == nil {
return nil
}
return s.EventTypes
}
func (s *SearchEventsFilter) GetMerchantIDs() []string {
if s == nil {
return nil
}
return s.MerchantIDs
}
func (s *SearchEventsFilter) GetLocationIDs() []string {
if s == nil {
return nil
}
return s.LocationIDs
}
func (s *SearchEventsFilter) GetCreatedAt() *TimeRange {
if s == nil {
return nil
}
return s.CreatedAt
}
func (s *SearchEventsFilter) GetExtraProperties() map[string]interface{} {
return s.extraProperties
}
func (s *SearchEventsFilter) UnmarshalJSON(data []byte) error {
type unmarshaler SearchEventsFilter
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SearchEventsFilter(value)
extraProperties, err := internal.ExtractExtraProperties(data, *s)
if err != nil {
return err
}
s.extraProperties = extraProperties
s.rawJSON = json.RawMessage(data)
return nil
}
func (s *SearchEventsFilter) String() string {
if len(s.rawJSON) > 0 {
if value, err := internal.StringifyJSON(s.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(s); err == nil {
return value
}
return fmt.Sprintf("%#v", s)
}
// Contains query criteria for the search.
type SearchEventsQuery struct {
// Criteria to filter events by.
Filter *SearchEventsFilter `json:"filter,omitempty" url:"filter,omitempty"`
// Criteria to sort events by.
Sort *SearchEventsSort `json:"sort,omitempty" url:"sort,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (s *SearchEventsQuery) GetFilter() *SearchEventsFilter {
if s == nil {
return nil
}
return s.Filter
}
func (s *SearchEventsQuery) GetSort() *SearchEventsSort {
if s == nil {
return nil
}
return s.Sort
}
func (s *SearchEventsQuery) GetExtraProperties() map[string]interface{} {
return s.extraProperties
}
func (s *SearchEventsQuery) UnmarshalJSON(data []byte) error {
type unmarshaler SearchEventsQuery
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SearchEventsQuery(value)
extraProperties, err := internal.ExtractExtraProperties(data, *s)
if err != nil {
return err
}
s.extraProperties = extraProperties
s.rawJSON = json.RawMessage(data)
return nil
}
func (s *SearchEventsQuery) String() string {
if len(s.rawJSON) > 0 {
if value, err := internal.StringifyJSON(s.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(s); err == nil {
return value
}
return fmt.Sprintf("%#v", s)
}
// Defines the fields that are included in the response body of
// a request to the [SearchEvents](api-endpoint:Events-SearchEvents) endpoint.
//
// Note: if there are errors processing the request, the events field will not be
// present.
type SearchEventsResponse struct {
// Information on errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The list of [Event](entity:Event)s returned by the search.
Events []*Event `json:"events,omitempty" url:"events,omitempty"`
// Contains the metadata of an event. For more information, see [Event](entity:Event).
Metadata []*EventMetadata `json:"metadata,omitempty" url:"metadata,omitempty"`
// When a response is truncated, it includes a cursor that you can use in a subsequent request to fetch the next set of events. If empty, this is the final response.
//
// For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).
Cursor *string `json:"cursor,omitempty" url:"cursor,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (s *SearchEventsResponse) GetErrors() []*Error {
if s == nil {
return nil
}
return s.Errors
}
func (s *SearchEventsResponse) GetEvents() []*Event {
if s == nil {
return nil
}
return s.Events
}
func (s *SearchEventsResponse) GetMetadata() []*EventMetadata {
if s == nil {
return nil
}
return s.Metadata
}
func (s *SearchEventsResponse) GetCursor() *string {
if s == nil {
return nil
}
return s.Cursor
}
func (s *SearchEventsResponse) GetExtraProperties() map[string]interface{} {
return s.extraProperties
}
func (s *SearchEventsResponse) UnmarshalJSON(data []byte) error {
type unmarshaler SearchEventsResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SearchEventsResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *s)
if err != nil {
return err
}
s.extraProperties = extraProperties
s.rawJSON = json.RawMessage(data)
return nil
}
func (s *SearchEventsResponse) String() string {
if len(s.rawJSON) > 0 {
if value, err := internal.StringifyJSON(s.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(s); err == nil {
return value
}
return fmt.Sprintf("%#v", s)
}
// Criteria to sort events by.
type SearchEventsSort struct {
// Sort events by event types.
// See [SearchEventsSortField](#type-searcheventssortfield) for possible values
Field *SearchEventsSortField `json:"field,omitempty" url:"field,omitempty"`
// The order to use for sorting the events.
// See [SortOrder](#type-sortorder) for possible values
Order *SortOrder `json:"order,omitempty" url:"order,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (s *SearchEventsSort) GetOrder() *SortOrder {
if s == nil {
return nil
}
return s.Order
}
func (s *SearchEventsSort) GetExtraProperties() map[string]interface{} {
return s.extraProperties
}
func (s *SearchEventsSort) UnmarshalJSON(data []byte) error {
type unmarshaler SearchEventsSort
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SearchEventsSort(value)
extraProperties, err := internal.ExtractExtraProperties(data, *s)
if err != nil {
return err
}
s.extraProperties = extraProperties
s.rawJSON = json.RawMessage(data)
return nil
}
func (s *SearchEventsSort) String() string {
if len(s.rawJSON) > 0 {
if value, err := internal.StringifyJSON(s.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(s); err == nil {
return value
}
return fmt.Sprintf("%#v", s)
}
// Specifies the sort key for events returned from a search.
type SearchEventsSortField = string