-
Notifications
You must be signed in to change notification settings - Fork 1
/
catalog.go
2075 lines (1846 loc) · 69.2 KB
/
catalog.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 SearchCatalogItemsRequest struct {
// The text filter expression to return items or item variations containing specified text in
// the `name`, `description`, or `abbreviation` attribute value of an item, or in
// the `name`, `sku`, or `upc` attribute value of an item variation.
TextFilter *string `json:"text_filter,omitempty" url:"-"`
// The category id query expression to return items containing the specified category IDs.
CategoryIDs []string `json:"category_ids,omitempty" url:"-"`
// The stock-level query expression to return item variations with the specified stock levels.
// See [SearchCatalogItemsRequestStockLevel](#type-searchcatalogitemsrequeststocklevel) for possible values
StockLevels []SearchCatalogItemsRequestStockLevel `json:"stock_levels,omitempty" url:"-"`
// The enabled-location query expression to return items and item variations having specified enabled locations.
EnabledLocationIDs []string `json:"enabled_location_ids,omitempty" url:"-"`
// The pagination token, returned in the previous response, used to fetch the next batch of pending results.
Cursor *string `json:"cursor,omitempty" url:"-"`
// The maximum number of results to return per page. The default value is 100.
Limit *int `json:"limit,omitempty" url:"-"`
// The order to sort the results by item names. The default sort order is ascending (`ASC`).
// See [SortOrder](#type-sortorder) for possible values
SortOrder *SortOrder `json:"sort_order,omitempty" url:"-"`
// The product types query expression to return items or item variations having the specified product types.
ProductTypes []CatalogItemProductType `json:"product_types,omitempty" url:"-"`
// The customer-attribute filter to return items or item variations matching the specified
// custom attribute expressions. A maximum number of 10 custom attribute expressions are supported in
// a single call to the [SearchCatalogItems](api-endpoint:Catalog-SearchCatalogItems) endpoint.
CustomAttributeFilters []*CustomAttributeFilter `json:"custom_attribute_filters,omitempty" url:"-"`
// The query filter to return not archived (`ARCHIVED_STATE_NOT_ARCHIVED`), archived (`ARCHIVED_STATE_ARCHIVED`), or either type (`ARCHIVED_STATE_ALL`) of items.
ArchivedState *ArchivedState `json:"archived_state,omitempty" url:"-"`
}
type UpdateItemModifierListsRequest struct {
// The IDs of the catalog items associated with the CatalogModifierList objects being updated.
ItemIDs []string `json:"item_ids,omitempty" url:"-"`
// The IDs of the CatalogModifierList objects to enable for the CatalogItem.
// At least one of `modifier_lists_to_enable` or `modifier_lists_to_disable` must be specified.
ModifierListsToEnable []string `json:"modifier_lists_to_enable,omitempty" url:"-"`
// The IDs of the CatalogModifierList objects to disable for the CatalogItem.
// At least one of `modifier_lists_to_enable` or `modifier_lists_to_disable` must be specified.
ModifierListsToDisable []string `json:"modifier_lists_to_disable,omitempty" url:"-"`
}
type UpdateItemTaxesRequest struct {
// IDs for the CatalogItems associated with the CatalogTax objects being updated.
// No more than 1,000 IDs may be provided.
ItemIDs []string `json:"item_ids,omitempty" url:"-"`
// IDs of the CatalogTax objects to enable.
// At least one of `taxes_to_enable` or `taxes_to_disable` must be specified.
TaxesToEnable []string `json:"taxes_to_enable,omitempty" url:"-"`
// IDs of the CatalogTax objects to disable.
// At least one of `taxes_to_enable` or `taxes_to_disable` must be specified.
TaxesToDisable []string `json:"taxes_to_disable,omitempty" url:"-"`
}
type BatchDeleteCatalogObjectsRequest struct {
// The IDs of the CatalogObjects to be deleted. When an object is deleted, other objects
// in the graph that depend on that object will be deleted as well (for example, deleting a
// CatalogItem will delete its CatalogItemVariation.
ObjectIDs []string `json:"object_ids,omitempty" url:"-"`
}
type BatchGetCatalogObjectsRequest struct {
// The IDs of the CatalogObjects to be retrieved.
ObjectIDs []string `json:"object_ids,omitempty" url:"-"`
// If `true`, the response will include additional objects that are related to the
// requested objects. Related objects are defined as any objects referenced by ID by the results in the `objects` field
// of the response. These objects are put in the `related_objects` field. Setting this to `true` is
// helpful when the objects are needed for immediate display to a user.
// This process only goes one level deep. Objects referenced by the related objects will not be included. For example,
//
// if the `objects` field of the response contains a CatalogItem, its associated
// CatalogCategory objects, CatalogTax objects, CatalogImage objects and
// CatalogModifierLists will be returned in the `related_objects` field of the
// response. If the `objects` field of the response contains a CatalogItemVariation,
// its parent CatalogItem will be returned in the `related_objects` field of
// the response.
//
// Default value: `false`
IncludeRelatedObjects *bool `json:"include_related_objects,omitempty" url:"-"`
// The specific version of the catalog objects to be included in the response.
// This allows you to retrieve historical versions of objects. The specified version value is matched against
// the [CatalogObject](entity:CatalogObject)s' `version` attribute. If not included, results will
// be from the current version of the catalog.
CatalogVersion *int64 `json:"catalog_version,omitempty" url:"-"`
// Indicates whether to include (`true`) or not (`false`) in the response deleted objects, namely, those with the `is_deleted` attribute set to `true`.
IncludeDeletedObjects *bool `json:"include_deleted_objects,omitempty" url:"-"`
// Specifies whether or not to include the `path_to_root` list for each returned category instance. The `path_to_root` list consists
// of `CategoryPathToRootNode` objects and specifies the path that starts with the immediate parent category of the returned category
// and ends with its root category. If the returned category is a top-level category, the `path_to_root` list is empty and is not returned
// in the response payload.
IncludeCategoryPathToRoot *bool `json:"include_category_path_to_root,omitempty" url:"-"`
}
type BatchUpsertCatalogObjectsRequest struct {
// A value you specify that uniquely identifies this
// request among all your requests. A common way to create
// a valid idempotency key is to use a Universally unique
// identifier (UUID).
//
// If you're unsure whether a particular request was successful,
// you can reattempt it with the same idempotency key without
// worrying about creating duplicate objects.
//
// See [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) for more information.
IdempotencyKey string `json:"idempotency_key" url:"-"`
// A batch of CatalogObjects to be inserted/updated atomically.
// The objects within a batch will be inserted in an all-or-nothing fashion, i.e., if an error occurs
// attempting to insert or update an object within a batch, the entire batch will be rejected. However, an error
// in one batch will not affect other batches within the same request.
//
// For each object, its `updated_at` field is ignored and replaced with a current [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates), and its
// `is_deleted` field must not be set to `true`.
//
// To modify an existing object, supply its ID. To create a new object, use an ID starting
// with `#`. These IDs may be used to create relationships between an object and attributes of
// other objects that reference it. For example, you can create a CatalogItem with
// ID `#ABC` and a CatalogItemVariation with its `item_id` attribute set to
// `#ABC` in order to associate the CatalogItemVariation with its parent
// CatalogItem.
//
// Any `#`-prefixed IDs are valid only within a single atomic batch, and will be replaced by server-generated IDs.
//
// Each batch may contain up to 1,000 objects. The total number of objects across all batches for a single request
// may not exceed 10,000. If either of these limits is violated, an error will be returned and no objects will
// be inserted or updated.
Batches []*CatalogObjectBatch `json:"batches,omitempty" url:"-"`
}
type CatalogListRequest struct {
// The pagination cursor returned in the previous response. Leave unset for an initial request.
// The page size is currently set to be 100.
// See [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) for more information.
Cursor *string `json:"-" url:"cursor,omitempty"`
// An optional case-insensitive, comma-separated list of object types to retrieve.
//
// The valid values are defined in the [CatalogObjectType](entity:CatalogObjectType) enum, for example,
// `ITEM`, `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`, `TAX`,
// `MODIFIER`, `MODIFIER_LIST`, `IMAGE`, etc.
//
// If this is unspecified, the operation returns objects of all the top level types at the version
// of the Square API used to make the request. Object types that are nested onto other object types
// are not included in the defaults.
//
// At the current API version the default object types are:
// ITEM, CATEGORY, TAX, DISCOUNT, MODIFIER_LIST,
// PRICING_RULE, PRODUCT_SET, TIME_PERIOD, MEASUREMENT_UNIT,
// SUBSCRIPTION_PLAN, ITEM_OPTION, CUSTOM_ATTRIBUTE_DEFINITION, QUICK_AMOUNT_SETTINGS.
Types *string `json:"-" url:"types,omitempty"`
// The specific version of the catalog objects to be included in the response.
// This allows you to retrieve historical versions of objects. The specified version value is matched against
// the [CatalogObject](entity:CatalogObject)s' `version` attribute. If not included, results will be from the
// current version of the catalog.
CatalogVersion *int64 `json:"-" url:"catalog_version,omitempty"`
}
type SearchCatalogObjectsRequest struct {
// The pagination cursor returned in the previous response. Leave unset for an initial request.
// See [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) for more information.
Cursor *string `json:"cursor,omitempty" url:"-"`
// The desired set of object types to appear in the search results.
//
// If this is unspecified, the operation returns objects of all the top level types at the version
// of the Square API used to make the request. Object types that are nested onto other object types
// are not included in the defaults.
//
// At the current API version the default object types are:
// ITEM, CATEGORY, TAX, DISCOUNT, MODIFIER_LIST,
// PRICING_RULE, PRODUCT_SET, TIME_PERIOD, MEASUREMENT_UNIT,
// SUBSCRIPTION_PLAN, ITEM_OPTION, CUSTOM_ATTRIBUTE_DEFINITION, QUICK_AMOUNT_SETTINGS.
//
// Note that if you wish for the query to return objects belonging to nested types (i.e., COMPONENT, IMAGE,
// ITEM_OPTION_VAL, ITEM_VARIATION, or MODIFIER), you must explicitly include all the types of interest
// in this field.
ObjectTypes []CatalogObjectType `json:"object_types,omitempty" url:"-"`
// If `true`, deleted objects will be included in the results. Deleted objects will have their
// `is_deleted` field set to `true`.
IncludeDeletedObjects *bool `json:"include_deleted_objects,omitempty" url:"-"`
// If `true`, the response will include additional objects that are related to the
// requested objects. Related objects are objects that are referenced by object ID by the objects
// in the response. This is helpful if the objects are being fetched for immediate display to a user.
// This process only goes one level deep. Objects referenced by the related objects will not be included.
// For example:
//
// If the `objects` field of the response contains a CatalogItem, its associated
// CatalogCategory objects, CatalogTax objects, CatalogImage objects and
// CatalogModifierLists will be returned in the `related_objects` field of the
// response. If the `objects` field of the response contains a CatalogItemVariation,
// its parent CatalogItem will be returned in the `related_objects` field of
// the response.
//
// Default value: `false`
IncludeRelatedObjects *bool `json:"include_related_objects,omitempty" url:"-"`
// Return objects modified after this [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates), in RFC 3339
// format, e.g., `2016-09-04T23:59:33.123Z`. The timestamp is exclusive - objects with a
// timestamp equal to `begin_time` will not be included in the response.
BeginTime *string `json:"begin_time,omitempty" url:"-"`
// A query to be used to filter or sort the results. If no query is specified, the entire catalog will be returned.
Query *CatalogQuery `json:"query,omitempty" url:"-"`
// A limit on the number of results to be returned in a single page. The limit is advisory -
// the implementation may return more or fewer results. If the supplied limit is negative, zero, or
// is higher than the maximum limit of 1,000, it will be ignored.
Limit *int `json:"limit,omitempty" url:"-"`
// Specifies whether or not to include the `path_to_root` list for each returned category instance. The `path_to_root` list consists
// of `CategoryPathToRootNode` objects and specifies the path that starts with the immediate parent category of the returned category
// and ends with its root category. If the returned category is a top-level category, the `path_to_root` list is empty and is not returned
// in the response payload.
IncludeCategoryPathToRoot *bool `json:"include_category_path_to_root,omitempty" url:"-"`
}
// Defines the values for the `archived_state` query expression
// used in [SearchCatalogItems](api-endpoint:Catalog-SearchCatalogItems)
// to return the archived, not archived or either type of catalog items.
type ArchivedState string
const (
ArchivedStateArchivedStateNotArchived ArchivedState = "ARCHIVED_STATE_NOT_ARCHIVED"
ArchivedStateArchivedStateArchived ArchivedState = "ARCHIVED_STATE_ARCHIVED"
ArchivedStateArchivedStateAll ArchivedState = "ARCHIVED_STATE_ALL"
)
func NewArchivedStateFromString(s string) (ArchivedState, error) {
switch s {
case "ARCHIVED_STATE_NOT_ARCHIVED":
return ArchivedStateArchivedStateNotArchived, nil
case "ARCHIVED_STATE_ARCHIVED":
return ArchivedStateArchivedStateArchived, nil
case "ARCHIVED_STATE_ALL":
return ArchivedStateArchivedStateAll, nil
}
var t ArchivedState
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (a ArchivedState) Ptr() *ArchivedState {
return &a
}
type BatchDeleteCatalogObjectsResponse struct {
// Any errors that occurred during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The IDs of all CatalogObjects deleted by this request.
DeletedObjectIDs []string `json:"deleted_object_ids,omitempty" url:"deleted_object_ids,omitempty"`
// The database [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) of this deletion in RFC 3339 format, e.g., "2016-09-04T23:59:33.123Z".
DeletedAt *string `json:"deleted_at,omitempty" url:"deleted_at,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (b *BatchDeleteCatalogObjectsResponse) GetErrors() []*Error {
if b == nil {
return nil
}
return b.Errors
}
func (b *BatchDeleteCatalogObjectsResponse) GetDeletedObjectIDs() []string {
if b == nil {
return nil
}
return b.DeletedObjectIDs
}
func (b *BatchDeleteCatalogObjectsResponse) GetDeletedAt() *string {
if b == nil {
return nil
}
return b.DeletedAt
}
func (b *BatchDeleteCatalogObjectsResponse) GetExtraProperties() map[string]interface{} {
return b.extraProperties
}
func (b *BatchDeleteCatalogObjectsResponse) UnmarshalJSON(data []byte) error {
type unmarshaler BatchDeleteCatalogObjectsResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*b = BatchDeleteCatalogObjectsResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *b)
if err != nil {
return err
}
b.extraProperties = extraProperties
b.rawJSON = json.RawMessage(data)
return nil
}
func (b *BatchDeleteCatalogObjectsResponse) 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 BatchGetCatalogObjectsResponse struct {
// Any errors that occurred during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// A list of [CatalogObject](entity:CatalogObject)s returned.
Objects []*CatalogObject `json:"objects,omitempty" url:"objects,omitempty"`
// A list of [CatalogObject](entity:CatalogObject)s referenced by the object in the `objects` field.
RelatedObjects []*CatalogObject `json:"related_objects,omitempty" url:"related_objects,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (b *BatchGetCatalogObjectsResponse) GetErrors() []*Error {
if b == nil {
return nil
}
return b.Errors
}
func (b *BatchGetCatalogObjectsResponse) GetObjects() []*CatalogObject {
if b == nil {
return nil
}
return b.Objects
}
func (b *BatchGetCatalogObjectsResponse) GetRelatedObjects() []*CatalogObject {
if b == nil {
return nil
}
return b.RelatedObjects
}
func (b *BatchGetCatalogObjectsResponse) GetExtraProperties() map[string]interface{} {
return b.extraProperties
}
func (b *BatchGetCatalogObjectsResponse) UnmarshalJSON(data []byte) error {
type unmarshaler BatchGetCatalogObjectsResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*b = BatchGetCatalogObjectsResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *b)
if err != nil {
return err
}
b.extraProperties = extraProperties
b.rawJSON = json.RawMessage(data)
return nil
}
func (b *BatchGetCatalogObjectsResponse) 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 BatchUpsertCatalogObjectsResponse struct {
// Any errors that occurred during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// The created successfully created CatalogObjects.
Objects []*CatalogObject `json:"objects,omitempty" url:"objects,omitempty"`
// The database [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) of this update in RFC 3339 format, e.g., "2016-09-04T23:59:33.123Z".
UpdatedAt *string `json:"updated_at,omitempty" url:"updated_at,omitempty"`
// The mapping between client and server IDs for this upsert.
IDMappings []*CatalogIDMapping `json:"id_mappings,omitempty" url:"id_mappings,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (b *BatchUpsertCatalogObjectsResponse) GetErrors() []*Error {
if b == nil {
return nil
}
return b.Errors
}
func (b *BatchUpsertCatalogObjectsResponse) GetObjects() []*CatalogObject {
if b == nil {
return nil
}
return b.Objects
}
func (b *BatchUpsertCatalogObjectsResponse) GetUpdatedAt() *string {
if b == nil {
return nil
}
return b.UpdatedAt
}
func (b *BatchUpsertCatalogObjectsResponse) GetIDMappings() []*CatalogIDMapping {
if b == nil {
return nil
}
return b.IDMappings
}
func (b *BatchUpsertCatalogObjectsResponse) GetExtraProperties() map[string]interface{} {
return b.extraProperties
}
func (b *BatchUpsertCatalogObjectsResponse) UnmarshalJSON(data []byte) error {
type unmarshaler BatchUpsertCatalogObjectsResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*b = BatchUpsertCatalogObjectsResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *b)
if err != nil {
return err
}
b.extraProperties = extraProperties
b.rawJSON = json.RawMessage(data)
return nil
}
func (b *BatchUpsertCatalogObjectsResponse) 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 CatalogInfoResponse struct {
// Any errors that occurred during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
// Limits that apply to this API.
Limits *CatalogInfoResponseLimits `json:"limits,omitempty" url:"limits,omitempty"`
// Names and abbreviations for standard units.
StandardUnitDescriptionGroup *StandardUnitDescriptionGroup `json:"standard_unit_description_group,omitempty" url:"standard_unit_description_group,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CatalogInfoResponse) GetErrors() []*Error {
if c == nil {
return nil
}
return c.Errors
}
func (c *CatalogInfoResponse) GetLimits() *CatalogInfoResponseLimits {
if c == nil {
return nil
}
return c.Limits
}
func (c *CatalogInfoResponse) GetStandardUnitDescriptionGroup() *StandardUnitDescriptionGroup {
if c == nil {
return nil
}
return c.StandardUnitDescriptionGroup
}
func (c *CatalogInfoResponse) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CatalogInfoResponse) UnmarshalJSON(data []byte) error {
type unmarshaler CatalogInfoResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CatalogInfoResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CatalogInfoResponse) 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 CatalogInfoResponseLimits struct {
// The maximum number of objects that may appear within a single batch in a
// `/v2/catalog/batch-upsert` request.
BatchUpsertMaxObjectsPerBatch *int `json:"batch_upsert_max_objects_per_batch,omitempty" url:"batch_upsert_max_objects_per_batch,omitempty"`
// The maximum number of objects that may appear across all batches in a
// `/v2/catalog/batch-upsert` request.
BatchUpsertMaxTotalObjects *int `json:"batch_upsert_max_total_objects,omitempty" url:"batch_upsert_max_total_objects,omitempty"`
// The maximum number of object IDs that may appear in a `/v2/catalog/batch-retrieve`
// request.
BatchRetrieveMaxObjectIDs *int `json:"batch_retrieve_max_object_ids,omitempty" url:"batch_retrieve_max_object_ids,omitempty"`
// The maximum number of results that may be returned in a page of a
// `/v2/catalog/search` response.
SearchMaxPageLimit *int `json:"search_max_page_limit,omitempty" url:"search_max_page_limit,omitempty"`
// The maximum number of object IDs that may be included in a single
// `/v2/catalog/batch-delete` request.
BatchDeleteMaxObjectIDs *int `json:"batch_delete_max_object_ids,omitempty" url:"batch_delete_max_object_ids,omitempty"`
// The maximum number of item IDs that may be included in a single
// `/v2/catalog/update-item-taxes` request.
UpdateItemTaxesMaxItemIDs *int `json:"update_item_taxes_max_item_ids,omitempty" url:"update_item_taxes_max_item_ids,omitempty"`
// The maximum number of tax IDs to be enabled that may be included in a single
// `/v2/catalog/update-item-taxes` request.
UpdateItemTaxesMaxTaxesToEnable *int `json:"update_item_taxes_max_taxes_to_enable,omitempty" url:"update_item_taxes_max_taxes_to_enable,omitempty"`
// The maximum number of tax IDs to be disabled that may be included in a single
// `/v2/catalog/update-item-taxes` request.
UpdateItemTaxesMaxTaxesToDisable *int `json:"update_item_taxes_max_taxes_to_disable,omitempty" url:"update_item_taxes_max_taxes_to_disable,omitempty"`
// The maximum number of item IDs that may be included in a single
// `/v2/catalog/update-item-modifier-lists` request.
UpdateItemModifierListsMaxItemIDs *int `json:"update_item_modifier_lists_max_item_ids,omitempty" url:"update_item_modifier_lists_max_item_ids,omitempty"`
// The maximum number of modifier list IDs to be enabled that may be included in
// a single `/v2/catalog/update-item-modifier-lists` request.
UpdateItemModifierListsMaxModifierListsToEnable *int `json:"update_item_modifier_lists_max_modifier_lists_to_enable,omitempty" url:"update_item_modifier_lists_max_modifier_lists_to_enable,omitempty"`
// The maximum number of modifier list IDs to be disabled that may be included in
// a single `/v2/catalog/update-item-modifier-lists` request.
UpdateItemModifierListsMaxModifierListsToDisable *int `json:"update_item_modifier_lists_max_modifier_lists_to_disable,omitempty" url:"update_item_modifier_lists_max_modifier_lists_to_disable,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CatalogInfoResponseLimits) GetBatchUpsertMaxObjectsPerBatch() *int {
if c == nil {
return nil
}
return c.BatchUpsertMaxObjectsPerBatch
}
func (c *CatalogInfoResponseLimits) GetBatchUpsertMaxTotalObjects() *int {
if c == nil {
return nil
}
return c.BatchUpsertMaxTotalObjects
}
func (c *CatalogInfoResponseLimits) GetBatchRetrieveMaxObjectIDs() *int {
if c == nil {
return nil
}
return c.BatchRetrieveMaxObjectIDs
}
func (c *CatalogInfoResponseLimits) GetSearchMaxPageLimit() *int {
if c == nil {
return nil
}
return c.SearchMaxPageLimit
}
func (c *CatalogInfoResponseLimits) GetBatchDeleteMaxObjectIDs() *int {
if c == nil {
return nil
}
return c.BatchDeleteMaxObjectIDs
}
func (c *CatalogInfoResponseLimits) GetUpdateItemTaxesMaxItemIDs() *int {
if c == nil {
return nil
}
return c.UpdateItemTaxesMaxItemIDs
}
func (c *CatalogInfoResponseLimits) GetUpdateItemTaxesMaxTaxesToEnable() *int {
if c == nil {
return nil
}
return c.UpdateItemTaxesMaxTaxesToEnable
}
func (c *CatalogInfoResponseLimits) GetUpdateItemTaxesMaxTaxesToDisable() *int {
if c == nil {
return nil
}
return c.UpdateItemTaxesMaxTaxesToDisable
}
func (c *CatalogInfoResponseLimits) GetUpdateItemModifierListsMaxItemIDs() *int {
if c == nil {
return nil
}
return c.UpdateItemModifierListsMaxItemIDs
}
func (c *CatalogInfoResponseLimits) GetUpdateItemModifierListsMaxModifierListsToEnable() *int {
if c == nil {
return nil
}
return c.UpdateItemModifierListsMaxModifierListsToEnable
}
func (c *CatalogInfoResponseLimits) GetUpdateItemModifierListsMaxModifierListsToDisable() *int {
if c == nil {
return nil
}
return c.UpdateItemModifierListsMaxModifierListsToDisable
}
func (c *CatalogInfoResponseLimits) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CatalogInfoResponseLimits) UnmarshalJSON(data []byte) error {
type unmarshaler CatalogInfoResponseLimits
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CatalogInfoResponseLimits(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CatalogInfoResponseLimits) 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)
}
// A batch of catalog objects.
type CatalogObjectBatch struct {
// A list of CatalogObjects belonging to this batch.
Objects []*CatalogObject `json:"objects,omitempty" url:"objects,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CatalogObjectBatch) GetObjects() []*CatalogObject {
if c == nil {
return nil
}
return c.Objects
}
func (c *CatalogObjectBatch) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CatalogObjectBatch) UnmarshalJSON(data []byte) error {
type unmarshaler CatalogObjectBatch
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CatalogObjectBatch(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CatalogObjectBatch) 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)
}
// A query composed of one or more different types of filters to narrow the scope of targeted objects when calling the `SearchCatalogObjects` endpoint.
//
// Although a query can have multiple filters, only certain query types can be combined per call to [SearchCatalogObjects](api-endpoint:Catalog-SearchCatalogObjects).
// Any combination of the following types may be used together:
// - [exact_query](entity:CatalogQueryExact)
// - [prefix_query](entity:CatalogQueryPrefix)
// - [range_query](entity:CatalogQueryRange)
// - [sorted_attribute_query](entity:CatalogQuerySortedAttribute)
// - [text_query](entity:CatalogQueryText)
//
// All other query types cannot be combined with any others.
//
// When a query filter is based on an attribute, the attribute must be searchable.
// Searchable attributes are listed as follows, along their parent types that can be searched for with applicable query filters.
//
// Searchable attribute and objects queryable by searchable attributes:
// - `name`: `CatalogItem`, `CatalogItemVariation`, `CatalogCategory`, `CatalogTax`, `CatalogDiscount`, `CatalogModifier`, `CatalogModifierList`, `CatalogItemOption`, `CatalogItemOptionValue`
// - `description`: `CatalogItem`, `CatalogItemOptionValue`
// - `abbreviation`: `CatalogItem`
// - `upc`: `CatalogItemVariation`
// - `sku`: `CatalogItemVariation`
// - `caption`: `CatalogImage`
// - `display_name`: `CatalogItemOption`
//
// For example, to search for [CatalogItem](entity:CatalogItem) objects by searchable attributes, you can use
// the `"name"`, `"description"`, or `"abbreviation"` attribute in an applicable query filter.
type CatalogQuery struct {
// A query expression to sort returned query result by the given attribute.
SortedAttributeQuery *CatalogQuerySortedAttribute `json:"sorted_attribute_query,omitempty" url:"sorted_attribute_query,omitempty"`
// An exact query expression to return objects with attribute name and value
// matching the specified attribute name and value exactly. Value matching is case insensitive.
ExactQuery *CatalogQueryExact `json:"exact_query,omitempty" url:"exact_query,omitempty"`
// A set query expression to return objects with attribute name and value
// matching the specified attribute name and any of the specified attribute values exactly.
// Value matching is case insensitive.
SetQuery *CatalogQuerySet `json:"set_query,omitempty" url:"set_query,omitempty"`
// A prefix query expression to return objects with attribute values
// that have a prefix matching the specified string value. Value matching is case insensitive.
PrefixQuery *CatalogQueryPrefix `json:"prefix_query,omitempty" url:"prefix_query,omitempty"`
// A range query expression to return objects with numeric values
// that lie in the specified range.
RangeQuery *CatalogQueryRange `json:"range_query,omitempty" url:"range_query,omitempty"`
// A text query expression to return objects whose searchable attributes contain all of the given
// keywords, irrespective of their order. For example, if a `CatalogItem` contains custom attribute values of
// `{"name": "t-shirt"}` and `{"description": "Small, Purple"}`, the query filter of `{"keywords": ["shirt", "sma", "purp"]}`
// returns this item.
TextQuery *CatalogQueryText `json:"text_query,omitempty" url:"text_query,omitempty"`
// A query expression to return items that have any of the specified taxes (as identified by the corresponding `CatalogTax` object IDs) enabled.
ItemsForTaxQuery *CatalogQueryItemsForTax `json:"items_for_tax_query,omitempty" url:"items_for_tax_query,omitempty"`
// A query expression to return items that have any of the given modifier list (as identified by the corresponding `CatalogModifierList`s IDs) enabled.
ItemsForModifierListQuery *CatalogQueryItemsForModifierList `json:"items_for_modifier_list_query,omitempty" url:"items_for_modifier_list_query,omitempty"`
// A query expression to return items that contains the specified item options (as identified the corresponding `CatalogItemOption` IDs).
ItemsForItemOptionsQuery *CatalogQueryItemsForItemOptions `json:"items_for_item_options_query,omitempty" url:"items_for_item_options_query,omitempty"`
// A query expression to return item variations (of the [CatalogItemVariation](entity:CatalogItemVariation) type) that
// contain all of the specified `CatalogItemOption` IDs.
ItemVariationsForItemOptionValuesQuery *CatalogQueryItemVariationsForItemOptionValues `json:"item_variations_for_item_option_values_query,omitempty" url:"item_variations_for_item_option_values_query,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CatalogQuery) GetSortedAttributeQuery() *CatalogQuerySortedAttribute {
if c == nil {
return nil
}
return c.SortedAttributeQuery
}
func (c *CatalogQuery) GetExactQuery() *CatalogQueryExact {
if c == nil {
return nil
}
return c.ExactQuery
}
func (c *CatalogQuery) GetSetQuery() *CatalogQuerySet {
if c == nil {
return nil
}
return c.SetQuery
}
func (c *CatalogQuery) GetPrefixQuery() *CatalogQueryPrefix {
if c == nil {
return nil
}
return c.PrefixQuery
}
func (c *CatalogQuery) GetRangeQuery() *CatalogQueryRange {
if c == nil {
return nil
}
return c.RangeQuery
}
func (c *CatalogQuery) GetTextQuery() *CatalogQueryText {
if c == nil {
return nil
}
return c.TextQuery
}
func (c *CatalogQuery) GetItemsForTaxQuery() *CatalogQueryItemsForTax {
if c == nil {
return nil
}
return c.ItemsForTaxQuery
}
func (c *CatalogQuery) GetItemsForModifierListQuery() *CatalogQueryItemsForModifierList {
if c == nil {
return nil
}
return c.ItemsForModifierListQuery
}
func (c *CatalogQuery) GetItemsForItemOptionsQuery() *CatalogQueryItemsForItemOptions {
if c == nil {
return nil
}
return c.ItemsForItemOptionsQuery
}
func (c *CatalogQuery) GetItemVariationsForItemOptionValuesQuery() *CatalogQueryItemVariationsForItemOptionValues {
if c == nil {
return nil
}
return c.ItemVariationsForItemOptionValuesQuery
}
func (c *CatalogQuery) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CatalogQuery) UnmarshalJSON(data []byte) error {
type unmarshaler CatalogQuery
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CatalogQuery(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CatalogQuery) 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)
}
// The query filter to return the search result by exact match of the specified attribute name and value.
type CatalogQueryExact struct {
// The name of the attribute to be searched. Matching of the attribute name is exact.
AttributeName string `json:"attribute_name" url:"attribute_name"`
// The desired value of the search attribute. Matching of the attribute value is case insensitive and can be partial.
// For example, if a specified value of "sma", objects with the named attribute value of "Small", "small" are both matched.
AttributeValue string `json:"attribute_value" url:"attribute_value"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CatalogQueryExact) GetAttributeName() string {
if c == nil {
return ""
}
return c.AttributeName
}
func (c *CatalogQueryExact) GetAttributeValue() string {
if c == nil {
return ""
}
return c.AttributeValue
}
func (c *CatalogQueryExact) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CatalogQueryExact) UnmarshalJSON(data []byte) error {
type unmarshaler CatalogQueryExact
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CatalogQueryExact(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CatalogQueryExact) 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)
}
// The query filter to return the item variations containing the specified item option value IDs.
type CatalogQueryItemVariationsForItemOptionValues struct {
// A set of `CatalogItemOptionValue` IDs to be used to find associated
// `CatalogItemVariation`s. All ItemVariations that contain all of the given
// Item Option Values (in any order) will be returned.
ItemOptionValueIDs []string `json:"item_option_value_ids,omitempty" url:"item_option_value_ids,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CatalogQueryItemVariationsForItemOptionValues) GetItemOptionValueIDs() []string {
if c == nil {
return nil
}
return c.ItemOptionValueIDs
}
func (c *CatalogQueryItemVariationsForItemOptionValues) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CatalogQueryItemVariationsForItemOptionValues) UnmarshalJSON(data []byte) error {
type unmarshaler CatalogQueryItemVariationsForItemOptionValues
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CatalogQueryItemVariationsForItemOptionValues(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CatalogQueryItemVariationsForItemOptionValues) 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)
}
// The query filter to return the items containing the specified item option IDs.
type CatalogQueryItemsForItemOptions struct {
// A set of `CatalogItemOption` IDs to be used to find associated
// `CatalogItem`s. All Items that contain all of the given Item Options (in any order)
// will be returned.
ItemOptionIDs []string `json:"item_option_ids,omitempty" url:"item_option_ids,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CatalogQueryItemsForItemOptions) GetItemOptionIDs() []string {
if c == nil {
return nil
}
return c.ItemOptionIDs
}
func (c *CatalogQueryItemsForItemOptions) GetExtraProperties() map[string]interface{} {