mirror of
https://github.com/cubixle/ebay.git
synced 2026-04-30 08:58:45 +01:00
wip integration bidding
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package ebay
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OfferService handles communication with the Offer API
|
||||
@@ -22,6 +25,11 @@ const (
|
||||
BuyMarketplaceUSA = "EBAY_US"
|
||||
)
|
||||
|
||||
// Valid values for the "auctionStatus" Bidding field.
|
||||
const (
|
||||
BiddingAuctionStatusEnded = "ENDED"
|
||||
)
|
||||
|
||||
// OptBuyMarketplace adds the header containing the marketplace id:
|
||||
// https://developer.ebay.com/api-docs/buy/static/ref-marketplace-supported.html
|
||||
//
|
||||
@@ -31,3 +39,42 @@ func OptBuyMarketplace(marketplaceID string) func(*http.Request) {
|
||||
req.Header.Set("X-EBAY-C-MARKETPLACE-ID", marketplaceID)
|
||||
}
|
||||
}
|
||||
|
||||
// Bidding represents an eBay item bidding.
|
||||
type Bidding struct {
|
||||
AuctionStatus string `json:"auctionStatus"`
|
||||
AuctionEndDate time.Time `json:"auctionEndDate"`
|
||||
ItemID string `json:"itemId"`
|
||||
CurrentPrice struct {
|
||||
Value string `json:"value"`
|
||||
Currency string `json:"currency"`
|
||||
} `json:"currentPrice"`
|
||||
BidCount int `json:"bidCount"`
|
||||
HighBidder bool `json:"highBidder"`
|
||||
ReservePriceMet bool `json:"reservePriceMet"`
|
||||
SuggestedBidAmounts []struct {
|
||||
Value string `json:"value"`
|
||||
Currency string `json:"currency"`
|
||||
} `json:"suggestedBidAmounts"`
|
||||
CurrentProxyBid struct {
|
||||
ProxyBidID string `json:"proxyBidId"`
|
||||
MaxAmount struct {
|
||||
Value string `json:"value"`
|
||||
Currency string `json:"currency"`
|
||||
} `json:"maxAmount"`
|
||||
} `json:"currentProxyBid"`
|
||||
}
|
||||
|
||||
// GetBidding retrieves the buyer's bidding details on an auction.
|
||||
//
|
||||
// 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...)
|
||||
if err != nil {
|
||||
return Item{}, err
|
||||
}
|
||||
var it Item
|
||||
return it, s.client.Do(ctx, req, &it)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user