Documentation
¶
Overview ¶
Package paapi5 APIs for Amazon Product Advertising API v5 client
Index ¶
- type Client
- type ClientOptFunc
- type Error
- type Marketplace
- type MarketplaceEnum
- type Operation
- type Query
- type Server
- func (s *Server) AWS4Request() string
- func (s *Server) Accept() string
- func (s *Server) AcceptLanguage() string
- func (s *Server) ContentEncoding() string
- func (s *Server) ContentType() string
- func (s *Server) CreateClient(associateTag, accessKey, secretKey string, opts ...ClientOptFunc) Client
- func (s *Server) HMACAlgorithm() string
- func (s *Server) HostName() string
- func (s *Server) Marketplace() string
- func (s *Server) Region() string
- func (s *Server) ServiceName() string
- func (s *Server) URL(path string) *url.URL
- type ServerOptFunc
- type TimeStamp
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Marketplace() string PartnerTag() string PartnerType() string Request(Query) ([]byte, error) RequestContext(context.Context, Query) ([]byte, error) }
Client interface
Example ¶
package main import ( "context" "fmt" "net/http" paapi5 "github.com/spiegel-im-spiegel/pa-api" ) func main() { //Create client for Janan region client := paapi5.New( paapi5.WithMarketplace(paapi5.LocaleJapan), ).CreateClient( "mytag-20", "AKIAIOSFODNN7EXAMPLE", "1234567890", paapi5.WithContext(context.Background()), paapi5.WithHttpClient(http.DefaultClient), ) fmt.Println("Marketplace:", client.Marketplace()) }
Output: Marketplace: www.amazon.co.jp
func DefaultClient ¶
DefaultClient function returns an default Client instance with associate-tag, access-key, and secret-key parameters.
Example ¶
package main import ( "fmt" paapi5 "github.com/spiegel-im-spiegel/pa-api" ) func main() { client := paapi5.DefaultClient("mytag-20", "AKIAIOSFODNN7EXAMPLE", "1234567890") //Create default client fmt.Println("Marketplace:", client.Marketplace()) }
Output: Marketplace: www.amazon.com
type ClientOptFunc ¶ added in v0.2.0
type ClientOptFunc func(*client)
ClientOptFunc type is self-referential function type for Server.CreateClient method. (functional options pattern)
func WithContext ¶ added in v0.2.0
func WithContext(ctx context.Context) ClientOptFunc
WithContext is dummy function. Because this function is deprecated.
func WithHttpClient ¶ added in v0.3.0
func WithHttpClient(hc *http.Client) ClientOptFunc
WithHttpClient function returns ClientOptFunc function value. This function is used in Server.CreateClient method that represents http.Client.
type Marketplace ¶ added in v0.4.0
Marketplace is interface class of locale information.
func MarketplaceOf ¶ added in v0.4.0
func MarketplaceOf(s string) Marketplace
MarketplaceOf function returns Marketplace instance from service domain.
type MarketplaceEnum ¶ added in v0.9.1
type MarketplaceEnum int
MarketplaceEnum is enumeration of locale information.
const ( LocaleUnknown MarketplaceEnum = iota //Unknown local LocaleAustralia //Australia LocaleBrazil //Brazil LocaleCanada //Canada LocaleEgypt //Egypt LocaleFrance //France LocaleGermany //Germany LocaleIndia //India LocaleItaly //Italy LocaleJapan //Japan LocaleMexico //Mexico LocaleNetherlands //Netherlands LocalePoland //Poland LocaleSingapore //Singapore LocaleSaudiArabia //SaudiArabia LocaleSpain //Spain LocaleSweden //Sweden LocaleTurkey //Turkey LocaleUnitedArabEmirates //United Arab Emirates LocaleUnitedKingdom //United Kingdom LocaleUnitedStates //United States DefaultMarketplace = LocaleUnitedStates )
func (MarketplaceEnum) HostName ¶ added in v0.9.1
func (m MarketplaceEnum) HostName() string
HostName returns hostname of Marketplace.
func (MarketplaceEnum) Language ¶ added in v0.9.1
func (m MarketplaceEnum) Language() string
Language returns language name of Marketplace.
func (MarketplaceEnum) Region ¶ added in v0.9.1
func (m MarketplaceEnum) Region() string
Region returns region name of Marketplace.
func (MarketplaceEnum) String ¶ added in v0.9.1
func (m MarketplaceEnum) String() string
String returns marketplace name of Marketplace.
type Operation ¶
type Operation int
Operation is enumeration of PA-API operation
func (Operation) MarshalJSON ¶
MarshalJSON method implements the json.Marshaler interface.
func (*Operation) UnmarshalJSON ¶
UnmarshalJSON method implements json.Unmarshaler interface.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server type is a implementation of PA-API service.
Example ¶
package main import ( "fmt" paapi5 "github.com/spiegel-im-spiegel/pa-api" ) func main() { sv := paapi5.New() //Create default server fmt.Println("Marketplace:", sv.Marketplace()) fmt.Println("Region:", sv.Region()) fmt.Println("AcceptLanguage:", sv.AcceptLanguage()) fmt.Println("URL:", sv.URL(paapi5.GetItems.Path())) }
Output: Marketplace: www.amazon.com Region: us-east-1 AcceptLanguage: en_US URL: https://webservices.amazon.com/paapi5/getitems
func New ¶
func New(opts ...ServerOptFunc) *Server
New function returns an Server instance with options.
Example ¶
package main import ( "fmt" paapi5 "github.com/spiegel-im-spiegel/pa-api" ) func main() { sv := paapi5.New(paapi5.WithMarketplace(paapi5.LocaleJapan)) //Create server in Japan region fmt.Println("Marketplace:", sv.Marketplace()) fmt.Println("Region:", sv.Region()) fmt.Println("AcceptLanguage:", sv.AcceptLanguage()) fmt.Println("URL:", sv.URL(paapi5.GetItems.Path())) }
Output: Marketplace: www.amazon.co.jp Region: us-west-2 AcceptLanguage: ja_JP URL: https://webservices.amazon.co.jp/paapi5/getitems
func (*Server) AWS4Request ¶
AWS4Request method returns AWS4Request parameter for PA-API v5
func (*Server) AcceptLanguage ¶
AcceptLanguage method returns Accept-Language parameter for PA-API v5
func (*Server) ContentEncoding ¶
ContentEncoding method returns Content-Encoding parameter for PA-API v5
func (*Server) ContentType ¶
ContentType method returns Content-Type parameter for PA-API v5
func (*Server) CreateClient ¶
func (s *Server) CreateClient(associateTag, accessKey, secretKey string, opts ...ClientOptFunc) Client
CreateClient method returns an Client instance with associate-tag, access-key, secret-key, and other options.
func (*Server) HMACAlgorithm ¶
HMACAlgorithm method returns HMAC-Algorithm parameter for PA-API v5
func (*Server) Marketplace ¶
Marketplace method returns marketplace name for PA-API v5.
func (*Server) ServiceName ¶
ServiceName method returns ServiceName parameter for PA-API v5
type ServerOptFunc ¶
type ServerOptFunc func(*Server)
ServerOptFunc type is self-referential function type for New functions. (functional options pattern)
func WithLanguage ¶ added in v0.4.0
func WithLanguage(language string) ServerOptFunc
WithLanguage function returns ServerOptFunc function value. This function is used in New functions that represents Accept-Language parameter.
func WithMarketplace ¶
func WithMarketplace(marketplace Marketplace) ServerOptFunc
WithMarketplace function returns ServerOptFunc function value. This function is used in New functions that represents Marketplace data.
type TimeStamp ¶
TimeStamp is wrapper class of time.Time
func NewTimeStamp ¶
NewTimeStamp returns TimeStamp instance