goark / pa-api Goto Github PK
View Code? Open in Web Editor NEWAPIs for Amazon Product Advertising API v5 by Golang
License: Apache License 2.0
APIs for Amazon Product Advertising API v5 by Golang
License: Apache License 2.0
Hi! I was looking for some update in a project, and when I typed
go get -u github.com/spiegel-im-spiegel/pa-api
here's what I got:
go get: github.com/spiegel-im-spiegel/[email protected]: parsing go.mod:
module declares its path as: github.com/goark/errs
but was required as: github.com/spiegel-im-spiegel/errs
I guess this line should be updated according to the new errs
package location ๐
Hi, @isaka1022 san.
I would like to be able to mock time generation(time.Now()) when running unit tests.
I tried to write the code like above, but if you have a better way, please let me know.
import (
"github.com/dnaeon/go-vcr/recorder"
paapi5 "github.com/goark/pa-api"
"github.com/goark/pa-api/query"
)
func Test(t *testing.T) {
t.Run("tests", func(t *testing.T) {
r, err := recorder.New(path)
if err != nil {
t.Fatal(err)
}
defer r.Stop()
client := &http.Client{
Transport: r,
}
amazon := paapi5.New().
CreateClient(
tag, access, secret,
paapi5.WithHttpClient(client),
)
ctx := context.Background()
q := query.NewSearchItems(...)
// It would be nice to be able to mock up time generation when requesting here.
content, err := amazon.RequestContext(ctx, q)
if err != nil {
t.Fatal(err)
}
})
}
func (c *client) post(ctx context.Context, cmd Operation, payload []byte) ([]byte, error) {
- dt := NewTimeStamp(time.Now())
+ dt := NewTimeStamp(contextGetTime(ctx))
u := c.server.URL(cmd.Path())
hds := newHeaders(c.server, cmd, dt)
sig := c.signiture(c.signedString(hds, payload), hds)
@@ -188,6 +188,20 @@ func (h *headers) values() string {
return strings.Join(list, "\n")
}
+type ctxTimeKey struct{}
+
+func ContextSetTime(ctx context.Context, t time.Time) context.Context {
+ return context.WithValue(ctx, ctxTimeKey{}, t)
+}
+
+func contextGetTime(ctx context.Context) time.Time {
+ val := ctx.Value(ctxTimeKey{})
+ if t, ok := val.(time.Time); !ok {
+ return t
+ }
+ return time.Now()
+}
First of all great work with the go PAapi, it was really helpful.
The issue here is that the response mapping process is missing an attribute ParentASIN
in the Item
struct.
If the selected ASIN is a variant option (e.x. https://www.amazon.com/dp/B08GQHCJVZ) and it has the EnabEnableParentASIN
the Response > Item
struct does not seem to have that property.
Hello everyone,
I want to get BrowseNode information through GetBrowseNodes operation on paapi5.
https://webservices.amazon.com/paapi5/documentation/getbrowsenodes.html
I would like to get BrowseNode information as SearchItems and GetItems operations in pa-api library like below.
//Make query
q := query.GetBrowseNodes(
client.Marketplace(),
client.PartnerTag(),
client.PartnerType(),
). BrowseNodeIds([]string{"3040", "3045"})
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.