mirror of
https://github.com/cubixle/ebay.git
synced 2026-04-30 17:48:42 +01:00
Add more GetBidding test and IsError
This commit is contained in:
@@ -65,16 +65,80 @@ type Bidding struct {
|
||||
} `json:"currentProxyBid"`
|
||||
}
|
||||
|
||||
// GetBidding retrieves the buyer's bidding details on an auction.
|
||||
// Some valid eBay error codes for the GetBidding method.
|
||||
//
|
||||
// eBay API docs: https://developer.ebay.com/api-docs/buy/offer/resources/bidding/methods/getBidding#h2-error-codes
|
||||
const (
|
||||
ErrGetBiddingMarketplaceNotSupported = 120017
|
||||
ErrGetBiddingNoBiddingActivity = 120033
|
||||
)
|
||||
|
||||
// GetBidding retrieves the buyer's bidding details on a specific auction item.
|
||||
//
|
||||
// eBay API docs: https://developer.ebay.com/api-docs/buy/offer/resources/bidding/methods/getBidding
|
||||
func (s *OfferService) GetBidding(ctx context.Context, itemID, marketplaceID string, opts ...Opt) (Item, error) {
|
||||
u := fmt.Sprintf("buy/offer/v1_beta/bidding/%s", itemID)
|
||||
opts = append(opts, OptBuyMarketplace(marketplaceID))
|
||||
req, err := s.client.NewRequest(http.MethodGet, u, opts...)
|
||||
req, err := s.client.NewRequest(http.MethodGet, u, nil, opts...)
|
||||
if err != nil {
|
||||
return Item{}, err
|
||||
}
|
||||
var it Item
|
||||
return it, s.client.Do(ctx, req, &it)
|
||||
}
|
||||
|
||||
// ProxyBid represents an eBay proxy bid.
|
||||
type ProxyBid struct {
|
||||
ProxyBidID string `json:"proxyBidId"`
|
||||
}
|
||||
|
||||
// Some valid eBay error codes for the PlaceProxyBid method.
|
||||
//
|
||||
// eBay API docs: https://developer.ebay.com/api-docs/buy/offer/resources/bidding/methods/getBidding#h2-error-codes
|
||||
const (
|
||||
ErrPlaceProxyBidAuctionEndedBecauseOfBuyItNow = 120002
|
||||
ErrPlaceProxyBidBidCannotBeGreaterThanBuyItNowPrice = 120005
|
||||
ErrPlaceProxyBidAmountTooHigh = 120007
|
||||
ErrPlaceProxyBidAmountTooLow = 120008
|
||||
ErrPlaceProxyBidCurrencyMustMatchItemPriceCurrency = 120009
|
||||
ErrPlaceProxyBidCannotLowerYourProxyBid = 120010
|
||||
ErrPlaceProxyBidAmountExceedsLimit = 120011
|
||||
ErrPlaceProxyBidAuctionHasEnded = 120012
|
||||
ErrPlaceProxyBidAmountInvalid = 120013
|
||||
ErrPlaceProxyBidCurrencyInvalid = 120014
|
||||
ErrPlaceProxyBidMaximumBidAmountMissing = 120016
|
||||
)
|
||||
|
||||
// PlaceProxyBid places a proxy bid for the buyer on a specific auction item.
|
||||
//
|
||||
// You must ensure the user agrees to the "Terms of use for Adult Only category"
|
||||
// (https://signin.ebay.com/ws/eBayISAPI.dll?AdultSignIn2) if he wishes to bid on on a adult-only item.
|
||||
//
|
||||
// eBay API docs: https://developer.ebay.com/api-docs/buy/offer/resources/bidding/methods/getBidding
|
||||
func (s *OfferService) PlaceProxyBid(ctx context.Context, itemID, marketplaceID, maxAmount, currency string, userConsentAdultOnlyItem bool, opts ...Opt) (ProxyBid, error) {
|
||||
u := fmt.Sprintf("buy/offer/v1_beta/bidding/%s/place_proxy_bid", itemID)
|
||||
opts = append(opts, OptBuyMarketplace(marketplaceID))
|
||||
pl := struct {
|
||||
MaxAmount struct {
|
||||
Currency string `json:"currency"`
|
||||
Value string `json:"value"`
|
||||
} `json:"maxAmount"`
|
||||
UserConsent struct {
|
||||
AdultOnlyItem bool `json:"adultOnlyItem"`
|
||||
} `json:"userConsent"`
|
||||
}{
|
||||
MaxAmount: struct {
|
||||
Currency string `json:"currency"`
|
||||
Value string `json:"value"`
|
||||
}{currency, maxAmount},
|
||||
UserConsent: struct {
|
||||
AdultOnlyItem bool `json:"adultOnlyItem"`
|
||||
}{userConsentAdultOnlyItem},
|
||||
}
|
||||
req, err := s.client.NewRequest(http.MethodPost, u, &pl, opts...)
|
||||
if err != nil {
|
||||
return ProxyBid{}, err
|
||||
}
|
||||
var p ProxyBid
|
||||
return p, s.client.Do(ctx, req, &p)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user