-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathorders.go
1213 lines (1077 loc) · 35.3 KB
/
orders.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
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// 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 BatchGetOrdersRequest struct {
// The ID of the location for these orders. This field is optional: omit it to retrieve
// orders within the scope of the current authorization's merchant ID.
LocationID *string `json:"location_id,omitempty" url:"-"`
// The IDs of the orders to retrieve. A maximum of 100 orders can be retrieved per request.
OrderIDs []string `json:"order_ids,omitempty" url:"-"`
}
type CalculateOrderRequest struct {
// The order to be calculated. Expects the entire order, not a sparse update.
Order *Order `json:"order,omitempty" url:"-"`
// Identifies one or more loyalty reward tiers to apply during the order calculation.
// The discounts defined by the reward tiers are added to the order only to preview the
// effect of applying the specified rewards. The rewards do not correspond to actual
// redemptions; that is, no `reward`s are created. Therefore, the reward `id`s are
// random strings used only to reference the reward tier.
ProposedRewards []*OrderReward `json:"proposed_rewards,omitempty" url:"-"`
}
type CloneOrderRequest struct {
// The ID of the order to clone.
OrderID string `json:"order_id" url:"-"`
// An optional order version for concurrency protection.
//
// If a version is provided, it must match the latest stored version of the order to clone.
// If a version is not provided, the API clones the latest version.
Version *int `json:"version,omitempty" url:"-"`
// A value you specify that uniquely identifies this clone request.
//
// If you are unsure whether a particular order was cloned successfully,
// you can reattempt the call with the same idempotency key without
// worrying about creating duplicate cloned orders.
// The originally cloned order is returned.
//
// For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).
IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"`
}
type OrdersGetRequest struct {
// The ID of the order to retrieve.
OrderID string `json:"-" url:"-"`
}
type PayOrderRequest struct {
// The ID of the order being paid.
OrderID string `json:"-" url:"-"`
// A value you specify that uniquely identifies this request among requests you have sent. If
// you are unsure whether a particular payment request was completed successfully, you can reattempt
// it with the same idempotency key without worrying about duplicate payments.
//
// For more information, see [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency).
IdempotencyKey string `json:"idempotency_key" url:"-"`
// The version of the order being paid. If not supplied, the latest version will be paid.
OrderVersion *int `json:"order_version,omitempty" url:"-"`
// The IDs of the [payments](entity:Payment) to collect.
// The payment total must match the order total.
PaymentIDs []string `json:"payment_ids,omitempty" url:"-"`
}
type SearchOrdersRequest struct {
// The location IDs for the orders to query. All locations must belong to
// the same merchant.
//
// Max: 10 location IDs.
LocationIDs []string `json:"location_ids,omitempty" url:"-"`
// A pagination cursor returned by a previous call to this endpoint.
// Provide this cursor to retrieve the next set of results 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:"-"`
// Query conditions used to filter or sort the results. Note that when
// retrieving additional pages using a cursor, you must use the original query.
Query *SearchOrdersQuery `json:"query,omitempty" url:"-"`
// The maximum number of results to be returned in a single page.
//
// Default: `500`
// Max: `1000`
Limit *int `json:"limit,omitempty" url:"-"`
// A Boolean that controls the format of the search results. If `true`,
// `SearchOrders` returns [OrderEntry](entity:OrderEntry) objects. If `false`, `SearchOrders`
// returns complete order objects.
//
// Default: `false`.
ReturnEntries *bool `json:"return_entries,omitempty" url:"-"`
}
// Defines the fields that are included in the response body of
// a request to the `BatchRetrieveOrders` endpoint.
type BatchGetOrdersResponse struct {
// The requested orders. This will omit any requested orders that do not exist.
Orders []*Order `json:"orders,omitempty" url:"orders,omitempty"`
// Any errors that occurred during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (b *BatchGetOrdersResponse) GetOrders() []*Order {
if b == nil {
return nil
}
return b.Orders
}
func (b *BatchGetOrdersResponse) GetErrors() []*Error {
if b == nil {
return nil
}
return b.Errors
}
func (b *BatchGetOrdersResponse) GetExtraProperties() map[string]interface{} {
return b.extraProperties
}
func (b *BatchGetOrdersResponse) UnmarshalJSON(data []byte) error {
type unmarshaler BatchGetOrdersResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*b = BatchGetOrdersResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *b)
if err != nil {
return err
}
b.extraProperties = extraProperties
b.rawJSON = json.RawMessage(data)
return nil
}
func (b *BatchGetOrdersResponse) String() string {
if len(b.rawJSON) > 0 {
if value, err := internal.StringifyJSON(b.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(b); err == nil {
return value
}
return fmt.Sprintf("%#v", b)
}
type CalculateOrderResponse struct {
// The calculated version of the order provided in the request.
Order *Order `json:"order,omitempty" url:"order,omitempty"`
// Any errors that occurred during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CalculateOrderResponse) GetOrder() *Order {
if c == nil {
return nil
}
return c.Order
}
func (c *CalculateOrderResponse) GetErrors() []*Error {
if c == nil {
return nil
}
return c.Errors
}
func (c *CalculateOrderResponse) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CalculateOrderResponse) UnmarshalJSON(data []byte) error {
type unmarshaler CalculateOrderResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CalculateOrderResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CalculateOrderResponse) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
// Defines the fields that are included in the response body of
// a request to the [CloneOrder](api-endpoint:Orders-CloneOrder) endpoint.
type CloneOrderResponse struct {
// The cloned order.
Order *Order `json:"order,omitempty" url:"order,omitempty"`
// Any errors that occurred during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CloneOrderResponse) GetOrder() *Order {
if c == nil {
return nil
}
return c.Order
}
func (c *CloneOrderResponse) GetErrors() []*Error {
if c == nil {
return nil
}
return c.Errors
}
func (c *CloneOrderResponse) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CloneOrderResponse) UnmarshalJSON(data []byte) error {
type unmarshaler CloneOrderResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CloneOrderResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CloneOrderResponse) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
// Defines the fields that are included in the response body of
// a request to the `CreateOrder` endpoint.
//
// Either `errors` or `order` is present in a given response, but never both.
type CreateOrderResponse struct {
// The newly created order.
Order *Order `json:"order,omitempty" url:"order,omitempty"`
// Any errors that occurred during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CreateOrderResponse) GetOrder() *Order {
if c == nil {
return nil
}
return c.Order
}
func (c *CreateOrderResponse) GetErrors() []*Error {
if c == nil {
return nil
}
return c.Errors
}
func (c *CreateOrderResponse) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CreateOrderResponse) UnmarshalJSON(data []byte) error {
type unmarshaler CreateOrderResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CreateOrderResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CreateOrderResponse) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
type GetOrderResponse struct {
// The requested order.
Order *Order `json:"order,omitempty" url:"order,omitempty"`
// Any errors that occurred during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (g *GetOrderResponse) GetOrder() *Order {
if g == nil {
return nil
}
return g.Order
}
func (g *GetOrderResponse) GetErrors() []*Error {
if g == nil {
return nil
}
return g.Errors
}
func (g *GetOrderResponse) GetExtraProperties() map[string]interface{} {
return g.extraProperties
}
func (g *GetOrderResponse) UnmarshalJSON(data []byte) error {
type unmarshaler GetOrderResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*g = GetOrderResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *g)
if err != nil {
return err
}
g.extraProperties = extraProperties
g.rawJSON = json.RawMessage(data)
return nil
}
func (g *GetOrderResponse) String() string {
if len(g.rawJSON) > 0 {
if value, err := internal.StringifyJSON(g.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(g); err == nil {
return value
}
return fmt.Sprintf("%#v", g)
}
// A lightweight description of an [order](entity:Order) that is returned when
// `returned_entries` is `true` on a [SearchOrdersRequest](api-endpoint:Orders-SearchOrders).
type OrderEntry struct {
// The ID of the order.
OrderID *string `json:"order_id,omitempty" url:"order_id,omitempty"`
// The version number, which is incremented each time an update is committed to the order.
// Orders that were not created through the API do not include a version number and
// therefore cannot be updated.
//
// [Read more about working with versions.](https://developer.squareup.com/docs/orders-api/manage-orders/update-orders)
Version *int `json:"version,omitempty" url:"version,omitempty"`
// The location ID the order belongs to.
LocationID *string `json:"location_id,omitempty" url:"location_id,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (o *OrderEntry) GetOrderID() *string {
if o == nil {
return nil
}
return o.OrderID
}
func (o *OrderEntry) GetVersion() *int {
if o == nil {
return nil
}
return o.Version
}
func (o *OrderEntry) GetLocationID() *string {
if o == nil {
return nil
}
return o.LocationID
}
func (o *OrderEntry) GetExtraProperties() map[string]interface{} {
return o.extraProperties
}
func (o *OrderEntry) UnmarshalJSON(data []byte) error {
type unmarshaler OrderEntry
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*o = OrderEntry(value)
extraProperties, err := internal.ExtractExtraProperties(data, *o)
if err != nil {
return err
}
o.extraProperties = extraProperties
o.rawJSON = json.RawMessage(data)
return nil
}
func (o *OrderEntry) String() string {
if len(o.rawJSON) > 0 {
if value, err := internal.StringifyJSON(o.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(o); err == nil {
return value
}
return fmt.Sprintf("%#v", o)
}
// Defines the fields that are included in the response body of a request to the
// [PayOrder](api-endpoint:Orders-PayOrder) endpoint.
type PayOrderResponse struct {
// Any errors that occurred during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The paid, updated [order](entity:Order).
Order *Order `json:"order,omitempty" url:"order,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (p *PayOrderResponse) GetErrors() []*Error {
if p == nil {
return nil
}
return p.Errors
}
func (p *PayOrderResponse) GetOrder() *Order {
if p == nil {
return nil
}
return p.Order
}
func (p *PayOrderResponse) GetExtraProperties() map[string]interface{} {
return p.extraProperties
}
func (p *PayOrderResponse) UnmarshalJSON(data []byte) error {
type unmarshaler PayOrderResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*p = PayOrderResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *p)
if err != nil {
return err
}
p.extraProperties = extraProperties
p.rawJSON = json.RawMessage(data)
return nil
}
func (p *PayOrderResponse) String() string {
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 filter based on the order `customer_id` and any tender `customer_id`
// associated with the order. It does not filter based on the
// [FulfillmentRecipient](entity:FulfillmentRecipient) `customer_id`.
type SearchOrdersCustomerFilter struct {
// A list of customer IDs to filter by.
//
// Max: 10 customer ids.
CustomerIDs []string `json:"customer_ids,omitempty" url:"customer_ids,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (s *SearchOrdersCustomerFilter) GetCustomerIDs() []string {
if s == nil {
return nil
}
return s.CustomerIDs
}
func (s *SearchOrdersCustomerFilter) GetExtraProperties() map[string]interface{} {
return s.extraProperties
}
func (s *SearchOrdersCustomerFilter) UnmarshalJSON(data []byte) error {
type unmarshaler SearchOrdersCustomerFilter
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SearchOrdersCustomerFilter(value)
extraProperties, err := internal.ExtractExtraProperties(data, *s)
if err != nil {
return err
}
s.extraProperties = extraProperties
s.rawJSON = json.RawMessage(data)
return nil
}
func (s *SearchOrdersCustomerFilter) 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)
}
// Filter for `Order` objects based on whether their `CREATED_AT`,
// `CLOSED_AT`, or `UPDATED_AT` timestamps fall within a specified time range.
// You can specify the time range and which timestamp to filter for. You can filter
// for only one time range at a time.
//
// For each time range, the start time and end time are inclusive. If the end time
// is absent, it defaults to the time of the first request for the cursor.
//
// __Important:__ If you use the `DateTimeFilter` in a `SearchOrders` query,
// you must set the `sort_field` in [OrdersSort](entity:SearchOrdersSort)
// to the same field you filter for. For example, if you set the `CLOSED_AT` field
// in `DateTimeFilter`, you must set the `sort_field` in `SearchOrdersSort` to
// `CLOSED_AT`. Otherwise, `SearchOrders` throws an error.
// [Learn more about filtering orders by time range.](https://developer.squareup.com/docs/orders-api/manage-orders/search-orders#important-note-about-filtering-orders-by-time-range)
type SearchOrdersDateTimeFilter struct {
// The time range for filtering on the `created_at` timestamp. If you use this
// value, you must set the `sort_field` in the `OrdersSearchSort` object to
// `CREATED_AT`.
CreatedAt *TimeRange `json:"created_at,omitempty" url:"created_at,omitempty"`
// The time range for filtering on the `updated_at` timestamp. If you use this
// value, you must set the `sort_field` in the `OrdersSearchSort` object to
// `UPDATED_AT`.
UpdatedAt *TimeRange `json:"updated_at,omitempty" url:"updated_at,omitempty"`
// The time range for filtering on the `closed_at` timestamp. If you use this
// value, you must set the `sort_field` in the `OrdersSearchSort` object to
// `CLOSED_AT`.
ClosedAt *TimeRange `json:"closed_at,omitempty" url:"closed_at,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (s *SearchOrdersDateTimeFilter) GetCreatedAt() *TimeRange {
if s == nil {
return nil
}
return s.CreatedAt
}
func (s *SearchOrdersDateTimeFilter) GetUpdatedAt() *TimeRange {
if s == nil {
return nil
}
return s.UpdatedAt
}
func (s *SearchOrdersDateTimeFilter) GetClosedAt() *TimeRange {
if s == nil {
return nil
}
return s.ClosedAt
}
func (s *SearchOrdersDateTimeFilter) GetExtraProperties() map[string]interface{} {
return s.extraProperties
}
func (s *SearchOrdersDateTimeFilter) UnmarshalJSON(data []byte) error {
type unmarshaler SearchOrdersDateTimeFilter
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SearchOrdersDateTimeFilter(value)
extraProperties, err := internal.ExtractExtraProperties(data, *s)
if err != nil {
return err
}
s.extraProperties = extraProperties
s.rawJSON = json.RawMessage(data)
return nil
}
func (s *SearchOrdersDateTimeFilter) 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)
}
// Filtering criteria to use for a `SearchOrders` request. Multiple filters
// are ANDed together.
type SearchOrdersFilter struct {
// Filter by [OrderState](entity:OrderState).
StateFilter *SearchOrdersStateFilter `json:"state_filter,omitempty" url:"state_filter,omitempty"`
// Filter for results within a time range.
//
// __Important:__ If you filter for orders by time range, you must set `SearchOrdersSort`
// to sort by the same field.
// [Learn more about filtering orders by time range.](https://developer.squareup.com/docs/orders-api/manage-orders/search-orders#important-note-about-filtering-orders-by-time-range)
DateTimeFilter *SearchOrdersDateTimeFilter `json:"date_time_filter,omitempty" url:"date_time_filter,omitempty"`
// Filter by the fulfillment type or state.
FulfillmentFilter *SearchOrdersFulfillmentFilter `json:"fulfillment_filter,omitempty" url:"fulfillment_filter,omitempty"`
// Filter by the source of the order.
SourceFilter *SearchOrdersSourceFilter `json:"source_filter,omitempty" url:"source_filter,omitempty"`
// Filter by customers associated with the order.
CustomerFilter *SearchOrdersCustomerFilter `json:"customer_filter,omitempty" url:"customer_filter,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (s *SearchOrdersFilter) GetStateFilter() *SearchOrdersStateFilter {
if s == nil {
return nil
}
return s.StateFilter
}
func (s *SearchOrdersFilter) GetDateTimeFilter() *SearchOrdersDateTimeFilter {
if s == nil {
return nil
}
return s.DateTimeFilter
}
func (s *SearchOrdersFilter) GetFulfillmentFilter() *SearchOrdersFulfillmentFilter {
if s == nil {
return nil
}
return s.FulfillmentFilter
}
func (s *SearchOrdersFilter) GetSourceFilter() *SearchOrdersSourceFilter {
if s == nil {
return nil
}
return s.SourceFilter
}
func (s *SearchOrdersFilter) GetCustomerFilter() *SearchOrdersCustomerFilter {
if s == nil {
return nil
}
return s.CustomerFilter
}
func (s *SearchOrdersFilter) GetExtraProperties() map[string]interface{} {
return s.extraProperties
}
func (s *SearchOrdersFilter) UnmarshalJSON(data []byte) error {
type unmarshaler SearchOrdersFilter
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SearchOrdersFilter(value)
extraProperties, err := internal.ExtractExtraProperties(data, *s)
if err != nil {
return err
}
s.extraProperties = extraProperties
s.rawJSON = json.RawMessage(data)
return nil
}
func (s *SearchOrdersFilter) 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)
}
// Filter based on [order fulfillment](entity:Fulfillment) information.
type SearchOrdersFulfillmentFilter struct {
// A list of [fulfillment types](entity:FulfillmentType) to filter
// for. The list returns orders if any of its fulfillments match any of the fulfillment types
// listed in this field.
// See [FulfillmentType](#type-fulfillmenttype) for possible values
FulfillmentTypes []FulfillmentType `json:"fulfillment_types,omitempty" url:"fulfillment_types,omitempty"`
// A list of [fulfillment states](entity:FulfillmentState) to filter
// for. The list returns orders if any of its fulfillments match any of the
// fulfillment states listed in this field.
// See [FulfillmentState](#type-fulfillmentstate) for possible values
FulfillmentStates []FulfillmentState `json:"fulfillment_states,omitempty" url:"fulfillment_states,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (s *SearchOrdersFulfillmentFilter) GetFulfillmentTypes() []FulfillmentType {
if s == nil {
return nil
}
return s.FulfillmentTypes
}
func (s *SearchOrdersFulfillmentFilter) GetFulfillmentStates() []FulfillmentState {
if s == nil {
return nil
}
return s.FulfillmentStates
}
func (s *SearchOrdersFulfillmentFilter) GetExtraProperties() map[string]interface{} {
return s.extraProperties
}
func (s *SearchOrdersFulfillmentFilter) UnmarshalJSON(data []byte) error {
type unmarshaler SearchOrdersFulfillmentFilter
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SearchOrdersFulfillmentFilter(value)
extraProperties, err := internal.ExtractExtraProperties(data, *s)
if err != nil {
return err
}
s.extraProperties = extraProperties
s.rawJSON = json.RawMessage(data)
return nil
}
func (s *SearchOrdersFulfillmentFilter) 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 SearchOrdersQuery struct {
// Criteria to filter results by.
Filter *SearchOrdersFilter `json:"filter,omitempty" url:"filter,omitempty"`
// Criteria to sort results by.
Sort *SearchOrdersSort `json:"sort,omitempty" url:"sort,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (s *SearchOrdersQuery) GetFilter() *SearchOrdersFilter {
if s == nil {
return nil
}
return s.Filter
}
func (s *SearchOrdersQuery) GetSort() *SearchOrdersSort {
if s == nil {
return nil
}
return s.Sort
}
func (s *SearchOrdersQuery) GetExtraProperties() map[string]interface{} {
return s.extraProperties
}
func (s *SearchOrdersQuery) UnmarshalJSON(data []byte) error {
type unmarshaler SearchOrdersQuery
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SearchOrdersQuery(value)
extraProperties, err := internal.ExtractExtraProperties(data, *s)
if err != nil {
return err
}
s.extraProperties = extraProperties
s.rawJSON = json.RawMessage(data)
return nil
}
func (s *SearchOrdersQuery) 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)
}
// Either the `order_entries` or `orders` field is set, depending on whether
// `return_entries` is set on the [SearchOrdersRequest](api-endpoint:Orders-SearchOrders).
type SearchOrdersResponse struct {
// A list of [OrderEntries](entity:OrderEntry) that fit the query
// conditions. The list is populated only if `return_entries` is set to `true` in the request.
OrderEntries []*OrderEntry `json:"order_entries,omitempty" url:"order_entries,omitempty"`
// A list of
// [Order](entity:Order) objects that match the query conditions. The list is populated only if
// `return_entries` is set to `false` in the request.
Orders []*Order `json:"orders,omitempty" url:"orders,omitempty"`
// The pagination cursor to be used in a subsequent request. If unset,
// 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"`
// [Errors](entity:Error) encountered during the search.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (s *SearchOrdersResponse) GetOrderEntries() []*OrderEntry {
if s == nil {
return nil
}
return s.OrderEntries
}
func (s *SearchOrdersResponse) GetOrders() []*Order {
if s == nil {
return nil
}
return s.Orders
}
func (s *SearchOrdersResponse) GetCursor() *string {
if s == nil {
return nil
}
return s.Cursor
}
func (s *SearchOrdersResponse) GetErrors() []*Error {
if s == nil {
return nil
}
return s.Errors
}
func (s *SearchOrdersResponse) GetExtraProperties() map[string]interface{} {
return s.extraProperties
}
func (s *SearchOrdersResponse) UnmarshalJSON(data []byte) error {
type unmarshaler SearchOrdersResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SearchOrdersResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *s)
if err != nil {
return err
}
s.extraProperties = extraProperties
s.rawJSON = json.RawMessage(data)
return nil
}
func (s *SearchOrdersResponse) 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)
}
// Sorting criteria for a `SearchOrders` request. Results can only be sorted
// by a timestamp field.
type SearchOrdersSort struct {
// The field to sort by.
//
// __Important:__ When using a [DateTimeFilter](entity:SearchOrdersFilter),
// `sort_field` must match the timestamp field that the `DateTimeFilter` uses to
// filter. For example, if you set your `sort_field` to `CLOSED_AT` and you use a
// `DateTimeFilter`, your `DateTimeFilter` must filter for orders by their `CLOSED_AT` date.
// If this field does not match the timestamp field in `DateTimeFilter`,
// `SearchOrders` returns an error.
//
// Default: `CREATED_AT`.
// See [SearchOrdersSortField](#type-searchorderssortfield) for possible values
SortField SearchOrdersSortField `json:"sort_field" url:"sort_field"`
// The chronological order in which results are returned. Defaults to `DESC`.
// See [SortOrder](#type-sortorder) for possible values
SortOrder *SortOrder `json:"sort_order,omitempty" url:"sort_order,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (s *SearchOrdersSort) GetSortField() SearchOrdersSortField {
if s == nil {
return ""
}
return s.SortField
}
func (s *SearchOrdersSort) GetSortOrder() *SortOrder {
if s == nil {
return nil
}
return s.SortOrder
}
func (s *SearchOrdersSort) GetExtraProperties() map[string]interface{} {
return s.extraProperties
}
func (s *SearchOrdersSort) UnmarshalJSON(data []byte) error {
type unmarshaler SearchOrdersSort
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SearchOrdersSort(value)
extraProperties, err := internal.ExtractExtraProperties(data, *s)
if err != nil {
return err
}
s.extraProperties = extraProperties
s.rawJSON = json.RawMessage(data)
return nil
}
func (s *SearchOrdersSort) String() string {
if len(s.rawJSON) > 0 {
if value, err := internal.StringifyJSON(s.rawJSON); err == nil {
return value