mock shop page allows updating of listings
This commit is contained in:
@@ -43,6 +43,7 @@ func Routes(
|
||||
|
||||
mockShops := platformGroup.Group("/shops/mocks/:shop-id")
|
||||
mockShops.POST("/listings", response.Handler(as.addMockListing))
|
||||
mockShops.PUT("/listings/:listing-id", response.Handler(as.updateMockListing))
|
||||
|
||||
syncGroups := r.Group("/:acctID/inventory/sync-groups")
|
||||
syncGroups.POST("", pub.Publish("/:acctID/inventory/sync-groups"), response.Handler(as.saveNewSyncGroup))
|
||||
@@ -304,7 +305,49 @@ func (s *accountSubrouter) addMockListing(c *gin.Context) (response.Response, er
|
||||
return nil, fmt.Errorf("failed to create new listing: %w", err)
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
return response.StatusCreated(), nil
|
||||
}
|
||||
|
||||
// PUT /:acctID/platforms/:platform/shops/mocks/:shop-id/listings/:listing-id
|
||||
func (s *accountSubrouter) updateMockListing(c *gin.Context) (response.Response, error) {
|
||||
acctID := auth.GetIdentity(c).Account.AccountID
|
||||
|
||||
var (
|
||||
platform accounts.Platform
|
||||
shopID string
|
||||
listingID string
|
||||
name string
|
||||
sku string
|
||||
description string
|
||||
)
|
||||
|
||||
err := param.Path("platform", param.Platform(&platform)).
|
||||
Path("shop-id", param.Text(&shopID)).
|
||||
Path("listing-id", param.Text(&listingID)).
|
||||
Form("name", param.Text(&name)).
|
||||
Form("sku", param.Text(&sku)).
|
||||
Form("description", param.Text(&description)).
|
||||
Unmarshal(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = s.accts.UpdateMockListing(
|
||||
c,
|
||||
accounts.MockListing{
|
||||
AccountShopListingIDs: accounts.NewAccountIDs(acctID).
|
||||
ShopID(platform, shopID).
|
||||
ListingID(listingID),
|
||||
Name: name,
|
||||
SKU: sku,
|
||||
Description: description,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to update new listing: %w", err)
|
||||
}
|
||||
|
||||
return response.StatusOK(), nil
|
||||
}
|
||||
|
||||
func lowerSnakeCase(s accounts.Platform) string {
|
||||
|
||||
Reference in New Issue
Block a user