Ejemplo n.º 1
0
func Delete(seller *seller.Seller, notification string, enabled bool, queues []string) error {
	u, err := gomws.CreateUrl(DeleteAction, BaseURL, Version, &seller.Marketplace)
	if err != nil {
		return err
	}

	params := u.Query()
	params.Set("MarketplaceId", seller.Marketplace.Id)
	params.Set("Destination.DeliveryChannel", "SQS")
	params.Set("NotificationType", notification)

	for k, v := range queues {
		params.Set(fmt.Sprintf("Destination.AttributeList.member.%v.Key", k+1), "sqsQueueUrl")
		params.Set(fmt.Sprintf("Destination.AttributeList.member.%v.Value", k+1), v)
	}

	u.RawQuery = params.Encode()
	seller.Sign(u)

	bodyBytes, err := gomws.ProcessUrl(u.String(), "POST")
	if err != nil {
		return err
	}

	subErr := gomws.MWSSubscriptionError{}
	xml.Unmarshal(bodyBytes, &subErr)
	if subErr.Message != "" {
		return errors.New(fmt.Sprintf("%s: %s", subErr.Code, subErr.Message))
	}

	return nil
}
Ejemplo n.º 2
0
func List(seller *seller.Seller) ([]string, error) {
	u, err := gomws.CreateUrl(ListAction, BaseURL, Version, &seller.Marketplace)
	if err != nil {
		return nil, err
	}

	params := u.Query()
	params.Set("MarketplaceId", seller.Marketplace.Id)
	u.RawQuery = params.Encode()
	seller.Sign(u)

	bodyBytes, err := gomws.ProcessUrl(u.String(), "POST")
	if err != nil {
		return nil, err
	}

	subErr := gomws.MWSSubscriptionError{}
	xml.Unmarshal(bodyBytes, &subErr)
	if subErr.Message != "" {
		return nil, errors.New(fmt.Sprintf("%s: %s", subErr.Code, subErr.Message))
	}

	r := listResponse{}
	err = xml.Unmarshal(bodyBytes, &r)
	return r.Values, err
}