|
|
|
@ -1,54 +1,9 @@
|
|
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
capi "git.vdhsn.com/barretthousen/barretthousen/src/catalog/api/grpc"
|
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func NewCatalogServiceClient(conn grpc.ClientConnInterface) *CatalogServiceClient {
|
|
|
|
|
return &CatalogServiceClient{
|
|
|
|
|
CatalogClient: capi.NewCatalogClient(conn),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CatalogServiceClient struct {
|
|
|
|
|
capi.CatalogClient
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type AuctionCreatedEvent struct {
|
|
|
|
|
Fingerprint string
|
|
|
|
|
ID int
|
|
|
|
|
Duplicate bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (css *CatalogServiceClient) UpdateUpcomingAuction(ctx context.Context, a Auction) (AuctionCreatedEvent, error) {
|
|
|
|
|
ac, err := css.ImportAuction(ctx, &capi.ImportAuctionMessage{
|
|
|
|
|
Items: int32(a.ItemCount),
|
|
|
|
|
Start: timestamppb.New(a.Start),
|
|
|
|
|
End: timestamppb.New(a.End),
|
|
|
|
|
Title: a.Title,
|
|
|
|
|
Description: a.Description,
|
|
|
|
|
SourceSiteURL: a.Source.SiteURL,
|
|
|
|
|
SourceSiteName: a.Source.Name,
|
|
|
|
|
SourceURL: a.Source.AuctionURL,
|
|
|
|
|
Country: a.Address.CountryCode,
|
|
|
|
|
Province: a.Address.State,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
return AuctionCreatedEvent{}, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AuctionCreatedEvent{
|
|
|
|
|
Fingerprint: ac.Auction.Fingerprint,
|
|
|
|
|
ID: int(ac.Auction.Id),
|
|
|
|
|
Duplicate: ac.Duplicate,
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Auction struct {
|
|
|
|
|
ID int `json:"id,omitempty"`
|
|
|
|
|
Fingerprint string `json:"fingerprint,omitempty"`
|
|
|
|
|