Skip to content

Commit

Permalink
Merge pull request #33 from goark/fix-bugs-and-testing
Browse files Browse the repository at this point in the history
Bump up external packages
  • Loading branch information
spiegel-im-spiegel committed Feb 3, 2024
2 parents 401b112 + 2a4615a commit 209d815
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/vulns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ^1.20
go-version-file: 'go.mod'
- name: WriteGoList
run: go list -json -m all > go.list
- name: Nancy
Expand Down
4 changes: 2 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tasks:
cmds:
- go mod verify
- go test -shuffle on ./...
- docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.51.1 golangci-lint run --enable gosec --timeout 3m0s ./...
- docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.55.2 golangci-lint run --enable gosec --timeout 3m0s ./...
sources:
- ./go.mod
- '**/*.go'
Expand All @@ -28,4 +28,4 @@ tasks:
clean:
desc: Initialize module and build cache, and remake go.sum file.
cmds:
- go mod tidy -v -go=1.20
- go mod tidy -v -go=1.21
20 changes: 10 additions & 10 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ const (
defaultPartnerType = "Associates"
)

//Query interface for Client type
// Query interface for Client type
type Query interface {
Operation() Operation
Payload() ([]byte, error)
}

//Client interface
// Client interface
type Client interface {
Marketplace() string
PartnerTag() string
Expand All @@ -32,7 +32,7 @@ type Client interface {
RequestContext(context.Context, Query) ([]byte, error)
}

//client is http.Client for Aozora API Server
// client is http.Client for Aozora API Server
type client struct {
server *Server
client fetch.Client
Expand All @@ -41,27 +41,27 @@ type client struct {
secretKey string
}

//Marketplace returns name of Marketplace parameter for PA-API v5
// Marketplace returns name of Marketplace parameter for PA-API v5
func (c *client) Marketplace() string {
return c.server.Marketplace()
}

//PartnerTag returns PartnerTag parameter for PA-API v5
// PartnerTag returns PartnerTag parameter for PA-API v5
func (c *client) PartnerTag() string {
return c.partnerTag
}

//PartnerType returns PartnerType parameter for PA-API v5
// PartnerType returns PartnerType parameter for PA-API v5
func (c *client) PartnerType() string {
return defaultPartnerType
}

//Request method returns response data (JSON format) by PA-APIv5.
// Request method returns response data (JSON format) by PA-APIv5.
func (c *client) Request(q Query) ([]byte, error) {
return c.RequestContext(context.Background(), q)
}

//RequestContext method returns response data (JSON format) by PA-APIv5. (with context.Context)
// RequestContext method returns response data (JSON format) by PA-APIv5. (with context.Context)
func (c *client) RequestContext(ctx context.Context, q Query) ([]byte, error) {
payload, err := q.Payload()
if err != nil {
Expand All @@ -79,10 +79,10 @@ func (c *client) post(ctx context.Context, cmd Operation, payload []byte) ([]byt
u := c.server.URL(cmd.Path())
hds := newHeaders(c.server, cmd, dt)
sig := c.signiture(c.signedString(hds, payload), hds)
resp, err := c.client.Post(
resp, err := c.client.PostWithContext(
ctx,
u,
bytes.NewReader(payload),
fetch.WithContext(ctx),
fetch.WithRequestHeaderSet("Accept", c.server.Accept()),
fetch.WithRequestHeaderSet("Accept-Language", c.server.AcceptLanguage()),
fetch.WithRequestHeaderSet("Content-Type", c.server.ContentType()),
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/goark/pa-api

go 1.20
go 1.21

require (
github.com/goark/errs v1.1.0
github.com/goark/fetch v0.3.0
github.com/goark/errs v1.3.2
github.com/goark/fetch v0.4.1
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github.com/goark/errs v1.1.0 h1:FKnyw4LVyRADIjM8Nj0Up6r0/y5cfADvZAd1E+tthXE=
github.com/goark/errs v1.1.0/go.mod h1:TtaPEoadm2mzqzfXdkkfpN2xuniCFm2q4JH+c1qzaqw=
github.com/goark/fetch v0.3.0 h1:2m32EGOLBi99RzI5urFfmv5++CMqfenVw7NH8z/lbX8=
github.com/goark/fetch v0.3.0/go.mod h1:sqDdPbbHeIjDVeHrgvzhHpkUr8X9pVC9DgJoVwU02x0=
github.com/goark/errs v1.3.2 h1:ifccNe1aK7Xezt4XVYwHUqalmnfhuphnEvh3FshCReQ=
github.com/goark/errs v1.3.2/go.mod h1:ZsQucxaDFVfSB8I99j4bxkDRfNOrlKINwg72QMuRWKw=
github.com/goark/fetch v0.4.1 h1:Y59g9sAdgqjPS7UADdLIoQGRxJE1WMo5ixlJi/ZcCfc=
github.com/goark/fetch v0.4.1/go.mod h1:umZxLIJHa15J8EQSp5zft1dHDv0VGwmQL6pOfaJ60FY=

0 comments on commit 209d815

Please sign in to comment.