-
Notifications
You must be signed in to change notification settings - Fork 0
/
request_components2.go
557 lines (500 loc) · 23.4 KB
/
request_components2.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
package finding
import (
"strconv"
)
// RequestItemFilter works with ItemFilter ebay entity
type RequestItemFilter struct {
ItemFilterMap map[ItemFilterParameter]ServiceItemFilter `json:"-" xml:"-"`
ItemFilter []ServiceItemFilter `json:"itemFilter,omitempty" xml:"itemFilter,omitempty"`
}
// ServiceItemFilter represents ItemFilter unit
type ServiceItemFilter struct {
Name string `json:"name" xml:"name"`
Value []string `json:"value" xml:"value"`
ParamName string `json:"paramName,omitempty" xml:"paramName,omitempty"`
ParamValue string `json:"paramValue,omitempty" xml:"paramValue,omitempty"`
}
// Initialize needed to initialize map inside RequestItemFilter
func (sr *RequestItemFilter) Initialize() {
sr.ItemFilterMap = make(map[ItemFilterParameter]ServiceItemFilter)
}
// Reload refreshes itemFilter
func (sr *RequestItemFilter) Reload() {
sr.ItemFilter = nil
}
// prepares ServiceItemFilter from changing ItemFilterMap. Executed every request call or getting req body.
func (sr *RequestItemFilter) prepare() {
if len(sr.ItemFilterMap) == 0 {
return
}
if len(sr.ItemFilter) != 0 {
return
}
var filter []ServiceItemFilter
for _, val := range sr.ItemFilterMap {
filter = append(filter, val)
}
sr.ItemFilter = filter
}
// creates ItemFilter record with just Name
func (sr *RequestItemFilter) prepareIFMap(ifp ItemFilterParameter) {
if _, ok := sr.ItemFilterMap[ifp]; !ok {
sr.ItemFilterMap[ifp] = ServiceItemFilter{Name: string(ifp)}
}
}
// adds values to ItemFilter if accepted multiple values in this ItemFilter
func (sr *RequestItemFilter) addIFValues(ifp ItemFilterParameter, limit int, values ...string) {
if len(values) == 0 {
return
}
sr.prepareIFMap(ifp)
oldValues := sr.ItemFilterMap[ifp].Value
valuesMap := make(map[string]struct{})
for _, v := range oldValues {
valuesMap[v] = struct{}{}
}
for _, value := range values {
if len(valuesMap) >= limit {
break
}
valuesMap[value] = struct{}{}
}
newValues := make([]string, 0, len(valuesMap))
for k := range valuesMap {
newValues = append(newValues, k)
}
sr.ItemFilterMap[ifp] = ServiceItemFilter{
Name: string(ifp),
Value: newValues,
}
}
// creates of updates value for this single-value ItemFilter
func (sr *RequestItemFilter) updateIFValue(ifp ItemFilterParameter, value string) {
sr.prepareIFMap(ifp)
sr.ItemFilterMap[ifp] = ServiceItemFilter{
Name: string(ifp),
Value: []string{value},
}
}
// creates or updates value with parameters for this single-value ItemFilter
func (sr *RequestItemFilter) updateIFValueWithParameter(ifp ItemFilterParameter, paramName string, paramValue string, value string) {
sr.prepareIFMap(ifp)
sr.ItemFilterMap[ifp] = ServiceItemFilter{
Name: string(ifp),
Value: []string{value},
ParamName: paramName,
ParamValue: paramValue,
}
}
// WithItemFilterTopRatedSellerOnly adds TopRatedSellerOnly ItemFilter
// The TopRatedSellerOnly item filter cannot be used together with either the Seller or ExcludeSeller item filters.
// The TopRatedSellerOnly item filter is supported for the following sites only:
// US (EBAY-US), Motors (EBAY-MOTOR), UK (EBAY-GB), IE (EBAY-IE), DE (EBAY-DE), AT (EBAY-AT), and CH (EBAY-CH).
func (sr *RequestItemFilter) WithItemFilterTopRatedSellerOnly(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterTopRatedSellerOnly, strconv.FormatBool(b))
return sr
}
// WithItemFilterAuthorizedSellerOnly adds AuthorizedSellerOnly ItemFilter
// If set to true, returns only items listed by authorized sellers
func (sr *RequestItemFilter) WithItemFilterAuthorizedSellerOnly(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterAuthorizedSellerOnly, strconv.FormatBool(b))
return sr
}
// WithItemFilterBestOfferOnly adds BestOfferOnly ItemFilter
// If true, the search results are limited to only items that have Best Offer enabled.
// Default is false.
func (sr *RequestItemFilter) WithItemFilterBestOfferOnly(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterBestOfferOnly, strconv.FormatBool(b))
return sr
}
// WithItemFilterCharityOnly adds CharityOnly ItemFilter
// If true, the search results are limited to items for which all or part of the proceeds are given to a charity.
// Each item in the search results will include the ID of the given charity.
// Default is false.
func (sr *RequestItemFilter) WithItemFilterCharityOnly(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterCharityOnly, strconv.FormatBool(b))
return sr
}
// WithItemFilterExcludeAutoPay adds ExcludeAutoPay ItemFilter
// If true, excludes all items requiring immediate payment. Default is false.
func (sr *RequestItemFilter) WithItemFilterExcludeAutoPay(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterExcludeAutoPay, strconv.FormatBool(b))
return sr
}
// WithItemFilterFeaturedOnly adds FeaturedOnly ItemFilter
// If true, the search results are limited to featured item listings only. Default is false.
func (sr *RequestItemFilter) WithItemFilterFeaturedOnly(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterFeaturedOnly, strconv.FormatBool(b))
return sr
}
// WithItemFilterFreeShippingOnly adds FreeShippingOnly ItemFilter
// If true, the search results are limited to only items with free shipping to the site specified in the req
// (see Global ID Values).
// Default is false.
func (sr *RequestItemFilter) WithItemFilterFreeShippingOnly(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterFreeShippingOnly, strconv.FormatBool(b))
return sr
}
// WithItemFilterGetItFastOnly adds GetItFastOnly ItemFilter
// If true, the search results are limited to only Get It Fast listings. Default is false.
func (sr *RequestItemFilter) WithItemFilterGetItFastOnly(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterGetItFastOnly, strconv.FormatBool(b))
return sr
}
// WithItemFilterHideDuplicateItems adds HideDuplicateItems ItemFilter
// If true, and there are duplicate items for an item in the search results,
// the subsequent duplicates will not appear in the results. Default is false.
func (sr *RequestItemFilter) WithItemFilterHideDuplicateItems(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterHideDuplicateItems, strconv.FormatBool(b))
return sr
}
// WithItemFilterLocalPickupOnly adds LocalPickupOnly ItemFilter
// If true, the search results are limited to only items which have local pickup available. Default is false.
func (sr *RequestItemFilter) WithItemFilterLocalPickupOnly(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterLocalPickupOnly, strconv.FormatBool(b))
return sr
}
// WithItemFilterLocalSearchOnly adds LocalSearchOnly ItemFilter
// If true, the search results are limited to only matching items with the Local Inventory Listing Options (LILO).
// Must be used together with the MaxDistance item filter, and the req must also specify buyerPostalCode.
// Currently, this is only available for the Motors site (global ID EBAY- MOTOR).
func (sr *RequestItemFilter) WithItemFilterLocalSearchOnly(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterLocalSearchOnly, strconv.FormatBool(b))
return sr
}
// WithItemFilterLotsOnly adds LotsOnly ItemFilter
// If true, the search results are limited to only matching listings for which the lot size is 2 or more.
// Default is false.
func (sr *RequestItemFilter) WithItemFilterLotsOnly(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterLotsOnly, strconv.FormatBool(b))
return sr
}
// WithItemFilterOutletSellerOnly adds OutletSellerOnly ItemFilter
// If set to true, returns only items listed by outlet sellers.
func (sr *RequestItemFilter) WithItemFilterOutletSellerOnly(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterOutletSellerOnly, strconv.FormatBool(b))
return sr
}
// WithItemFilterReturnsAcceptedOnly adds ReturnsAcceptedOnly ItemFilter
// If set to true, returns only items where the seller accepts returns.
func (sr *RequestItemFilter) WithItemFilterReturnsAcceptedOnly(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterReturnsAcceptedOnly, strconv.FormatBool(b))
return sr
}
// WithItemFilterSoldItemsOnly adds SoldItemsOnly ItemFilter
// Reserved for future use. If true, excludes all completed items which are not ended by being sold.
func (sr *RequestItemFilter) WithItemFilterSoldItemsOnly(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterSoldItemsOnly, strconv.FormatBool(b))
return sr
}
// WithItemFilterWorldOfGoodOnly adds WorldOfGoodOnly ItemFilter
// If true, the search results are limited to only items listed in the World of Good marketplace.
// Defaults to false.
func (sr *RequestItemFilter) WithItemFilterWorldOfGoodOnly(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterWorldOfGoodOnly, strconv.FormatBool(b))
return sr
}
// WithItemFilterAvailableTo adds AvailableTo ItemFilter
// Limits items to those available to the specified country only.
// Item filter LocatedIn cannot be used together with item filter AvailableTo.
// Expects the two-letter ISO 3166 country code to indicate the country where the item is located.
// For English names that correspond to each code (e.g., KY="Cayman Islands")
func (sr *RequestItemFilter) WithItemFilterAvailableTo(code string) *RequestItemFilter {
sr.updateIFValue(ItemFilterAvailableTo, code)
return sr
}
// WithItemFilterCurrency adds Currency ItemFilter
// Limits results to items listed with the specified currency only.
func (sr *RequestItemFilter) WithItemFilterCurrency(currency ItemFilterCurrencyIDOption) *RequestItemFilter {
sr.updateIFValue(ItemFilterCurrency, string(currency))
return sr
}
// WithItemFilterExpeditedShippingType adds ExpeditedShippingType ItemFilter
// Specifies the type of expedited shipping. You can specify either Expedited or OneDayShipping.
// Only items that can be shipped by the specified type are returned.
// ExpeditedShippingType is used together with the MaxHandlingTime and ReturnsAcceptedOnly filters
// to filter items for certain kinds of gifting events such as birthdays or holidays where the items must
// be delivered by a certain date.
func (sr *RequestItemFilter) WithItemFilterExpeditedShippingType(shipping ItemFilterExpeditedShippingTypeOption) *RequestItemFilter {
sr.updateIFValue(ItemFilterExpeditedShippingType, string(shipping))
return sr
}
// WithItemFilterFeedbackScoreMax adds FeedbackScoreMax ItemFilter
// Specifies the maximum feedback score of a seller whose items can be included in the response.
// If FeedbackScoreMin is also specified, the FeedbackScoreMax value must be greater than or equal to the
// FeedbackScoreMin value.
//
// Values below 0 are ignored.
func (sr *RequestItemFilter) WithItemFilterFeedbackScoreMax(score int) *RequestItemFilter {
if score < 0 {
return sr
}
sr.updateIFValue(ItemFilterFeedbackScoreMax, strconv.Itoa(score))
return sr
}
// WithItemFilterFeedbackScoreMin adds FeedbackScoreMin ItemFilter
// Specifies the mininum feedback score of a seller whose items can be included in the response.
// If FeedbackScoreMax is also specified, the FeedbackScoreMax value must be greater than or equal to the
// FeedbackScoreMin value.
//
// Values below are 0 ignored.
func (sr *RequestItemFilter) WithItemFilterFeedbackScoreMin(score int) *RequestItemFilter {
if score < 0 {
return sr
}
sr.updateIFValue(ItemFilterFeedbackScoreMin, strconv.Itoa(score))
return sr
}
// WithItemFilterListedIn adds ListedIn ItemFilter
// The site on which the items were originally listed.
// This can be useful for buyers who wish to see only items on their domestic site
// either for delivery cost reasons or time reasons, such as for gifting occasions like birthdays or holidays.
func (sr *RequestItemFilter) WithItemFilterListedIn(globalID GlobalID) *RequestItemFilter {
sr.updateIFValue(ItemFilterListedIn, string(globalID))
return sr
}
// WithItemFilterMaxBids adds MaxBids ItemFilter
// Limits the results to items with bid counts less than or equal to the specified value.
// If MinBids is also specified, the MaxBids value must be greater than or equal to the MinBids value.
//
// Values below 0 are ignored.
func (sr *RequestItemFilter) WithItemFilterMaxBids(score int) *RequestItemFilter {
if score < 0 {
return sr
}
sr.updateIFValue(ItemFilterMaxBids, strconv.Itoa(score))
return sr
}
// WithItemFilterMaxDistance adds MaxDistance ItemFilter
// Specifies the maximum distance from the specified postal code (buyerPostalCode) to search for items.
// The req must also specify buyerPostalCode.
// Values below 5 are ignored.
func (sr *RequestItemFilter) WithItemFilterMaxDistance(score int) *RequestItemFilter {
if score < 5 {
return sr
}
sr.updateIFValue(ItemFilterMaxDistance, strconv.Itoa(score))
return sr
}
// WithItemFilterMaxHandlingTime adds MaxHandlingTime ItemFilter
// Specifies the maximum number of handling days the seller requires to ship the item.
// Only items with a handling time less than or equal to this number will be returned.
// (The handling time is the amount of time, in days, required by the seller to get the item
// ready to ship and handed off to the actual carrier who does the delivery.
// It does not include the time required by the carrier to deliver the item.
// Values below 1 are ignored.
func (sr *RequestItemFilter) WithItemFilterMaxHandlingTime(score int) *RequestItemFilter {
if score < 1 {
return sr
}
sr.updateIFValue(ItemFilterMaxHandlingTime, strconv.Itoa(score))
return sr
}
// WithItemFilterMaxQuantity adds MaxQuantity ItemFilter
// Limits the results to listings with a quantity less than or equal to the specified value.
// If MinQuantity is also specified, the MaxQuantity value must be greater than or equal to the MinQuantity value.
//
// Values below 1 are ignored.
func (sr *RequestItemFilter) WithItemFilterMaxQuantity(score int) *RequestItemFilter {
if score < 1 {
return sr
}
sr.updateIFValue(ItemFilterMaxQuantity, strconv.Itoa(score))
return sr
}
// WithItemFilterMinBids adds MinBids ItemFilter
// Limits the results to items with bid counts greater than or equal to the specified value.
// If MaxBids is also specified, the MaxBids value must be greater than or equal to the MinBids value.
//
// Values below 0 are ignored.
func (sr *RequestItemFilter) WithItemFilterMinBids(score int) *RequestItemFilter {
if score < 0 {
return sr
}
sr.updateIFValue(ItemFilterMinBids, strconv.Itoa(score))
return sr
}
// WithItemFilterMinQuantity adds MinQuantity ItemFilter
// Limits the results to listings with a quantity greater than or equal to the specified value.
// If MaxQuantity is also specified, the MaxQuantity value must be greater than or equal to the MinQuantity value.
//
// Values below 1 are ignored.
func (sr *RequestItemFilter) WithItemFilterMinQuantity(score int) *RequestItemFilter {
if score < 1 {
return sr
}
sr.updateIFValue(ItemFilterMinQuantity, strconv.Itoa(score))
return sr
}
// WithItemFilterPaymentMethod adds PaymentMethod ItemFilter
// Limits results to items that accept the specified payment method.
func (sr *RequestItemFilter) WithItemFilterPaymentMethod(payment ItemFilterPaymentMethodOption) *RequestItemFilter {
sr.updateIFValue(ItemFilterPaymentMethod, string(payment))
return sr
}
// WithItemFilterSellerBusinessType adds SellerBusinessType ItemFilter
// Restricts the items to those that are from sellers whose
// business type is the specified value. Only one value can be specified.
func (sr *RequestItemFilter) WithItemFilterSellerBusinessType(businessType ItemFilterSellerBusinessTypeOption) *RequestItemFilter {
sr.updateIFValue(ItemFilterSellerBusinessType, string(businessType))
return sr
}
// WithItemFilterValueBoxInventory adds ValueBoxInventory ItemFilter
// Coming Soon!
// Coming Soon: This filter can be used in conjunction with the sortOrder PricePlusShippingLowest
// to return competitively priced items from eBay top-rated sellers that have a BuyItNow price,
// with the lowest priced item at the top of the list. This filter returns items from categories
// that are catalog-enabled; items from non catalog-enabled categories are not returned.
// Sellers can use this item filter to determine competitive pricing; buying applications can use
// it to obtain competitive items from top rated sellers that are likely to sell quickly.
//
// If set to 1, the item filter constraints are applied and the items are returned accordingly.
// If set to 0 (zero) the item filter is not applied. Defaults to 0.
func (sr *RequestItemFilter) WithItemFilterValueBoxInventory(b bool) *RequestItemFilter {
sr.updateIFValue(ItemFilterValueBoxInventory, strconv.FormatBool(b))
return sr
}
// WithItemFilterSeller adds Seller ItemFilter
// The Seller item filter cannot be used together with either the ExcludeSeller or TopRatedSellerOnly item filters.
// Multiple values are allowed. Up to 100 sellers can be specified.
// 101th and next sellers will be skipped
func (sr *RequestItemFilter) WithItemFilterSeller(sellers ...string) *RequestItemFilter {
sr.addIFValues(ItemFilterSeller, 100, sellers...)
return sr
}
// WithItemFilterExcludeCategory adds ExcludeCategory ItemFilter
// Specify one or more category IDs. Search results will not include
// items from the specified categories or their child categories.
// Valid category IDs.
// 26th and next categories will be skipped
func (sr *RequestItemFilter) WithItemFilterExcludeCategory(categories ...string) *RequestItemFilter {
sr.addIFValues(ItemFilterExcludeCategory, 25, categories...)
return sr
}
// WithItemFilterExcludeSeller adds ExcludeSeller ItemFilter
// Specify one or more seller names. Search results will not include items from the specified sellers.
// The ExcludeSeller item filter cannot be used together with either the Seller or TopRatedSellerOnly item filters.
// 101th and next sellers will be skipped
func (sr *RequestItemFilter) WithItemFilterExcludeSeller(sellers ...string) *RequestItemFilter {
sr.addIFValues(ItemFilterExcludeSeller, 100, sellers...)
return sr
}
// WithItemFilterCondition adds Condition ItemFilter
// This item condition filter allows a user to filter items based on item condition.
func (sr *RequestItemFilter) WithItemFilterCondition(conditions ...ItemFilterConditionOption) *RequestItemFilter {
var values []string
for _, condition := range conditions {
values = append(values, string(condition))
}
// 14 - quantity of available conditions, but let's use 20
sr.addIFValues(ItemFilterCondition, 14, values...)
return sr
}
// WithItemFilterConditionName adds Condition ItemFilter
// This item condition filter allows a user to filter items based on item condition name.
func (sr *RequestItemFilter) WithItemFilterConditionName(conditions ...ItemFilterConditionNameOption) *RequestItemFilter {
var values []string
for _, condition := range conditions {
values = append(values, string(condition))
}
// 14 - quantity of available conditions, but let's use 20
sr.addIFValues(ItemFilterCondition, 14, values...)
return sr
}
// WithItemFilterListingType adds ListingType ItemFilter
// Filters items based listing type information. Default behavior is to return all matching items,
// except Store Inventory format listings.
func (sr *RequestItemFilter) WithItemFilterListingType(listingTypes ...ItemFilterListingTypeOption) *RequestItemFilter {
var values []string
for _, listingType := range listingTypes {
values = append(values, string(listingType))
}
// 6 - quantity of available Listing Types
sr.addIFValues(ItemFilterListingType, 6, values...)
return sr
}
// WithItemFilterLocatedIn adds LocatedIn ItemFilter
// Limits the result set to just those items located in the specified country.
// Item filter AvailableTo cannot be used together with item filter LocatedIn.
//
// Expects the two-letter ISO 3166 country code to indicate the country where the item is located.
// For English names that correspond to each code (e.g., KY="Cayman Islands")
func (sr *RequestItemFilter) WithItemFilterLocatedIn(codes ...string) *RequestItemFilter {
sr.addIFValues(ItemFilterLocatedIn, 25, codes...)
return sr
}
// WithItemFilterMaxPrice adds MaxPrice ItemFilter
// Specifies the maximum current price an item can have to be included in the response.
// If using with MinPrice to specify a price range, the MaxPrice value must be greater than or equal to MinPrice.
// Values below 0 are ignored.
func (sr *RequestItemFilter) WithItemFilterMaxPrice(price float64) *RequestItemFilter {
if price < 0 {
return sr
}
sr.updateIFValue(ItemFilterMaxPrice, strconv.FormatFloat(price, 'f', 2, 64))
return sr
}
// WithItemFilterMaxPriceWithCurrency adds MaxPrice ItemFilter
// Specifies the maximum current price an item can have to be included in the response.
// If using with MinPrice to specify a price range, the MaxPrice value must be greater than or equal to MinPrice.
// Values below 0 are ignored.
func (sr *RequestItemFilter) WithItemFilterMaxPriceWithCurrency(price float64, currency ItemFilterCurrencyIDOption) *RequestItemFilter {
if price < 0 {
return sr
}
sr.updateIFValueWithParameter(ItemFilterMaxPrice, "Currency", string(currency), strconv.FormatFloat(price, 'f', 2, 64))
return sr
}
// WithItemFilterMinPrice adds MinPrice ItemFilter
// Specifies the minimum current price an item can have to be included in the response.
// If using with MaxPrice to specify a price range, the MaxPrice value must be greater than or equal to MinPrice.
// Values below 0 are ignored.
func (sr *RequestItemFilter) WithItemFilterMinPrice(price float64) *RequestItemFilter {
if price < 0 {
return sr
}
sr.updateIFValue(ItemFilterMinPrice, strconv.FormatFloat(price, 'f', 2, 64))
return sr
}
// WithItemFilterMinPriceWithCurrency adds MinPrice ItemFilter
// Specifies the minimum current price an item can have to be included in the response.
// If using with MaxPrice to specify a price range, the MaxPrice value must be greater than or equal to MinPrice.
// Values below 0 are ignored.
func (sr *RequestItemFilter) WithItemFilterMinPriceWithCurrency(price float64, currency ItemFilterCurrencyIDOption) *RequestItemFilter {
if price < 0 {
return sr
}
sr.updateIFValueWithParameter(ItemFilterMinPrice, "Currency", string(currency), strconv.FormatFloat(price, 'f', 2, 64))
return sr
}
// WithItemFilterEndTimeFrom adds EndTimeFrom ItemFilter
// Limits the results to items ending on or after the specified time. Specify a time in the future.
func (sr *RequestItemFilter) WithItemFilterEndTimeFrom(datetime string) *RequestItemFilter {
sr.updateIFValue(ItemFilterEndTimeFrom, datetime)
return sr
}
// WithItemFilterEndTimeTo adds EndTimeTo ItemFilter
// Limits the results to items ending on or before the specified time. Specify a time in the future.
func (sr *RequestItemFilter) WithItemFilterEndTimeTo(datetime string) *RequestItemFilter {
sr.updateIFValue(ItemFilterEndTimeTo, datetime)
return sr
}
// WithItemFilterModTimeFrom adds ModTimeFrom ItemFilter
// Limits the results to active items whose status has changed since the specified time.
// Specify a time in the past. Time must be in GMT.
func (sr *RequestItemFilter) WithItemFilterModTimeFrom(datetime string) *RequestItemFilter {
sr.updateIFValue(ItemFilterModTimeFrom, datetime)
return sr
}
// WithItemFilterStartTimeFrom adds StartTimeFrom ItemFilter
// Limits the results to items started on or after the specified time. Specify a time in the future.
func (sr *RequestItemFilter) WithItemFilterStartTimeFrom(datetime string) *RequestItemFilter {
sr.updateIFValue(ItemFilterStartTimeFrom, datetime)
return sr
}
// WithItemFilterStartTimeTo adds StartTimeTo ItemFilter
// Limits the results to items started on or before the specified time. Specify a time in the future.
func (sr *RequestItemFilter) WithItemFilterStartTimeTo(datetime string) *RequestItemFilter {
sr.updateIFValue(ItemFilterStartTimeTo, datetime)
return sr
}