Configure HttpClient, added context parameter to all methods (#37)

Context is needed to limit time of execution of a method. Previously, context was passed to structure and it was stored inside structure which is a bad practice. Now we need to pass context to function, which is a best practice
This commit is contained in:
Kirill
2023-08-05 13:50:34 +03:00
committed by GitHub
parent 018d40e641
commit 854d110ab1
41 changed files with 698 additions and 493 deletions

View File

@@ -1,6 +1,7 @@
package ozon
import (
"context"
"net/http"
"time"
@@ -90,12 +91,12 @@ type GetCurrentSellerRatingInfoGroupItemChange struct {
Meaning string `json:"meaning"`
}
func (c Rating) GetCurrentSellerRatingInfo() (*GetCurrentSellerRatingInfoResponse, error) {
func (c Rating) GetCurrentSellerRatingInfo(ctx context.Context) (*GetCurrentSellerRatingInfoResponse, error) {
url := "/v1/rating/summary"
resp := &GetCurrentSellerRatingInfoResponse{}
response, err := c.client.Request(http.MethodPost, url, nil, resp, nil)
response, err := c.client.Request(ctx, http.MethodPost, url, nil, resp, nil)
if err != nil {
return nil, err
}
@@ -189,12 +190,12 @@ type GetSellerRatingInfoPeriodRatingValueStatus struct {
Warning bool `json:"warning"`
}
func (c Rating) GetSellerRatingInfoForPeriod(params *GetSellerRatingInfoForPeriodParams) (*GetSellerRatingInfoPeriodResponse, error) {
func (c Rating) GetSellerRatingInfoForPeriod(ctx context.Context, params *GetSellerRatingInfoForPeriodParams) (*GetSellerRatingInfoPeriodResponse, error) {
url := "/v1/rating/history"
resp := &GetSellerRatingInfoPeriodResponse{}
response, err := c.client.Request(http.MethodPost, url, params, resp, nil)
response, err := c.client.Request(ctx, http.MethodPost, url, params, resp, nil)
if err != nil {
return nil, err
}