File: ecommerce.go

package info (click to toggle)
golang-github-docker-goamz 0.0~git20160206.0.f0a21f5-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,580 kB
  • sloc: makefile: 66
file content (34 lines) | stat: -rw-r--r-- 1,112 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package ecommerce

import (
	"net/http"

	"github.com/docker/goamz/aws"
)

// ProductAdvertising provides methods for querying the product advertising API
type ProductAdvertising struct {
	service      aws.Service
	associateTag string
}

// New creates a new ProductAdvertising client
func New(auth aws.Auth, associateTag string) (p *ProductAdvertising, err error) {
	serviceInfo := aws.ServiceInfo{Endpoint: "https://webservices.amazon.com", Signer: aws.V2Signature}
	if service, err := aws.NewService(auth, serviceInfo); err == nil {
		p = &ProductAdvertising{*service, associateTag}
	}
	return
}

// PerformOperation is the main method used for interacting with the product advertising API
func (p *ProductAdvertising) PerformOperation(operation string, params map[string]string) (resp *http.Response, err error) {
	params["Operation"] = operation
	return p.query(params)
}

func (p *ProductAdvertising) query(params map[string]string) (resp *http.Response, err error) {
	params["Service"] = "AWSECommerceService"
	params["AssociateTag"] = p.associateTag
	return p.service.Query("GET", "/onca/xml", params)
}