fix/change string to time.Time where possible
This commit is contained in:
		@@ -82,9 +82,9 @@ func (c Client) Request(method string, path string, req, resp interface{}) (*Res
 | 
			
		||||
	response.Data = resp
 | 
			
		||||
	response.StatusCode = httpResp.StatusCode
 | 
			
		||||
	if httpResp.StatusCode == http.StatusOK {
 | 
			
		||||
		err = json.Unmarshal(body, &response)
 | 
			
		||||
	} else {
 | 
			
		||||
		err = json.Unmarshal(body, &response.Data)
 | 
			
		||||
	} else {
 | 
			
		||||
		err = json.Unmarshal(body, &response)
 | 
			
		||||
	}
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								core.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								core.go
									
									
									
									
									
								
							@@ -4,6 +4,8 @@ import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"reflect"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type CommonResponse struct {
 | 
			
		||||
@@ -99,3 +101,11 @@ func isZero(v interface{}) (bool, error) {
 | 
			
		||||
	}
 | 
			
		||||
	return v == reflect.Zero(t).Interface(), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TimeFromString(t *testing.T, datetime string) time.Time {
 | 
			
		||||
	dt, err := time.Parse("2006-01-02T15:04:05Z", datetime)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Errorf("error when parsing time: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
	return dt
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								ozon/fbs.go
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								ozon/fbs.go
									
									
									
									
									
								
							@@ -2,6 +2,7 @@ package ozon
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	core "github.com/diphantxm/ozon-api-client"
 | 
			
		||||
)
 | 
			
		||||
@@ -15,10 +16,10 @@ type ListUnprocessedShipmentsParams struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ListUnprocessedShipmentsFilter struct {
 | 
			
		||||
	CutoffFrom         string  `json:"cutoff_from"`
 | 
			
		||||
	CutoffTo           string  `json:"cutoff_to"`
 | 
			
		||||
	DeliveringDateFrom string  `json:"delivering_date_from"`
 | 
			
		||||
	DeliveringDateTo   string  `json:"delivering_date_to"`
 | 
			
		||||
	CutoffFrom         time.Time `json:"cutoff_from"`
 | 
			
		||||
	CutoffTo           time.Time `json:"cutoff_to"`
 | 
			
		||||
	DeliveringDateFrom time.Time `json:"delivering_date_from"`
 | 
			
		||||
	DeliveringDateTo   time.Time `json:"delivering_date_to"`
 | 
			
		||||
	DeliveryMethodId   []int64   `json:"deliveryMethodId"`
 | 
			
		||||
	ProviderId         []int64   `json:"provider_id"`
 | 
			
		||||
	Status             string    `json:"status"`
 | 
			
		||||
@@ -51,8 +52,8 @@ type ListUnprocessedShipmentsPosting struct {
 | 
			
		||||
 | 
			
		||||
	AnalyticsData struct {
 | 
			
		||||
		City                 string    `json:"city"`
 | 
			
		||||
		DeliveryDateBegin    string `json:"delivery_date_begin"`
 | 
			
		||||
		DeliveryDateEnd      string `json:"delivery_date_end"`
 | 
			
		||||
		DeliveryDateBegin    time.Time `json:"delivery_date_begin"`
 | 
			
		||||
		DeliveryDateEnd      time.Time `json:"delivery_date_end"`
 | 
			
		||||
		DeliveryType         string    `json:"delivery_type"`
 | 
			
		||||
		IsLegal              bool      `json:"is_legal"`
 | 
			
		||||
		IsPremium            bool      `json:"is_premium"`
 | 
			
		||||
@@ -85,7 +86,7 @@ type ListUnprocessedShipmentsPosting struct {
 | 
			
		||||
			Comment         string  `json:"comment"`
 | 
			
		||||
			Country         string  `json:"country"`
 | 
			
		||||
			District        string  `json:"district"`
 | 
			
		||||
			Latitude        float64 `json:'latitude"`
 | 
			
		||||
			Latitude        float64 `json:"latitude"`
 | 
			
		||||
			Longitude       float64 `json:"longitude"`
 | 
			
		||||
			ProviderPVZCode string  `json:"provider_pvz_code"`
 | 
			
		||||
			PVZCode         int64   `json:"pvz_code"`
 | 
			
		||||
@@ -99,7 +100,8 @@ type ListUnprocessedShipmentsPosting struct {
 | 
			
		||||
		Phone         string `json:"phone"`
 | 
			
		||||
	} `json:"customer"`
 | 
			
		||||
 | 
			
		||||
	DeliveringDate string `json:"delivering_date"`
 | 
			
		||||
	DeliveringDate time.Time `json:"delivering_date"`
 | 
			
		||||
 | 
			
		||||
	DeliveryMethod struct {
 | 
			
		||||
		Id            int64  `json:"id"`
 | 
			
		||||
		Name          string `json:"name"`
 | 
			
		||||
@@ -126,7 +128,7 @@ type ListUnprocessedShipmentsPosting struct {
 | 
			
		||||
			Payout                  float64             `json:"payout"`
 | 
			
		||||
			Picking                 struct {
 | 
			
		||||
				Amount float64   `json:"amount"`
 | 
			
		||||
				Moment string  `json:"moment"`
 | 
			
		||||
				Moment time.Time `json:"moment"`
 | 
			
		||||
				Tag    string    `json:"tag"`
 | 
			
		||||
			} `json:"picking"`
 | 
			
		||||
			Price                float64 `json:"price"`
 | 
			
		||||
@@ -137,7 +139,7 @@ type ListUnprocessedShipmentsPosting struct {
 | 
			
		||||
		} `json:"products"`
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	InProccessAt        string `json:"in_process_at"`
 | 
			
		||||
	InProccessAt        time.Time `json:"in_process_at"`
 | 
			
		||||
	IsExpress           bool      `json:"is_express"`
 | 
			
		||||
	IsMultibox          bool      `json:"is_multibox"`
 | 
			
		||||
	MultiBoxQuantity    int32     `json:"multi_box_qty"`
 | 
			
		||||
@@ -146,7 +148,7 @@ type ListUnprocessedShipmentsPosting struct {
 | 
			
		||||
	ParentPostingNumber string    `json:"parent_posting_number"`
 | 
			
		||||
	PostingNumber       string    `json:"posting_number"`
 | 
			
		||||
 | 
			
		||||
	Products struct {
 | 
			
		||||
	Products []struct {
 | 
			
		||||
		MandatoryMark []string `json:"mandatory_mark"`
 | 
			
		||||
		Name          string   `json:"name"`
 | 
			
		||||
		OfferId       string   `json:"offer_id"`
 | 
			
		||||
@@ -163,7 +165,7 @@ type ListUnprocessedShipmentsPosting struct {
 | 
			
		||||
		ProductsRequiringRNPT          []string `json:"products_requiring_rnpt"`
 | 
			
		||||
	} `json:"requirements"`
 | 
			
		||||
 | 
			
		||||
	ShipmentDate       string `json:"shipment_date"`
 | 
			
		||||
	ShipmentDate       time.Time `json:"shipment_date"`
 | 
			
		||||
	Status             string    `json:"status"`
 | 
			
		||||
	TPLIntegrationType string    `json:"tpl_integration_type"`
 | 
			
		||||
	TrackingNumber     string    `json:"tracking_number"`
 | 
			
		||||
 
 | 
			
		||||
@@ -19,8 +19,8 @@ func TestListUnprocessedShipments(t *testing.T) {
 | 
			
		||||
			&ListUnprocessedShipmentsParams{
 | 
			
		||||
				Direction: "ASC",
 | 
			
		||||
				Filter: ListUnprocessedShipmentsFilter{
 | 
			
		||||
					CutoffFrom: "2021-08-24T14:15:22Z",
 | 
			
		||||
					CutoffTo:   "2021-08-31T14:15:22Z",
 | 
			
		||||
					CutoffFrom: core.TimeFromString(t, "2021-08-24T14:15:22Z"),
 | 
			
		||||
					CutoffTo:   core.TimeFromString(t, "2021-08-31T14:15:22Z"),
 | 
			
		||||
					Status:     "awaiting_packaging",
 | 
			
		||||
				},
 | 
			
		||||
				Limit: 100,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										115
									
								
								ozon/products.go
									
									
									
									
									
								
							
							
						
						
									
										115
									
								
								ozon/products.go
									
									
									
									
									
								
							@@ -2,6 +2,7 @@ package ozon
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	core "github.com/diphantxm/ozon-api-client"
 | 
			
		||||
)
 | 
			
		||||
@@ -34,10 +35,7 @@ type GetStocksInfoResponse struct {
 | 
			
		||||
	core.CommonResponse
 | 
			
		||||
 | 
			
		||||
	// Method Result
 | 
			
		||||
	Result GetStocksInfoResponseResult `json:"result,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetStocksInfoResponseResult struct {
 | 
			
		||||
	Result struct {
 | 
			
		||||
		// Identifier of the last value on the page
 | 
			
		||||
		//
 | 
			
		||||
		// To get the next values, specify the recieved value in the next request in the last_id parameter
 | 
			
		||||
@@ -47,10 +45,7 @@ type GetStocksInfoResponseResult struct {
 | 
			
		||||
		Total int32 `json:"total,omitempty"`
 | 
			
		||||
 | 
			
		||||
		// Product details
 | 
			
		||||
	Items []GetStocksInfoResponseItem `json:"items,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetStocksInfoResponseItem struct {
 | 
			
		||||
		Items []struct {
 | 
			
		||||
			// Product identifier in the seller's system
 | 
			
		||||
			OfferId string `json:"offer_id,omitempty"`
 | 
			
		||||
 | 
			
		||||
@@ -58,10 +53,7 @@ type GetStocksInfoResponseItem struct {
 | 
			
		||||
			ProductId int64 `json:"product_id,omitempty"`
 | 
			
		||||
 | 
			
		||||
			// Stock details
 | 
			
		||||
	Stocks []GetStocksInfoResponseStock `json:"stocks,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetStocksInfoResponseStock struct {
 | 
			
		||||
			Stocks []struct {
 | 
			
		||||
				// In a warehouse
 | 
			
		||||
				Present int32 `json:"present,omitempty"`
 | 
			
		||||
 | 
			
		||||
@@ -70,6 +62,9 @@ type GetStocksInfoResponseStock struct {
 | 
			
		||||
 | 
			
		||||
				// Warehouse type
 | 
			
		||||
				Type string `json:"type,omitempty" default:"ALL"`
 | 
			
		||||
			} `json:"stocks,omitempty"`
 | 
			
		||||
		} `json:"items,omitempty"`
 | 
			
		||||
	} `json:"result,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c Client) GetStocksInfo(params *GetStocksInfoParams) (*GetStocksInfoResponse, error) {
 | 
			
		||||
@@ -95,17 +90,21 @@ type GetProductDetailsParams struct {
 | 
			
		||||
type GetProductDetailsResponse struct {
 | 
			
		||||
	core.CommonResponse
 | 
			
		||||
 | 
			
		||||
	Result GetProductDetailsResponseResult `json:"Result"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetProductDetailsResponseResult struct {
 | 
			
		||||
	Result struct {
 | 
			
		||||
		Barcode     string   `json:"barcode"`
 | 
			
		||||
		Barcodes    []string `json:"barcodes"`
 | 
			
		||||
		BuyboxPrice string   `json:"buybox_price"`
 | 
			
		||||
		CategoryId  int64    `json:"category_id"`
 | 
			
		||||
		ColorImage  string   `json:"color_image"`
 | 
			
		||||
	Commissions         []GetProductDetailsResponseCommission     `json:"commissions"`
 | 
			
		||||
	CreatedAt           string                                    `json:"created_at"`
 | 
			
		||||
		Commissions []struct {
 | 
			
		||||
			DeliveryAmount float64 `json:"deliveryAmount"`
 | 
			
		||||
			MinValue       float64 `json:"minValue"`
 | 
			
		||||
			Percent        float64 `json:"percent"`
 | 
			
		||||
			ReturnAmount   float64 `json:"returnAmount"`
 | 
			
		||||
			SaleSchema     string  `json:"saleSchema"`
 | 
			
		||||
			Value          float64 `json:"value"`
 | 
			
		||||
		} `json:"commissions"`
 | 
			
		||||
		CreatedAt         time.Time `json:"created_at"`
 | 
			
		||||
		FBOSKU            int64     `json:"fbo_sku"`
 | 
			
		||||
		FBSSKU            int64     `json:"fbs_sku"`
 | 
			
		||||
		Id                int64     `json:"id"`
 | 
			
		||||
@@ -114,7 +113,11 @@ type GetProductDetailsResponseResult struct {
 | 
			
		||||
		Images360         []string  `json:"images360"`
 | 
			
		||||
		HasDiscountedItem bool      `json:"has_discounted_item"`
 | 
			
		||||
		IsDiscounted      bool      `json:"is_discounted"`
 | 
			
		||||
	DiscountedStocks    GetProductDetailsResponseDiscountedStocks `json:"discounted_stocks"`
 | 
			
		||||
		DiscountedStocks  struct {
 | 
			
		||||
			Coming   int32 `json:"coming"`
 | 
			
		||||
			Present  int32 `json:"present"`
 | 
			
		||||
			Reserved int32 `json:"reserved"`
 | 
			
		||||
		} `json:"discounted_stocks"`
 | 
			
		||||
		IsKGT               bool   `json:"is_kgt"`
 | 
			
		||||
		IsPrepayment        bool   `json:"is_prepayment"`
 | 
			
		||||
		IsPrepaymentAllowed bool   `json:"is_prepayment_allowed"`
 | 
			
		||||
@@ -129,32 +132,7 @@ type GetProductDetailsResponseResult struct {
 | 
			
		||||
		Price               string `json:"price"`
 | 
			
		||||
		PriceIndex          string `json:"price_idnex"`
 | 
			
		||||
		RecommendedPrice    string `json:"recommended_price"`
 | 
			
		||||
	Status              GetProductDetailsResponseStatus           `json:"status"`
 | 
			
		||||
	Sources             []GetProductDetailsResponseSource         `json:"sources"`
 | 
			
		||||
	Stocks              GetProductDetailsResponseStocks           `json:"stocks"`
 | 
			
		||||
	UpdatedAt           string                                    `json:"updated_at"`
 | 
			
		||||
	VAT                 string                                    `json:"vat"`
 | 
			
		||||
	VisibilityDetails   GetProductDetailsResponseDetails          `json:"visibility_details"`
 | 
			
		||||
	Visible             bool                                      `json:"visible"`
 | 
			
		||||
	VolumeWeight        float64                                   `json:"volume_weights"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetProductDetailsResponseCommission struct {
 | 
			
		||||
	DeliveryAmount float64 `json:"deliveryAmount"`
 | 
			
		||||
	MinValue       float64 `json:"minValue"`
 | 
			
		||||
	Percent        float64 `json:"percent"`
 | 
			
		||||
	ReturnAmount   float64 `json:"returnAmount"`
 | 
			
		||||
	SaleSchema     string  `json:"saleSchema"`
 | 
			
		||||
	Value          float64 `json:"value"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetProductDetailsResponseDiscountedStocks struct {
 | 
			
		||||
	Coming   int32 `json:"coming"`
 | 
			
		||||
	Present  int32 `json:"present"`
 | 
			
		||||
	Reserved int32 `json:"reserved"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetProductDetailsResponseStatus struct {
 | 
			
		||||
		Status              struct {
 | 
			
		||||
			State            string                               `json:"state"`
 | 
			
		||||
			StateFailed      string                               `json:"state_failed"`
 | 
			
		||||
			ModerateStatus   string                               `json:"moderate_status"`
 | 
			
		||||
@@ -166,7 +144,28 @@ type GetProductDetailsResponseStatus struct {
 | 
			
		||||
			IsCreated        bool                                 `json:"is_created"`
 | 
			
		||||
			StateTooltip     string                               `json:"state_tooltip"`
 | 
			
		||||
			ItemErrors       []GetProductDetailsResponseItemError `json:"item_errors"`
 | 
			
		||||
	StateUpdatedAt   string                               `json:"state_updated_at"`
 | 
			
		||||
			StateUpdatedAt   time.Time                            `json:"state_updated_at"`
 | 
			
		||||
		} `json:"status"`
 | 
			
		||||
		Sources []struct {
 | 
			
		||||
			IsEnabled bool   `json:"is_enabled"`
 | 
			
		||||
			SKU       int64  `json:"sku"`
 | 
			
		||||
			Source    string `json:"source"`
 | 
			
		||||
		} `json:"sources"`
 | 
			
		||||
		Stocks struct {
 | 
			
		||||
			Coming   int32 `json:"coming"`
 | 
			
		||||
			Present  int32 `json:"present"`
 | 
			
		||||
			Reserved int32 `json:"reserved"`
 | 
			
		||||
		} `json:"stocks"`
 | 
			
		||||
		UpdatedAt         time.Time `json:"updated_at"`
 | 
			
		||||
		VAT               string    `json:"vat"`
 | 
			
		||||
		VisibilityDetails struct {
 | 
			
		||||
			ActiveProduct bool `json:"active_product"`
 | 
			
		||||
			HasPrice      bool `json:"has_price"`
 | 
			
		||||
			HasStock      bool `json:"has_stock"`
 | 
			
		||||
		} `json:"visibility_details"`
 | 
			
		||||
		Visible      bool    `json:"visible"`
 | 
			
		||||
		VolumeWeight float64 `json:"volume_weights"`
 | 
			
		||||
	} `json:"Result"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetProductDetailsResponseItemError struct {
 | 
			
		||||
@@ -177,29 +176,9 @@ type GetProductDetailsResponseItemError struct {
 | 
			
		||||
	Field                       string `json:"field"`
 | 
			
		||||
	AttributeId                 int64  `json:"attribute_id"`
 | 
			
		||||
	AttributeName               string `json:"attribute_name"`
 | 
			
		||||
	OptionalDescriptionElements GetProductDetailsResponseOptionalDescriptionElements `json:"optional_description_elements"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetProductDetailsResponseOptionalDescriptionElements struct {
 | 
			
		||||
	OptionalDescriptionElements struct {
 | 
			
		||||
		PropertyName string `json:"property_name"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetProductDetailsResponseSource struct {
 | 
			
		||||
	IsEnabled bool   `json:"is_enabled"`
 | 
			
		||||
	SKU       int64  `json:"sku"`
 | 
			
		||||
	Source    string `json:"source"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetProductDetailsResponseStocks struct {
 | 
			
		||||
	Coming   int32 `json:"coming"`
 | 
			
		||||
	Present  int32 `json:"present"`
 | 
			
		||||
	Reserved int32 `json:"reserved"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetProductDetailsResponseDetails struct {
 | 
			
		||||
	ActiveProduct bool `json:"active_product"`
 | 
			
		||||
	HasPrice      bool `json:"has_price"`
 | 
			
		||||
	HasStock      bool `json:"has_stock"`
 | 
			
		||||
	} `json:"optional_description_elements"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c Client) GetProductDetails(params *GetProductDetailsParams) (*GetProductDetailsResponse, error) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user