Exemplo n.º 1
0
func Status(seller *seller.Seller) (string, error) {
	u, err := gomws.CreateUrl(GetStatusAction, BaseURL, Version, &seller.Marketplace)
	if err != nil {
		return "", err
	}

	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(subErr.Message)
	}

	r := gomws.StatusResponse{}
	err = xml.Unmarshal(bodyBytes, &r)
	if err != nil {
		return "", err
	}

	return r.Status, nil
}
Exemplo n.º 2
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
}
Exemplo n.º 3
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
}