add all remained methods for fbs
This commit is contained in:
24
ENDPOINTS.md
24
ENDPOINTS.md
@@ -95,29 +95,29 @@
|
|||||||
- [x] Get shipment data by barcode
|
- [x] Get shipment data by barcode
|
||||||
- [x] List of manufacturing countries
|
- [x] List of manufacturing countries
|
||||||
- [x] Set the manufacturing country
|
- [x] Set the manufacturing country
|
||||||
- [ ] Specify number of boxes for multi-box shipments
|
- [x] Specify number of boxes for multi-box shipments
|
||||||
- [x] Get drop-off point restrictions
|
- [x] Get drop-off point restrictions
|
||||||
- [x] Partial pack the order
|
- [x] Partial pack the order
|
||||||
- [x] Create an acceptance and transfer certificate and a waybill
|
- [x] Create an acceptance and transfer certificate and a waybill
|
||||||
- [ ] Status of acceptance and transfer certificate and waybill
|
- [x] Status of acceptance and transfer certificate and waybill
|
||||||
- [x] Available freights list
|
- [x] Available freights list
|
||||||
- [x] Get acceptance and transfer certificate and waybill
|
- [x] Get acceptance and transfer certificate and waybill
|
||||||
- [ ] Generating status of digital acceptance and transfer certificate and waybill
|
- [x] Generating status of digital acceptance and transfer certificate and waybill
|
||||||
- [ ] Get digital shipment certificate
|
- [x] Get digital shipment certificate
|
||||||
- [x] Print the labeling
|
- [x] Print the labeling
|
||||||
- [x] Create a task to generate labeling
|
- [x] Create a task to generate labeling
|
||||||
- [x] Get a labeling file
|
- [x] Get a labeling file
|
||||||
- [ ] Package unit labels
|
- [x] Package unit labels
|
||||||
- [ ] Open a dispute over a shipment
|
- [x] Open a dispute over a shipment
|
||||||
- [x] Pass the shipment to shipping
|
- [x] Pass the shipment to shipping
|
||||||
- [ ] Shipment cancellation reasons
|
- [x] Shipment cancellation reasons
|
||||||
- [ ] Shipments cancellation reasons
|
- [x] Shipments cancellation reasons
|
||||||
- [x] Cancel the shipment
|
- [x] Cancel the shipment
|
||||||
- [ ] Add weight for bulk products in a shipment
|
- [x] Add weight for bulk products in a shipment
|
||||||
- [ ] Cancel sending some products in the shipment
|
- [x] Cancel sending some products in the shipment
|
||||||
- [x] List of shipment certificates
|
- [x] List of shipment certificates
|
||||||
- [x] Sign shipment certificates
|
- [x] Sign shipment certificates
|
||||||
- [ ] List of shipments in the certificate
|
- [x] List of shipments in the certificate
|
||||||
- [x] Change the status to "Delivering"
|
- [x] Change the status to "Delivering"
|
||||||
- [x] Add tracking numbers
|
- [x] Add tracking numbers
|
||||||
- [x] Change the status to "Last Mile"
|
- [x] Change the status to "Last Mile"
|
||||||
@@ -125,7 +125,7 @@
|
|||||||
- [x] Change status to "Sent by seller"
|
- [x] Change status to "Sent by seller"
|
||||||
- [x] Dates available for delivery reschedule
|
- [x] Dates available for delivery reschedule
|
||||||
- [x] Reschedule shipment delivery date
|
- [x] Reschedule shipment delivery date
|
||||||
- [ ] ETGB customs declarations
|
- [x] ETGB customs declarations
|
||||||
|
|
||||||
## Returns
|
## Returns
|
||||||
- [x] Get information about FBO returns (version 3)
|
- [x] Get information about FBO returns (version 3)
|
||||||
|
|||||||
522
ozon/fbs.go
522
ozon/fbs.go
@@ -1648,7 +1648,7 @@ type AvailableFreightsListResponse struct {
|
|||||||
core.CommonResponse
|
core.CommonResponse
|
||||||
|
|
||||||
// Method result
|
// Method result
|
||||||
Result []struct{
|
Result []struct {
|
||||||
// Freight identifier (document generation task number)
|
// Freight identifier (document generation task number)
|
||||||
CarriageId int64 `json:"carriage_id"`
|
CarriageId int64 `json:"carriage_id"`
|
||||||
|
|
||||||
@@ -1668,7 +1668,7 @@ type AvailableFreightsListResponse struct {
|
|||||||
DeliveryMethodName string `json:"delivery_method_name"`
|
DeliveryMethodName string `json:"delivery_method_name"`
|
||||||
|
|
||||||
// Errors list
|
// Errors list
|
||||||
Errors []struct{
|
Errors []struct {
|
||||||
// Error code
|
// Error code
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
|
|
||||||
@@ -1724,3 +1724,521 @@ func (c FBS) AvailableFreightsList(params *AvailableFreightsListParams) (*Availa
|
|||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GenerateActParams struct {
|
||||||
|
// Document generation task number (freight identifier) received from the POST `/v2/posting/fbs/act/create` method
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GenerateActResponse struct {
|
||||||
|
core.CommonResponse
|
||||||
|
|
||||||
|
// Document generation task number
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
|
||||||
|
// Documents generation status:
|
||||||
|
// - FORMING—in process,
|
||||||
|
// - FORMED—generated successfully,
|
||||||
|
// - CONFIRMED—signed by Ozon,
|
||||||
|
// - CONFIRMED_WITH_MISMATCH—signed by Ozon with mismatches,
|
||||||
|
// - NOT_FOUND—documents are not found,
|
||||||
|
// - UNKNOWN_ERROR—unknown error
|
||||||
|
Status string `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get current status of generating digital acceptance and transfer certificate and waybill
|
||||||
|
func (c FBS) GenerateAct(params *GenerateActParams) (*GenerateActResponse, error) {
|
||||||
|
url := "/v2/posting/fbs/digital/act/check-status"
|
||||||
|
|
||||||
|
resp := &GenerateActResponse{}
|
||||||
|
|
||||||
|
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.CopyCommonResponse(&resp.CommonResponse)
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetDigitalActParams struct {
|
||||||
|
// Document generation task number (freight identifier) received from the POST `/v2/posting/fbs/act/create` method
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
|
||||||
|
// Type of shipment certificate:
|
||||||
|
// - act_of_acceptance — acceptance certificate,
|
||||||
|
// - act_of_mismatch — discrepancy certificate,
|
||||||
|
// - act_of_excess — surplus certificate
|
||||||
|
DocType string `json:"doc_type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetDigitalActResponse struct {
|
||||||
|
core.CommonResponse
|
||||||
|
|
||||||
|
// File content in binary format
|
||||||
|
Content string `json:"content"`
|
||||||
|
|
||||||
|
// File name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// File type
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specify the type of a certificate in the doc_type parameter: `act_of_acceptance`, `act_of_mismatch`, `act_of_excess`
|
||||||
|
func (c FBS) GetDigitalAct(params *GetDigitalActParams) (*GetDigitalActResponse, error) {
|
||||||
|
url := "/v2/posting/fbs/digital/act/get-pdf"
|
||||||
|
|
||||||
|
resp := &GetDigitalActResponse{}
|
||||||
|
|
||||||
|
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.CopyCommonResponse(&resp.CommonResponse)
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type PackageUnitLabelsParams struct {
|
||||||
|
// Document generation task number (freight identifier) received from the POST `/v2/posting/fbs/act/create` method.
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PackageUnitLabelsResponse struct {
|
||||||
|
core.CommonResponse
|
||||||
|
|
||||||
|
// Content
|
||||||
|
Content string `json:"content"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Type
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method creates package unit labels
|
||||||
|
func (c FBS) PackageUnitLabel(params *PackageUnitLabelsParams) (*PackageUnitLabelsResponse, error) {
|
||||||
|
url := "/v2/posting/fbs/act/get-container-labels"
|
||||||
|
|
||||||
|
resp := &PackageUnitLabelsResponse{}
|
||||||
|
|
||||||
|
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.CopyCommonResponse(&resp.CommonResponse)
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type OpenDisputeOverShipmentParams struct {
|
||||||
|
// Shipment identifier
|
||||||
|
PostingNumber []string `json:"posting_number"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OpenDisputeOverShipmentResponse struct {
|
||||||
|
core.CommonResponse
|
||||||
|
|
||||||
|
// Request processing result. true, if the request was executed without errors
|
||||||
|
Result bool `json:"result"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the shipment has been handed over for delivery, but has not been scanned at the sorting center, you can open a dispute.
|
||||||
|
// Opened dispute will put the shipment into the `arbitration` status
|
||||||
|
func (c FBS) OpenDisputeOverShipment(params *OpenDisputeOverShipmentParams) (*OpenDisputeOverShipmentResponse, error) {
|
||||||
|
url := "/v2/posting/fbs/arbitration"
|
||||||
|
|
||||||
|
resp := &OpenDisputeOverShipmentResponse{}
|
||||||
|
|
||||||
|
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.CopyCommonResponse(&resp.CommonResponse)
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type ShipmentCancellationReasonsParams struct {
|
||||||
|
// Shipment numbers
|
||||||
|
RelatedPostingNumbers []string `json:"related_posting_numbers"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ShipmentCancellationReasonsResponse struct {
|
||||||
|
core.CommonResponse
|
||||||
|
|
||||||
|
// Request result
|
||||||
|
Result []struct {
|
||||||
|
// Shipment number
|
||||||
|
PostingNumber string `json:"posting_number"`
|
||||||
|
|
||||||
|
// Information about cancellation reasons
|
||||||
|
Reasons []struct {
|
||||||
|
// Cancellation reasons
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
|
||||||
|
// Reason description
|
||||||
|
Title string `json:"title"`
|
||||||
|
|
||||||
|
// Shipment cancellation initiator
|
||||||
|
TypeId string `json:"type_id"`
|
||||||
|
} `json:"reasons"`
|
||||||
|
} `json:"result"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a list of cancellation reasons for particular shipments
|
||||||
|
func (c FBS) ShipmentCancellationReasons(params *ShipmentCancellationReasonsParams) (*ShipmentCancellationReasonsResponse, error) {
|
||||||
|
url := "/v1/posting/fbs/cancel-reason"
|
||||||
|
|
||||||
|
resp := &ShipmentCancellationReasonsResponse{}
|
||||||
|
|
||||||
|
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.CopyCommonResponse(&resp.CommonResponse)
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type ShipmentsCancellationReasonsResponse struct {
|
||||||
|
core.CommonResponse
|
||||||
|
|
||||||
|
// Method result
|
||||||
|
Result []struct {
|
||||||
|
// Cancellation reason
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
|
||||||
|
// Shipment cancellation result. true if the request is available for cancellation
|
||||||
|
IsAvailableForCancellation bool `json:"is_available_for_cancellation"`
|
||||||
|
|
||||||
|
// Category name
|
||||||
|
Title string `json:"title"`
|
||||||
|
|
||||||
|
// Shipment cancellation initiator:
|
||||||
|
// - buyer
|
||||||
|
// - seller
|
||||||
|
TypeId string `json:"type_id"`
|
||||||
|
} `json:"result"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a list of cancellation reasons for particular shipments
|
||||||
|
func (c FBS) ShipmentsCancellationReasons() (*ShipmentsCancellationReasonsResponse, error) {
|
||||||
|
url := "/v2/posting/fbs/cancel-reason/list"
|
||||||
|
|
||||||
|
resp := &ShipmentsCancellationReasonsResponse{}
|
||||||
|
|
||||||
|
response, err := c.client.Request(http.MethodPost, url, nil, resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.CopyCommonResponse(&resp.CommonResponse)
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type AddWeightForBulkProductParams struct {
|
||||||
|
// Products information
|
||||||
|
Items AddWeightForBulkProductItem `json:"items"`
|
||||||
|
|
||||||
|
// Shipment identifier
|
||||||
|
PostingNumber string `json:"posting_number"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AddWeightForBulkProductItem struct {
|
||||||
|
// Product identifier in the Ozon system, SKU
|
||||||
|
SKU int64 `json:"sku"`
|
||||||
|
|
||||||
|
// List with weights of the products in the posting
|
||||||
|
WeightReal []float64 `json:"weightReal"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AddWeightForBulkProductResponse struct {
|
||||||
|
core.CommonResponse
|
||||||
|
|
||||||
|
// Shipment identifier
|
||||||
|
Result string `json:"result"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add weight for bulk products in a shipment
|
||||||
|
func (c FBS) AddWeightForBulkProduct(params *AddWeightForBulkProductParams) (*AddWeightForBulkProductResponse, error) {
|
||||||
|
url := "/v2/posting/fbs/product/change"
|
||||||
|
|
||||||
|
resp := &AddWeightForBulkProductResponse{}
|
||||||
|
|
||||||
|
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.CopyCommonResponse(&resp.CommonResponse)
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type CancelSendingParams struct {
|
||||||
|
// Product shipping cancellation reason identifier
|
||||||
|
CancelReasonId int64 `json:"cancel_reason_id"`
|
||||||
|
|
||||||
|
// Additional information on cancellation. Required parameter
|
||||||
|
CancelReasonMessage string `json:"cancel_reason_message"`
|
||||||
|
|
||||||
|
// Products information
|
||||||
|
Items []CancelSendingItem `json:"items"`
|
||||||
|
|
||||||
|
// Shipment identifier
|
||||||
|
PostingNumber string `json:"posting_number"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CancelSendingItem struct {
|
||||||
|
// Number of products in the shipment
|
||||||
|
Quantity int32 `json:"quantity"`
|
||||||
|
|
||||||
|
// Product identifier in the seller's system
|
||||||
|
SKU int64 `json:"sku"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CancelSendingResponse struct {
|
||||||
|
core.CommonResponse
|
||||||
|
|
||||||
|
// Shipment number
|
||||||
|
Result string `json:"result"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use this method if you cannot send some of the products from the shipment
|
||||||
|
func (c FBS) CancelSending(params *CancelSendingParams) (*CancelSendingResponse, error) {
|
||||||
|
url := "/v2/posting/fbs/product/cancel"
|
||||||
|
|
||||||
|
resp := &CancelSendingResponse{}
|
||||||
|
|
||||||
|
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.CopyCommonResponse(&resp.CommonResponse)
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListShipmentInCertificateParams struct {
|
||||||
|
// Certificate identifier
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListShipmentInCertificateResponse struct {
|
||||||
|
core.CommonResponse
|
||||||
|
|
||||||
|
// Information about shipments
|
||||||
|
Result []struct {
|
||||||
|
// Certificate identifier
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
|
||||||
|
// Number of boxes in which the product is packed
|
||||||
|
MultiBoxQuantity int32 `json:"multi_box_qty"`
|
||||||
|
|
||||||
|
// Shipment number
|
||||||
|
PostingNumber string `json:"posting_number"`
|
||||||
|
|
||||||
|
// Shipment status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Error code explanation
|
||||||
|
SellerError string `json:"seller_error"`
|
||||||
|
|
||||||
|
// Shipment record update date and time
|
||||||
|
UpdatedAt time.Time `json:"update_at"`
|
||||||
|
|
||||||
|
// Shipment record creation date and time
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
|
||||||
|
// List of products in the shipment
|
||||||
|
Products []struct {
|
||||||
|
// Product name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Product identifier in the seller's system
|
||||||
|
OfferId string `json:"offer_id"`
|
||||||
|
|
||||||
|
// Product price
|
||||||
|
Price string `json:"price"`
|
||||||
|
|
||||||
|
// Product number in the shipment
|
||||||
|
Quantity int32 `json:"quantity"`
|
||||||
|
|
||||||
|
// Product identifier in the Ozon system, SKU
|
||||||
|
SKU int64 `json:"sku"`
|
||||||
|
} `json:"products"`
|
||||||
|
} `json:"result"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a list of shipments in the certificate by certificate identifier
|
||||||
|
func (c FBS) ListShipmentInCertificate(params *ListShipmentInCertificateParams) (*ListShipmentInCertificateResponse, error) {
|
||||||
|
url := "/v2/posting/fbs/act/get-postings"
|
||||||
|
|
||||||
|
resp := &ListShipmentInCertificateResponse{}
|
||||||
|
|
||||||
|
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.CopyCommonResponse(&resp.CommonResponse)
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type SpecifyNumberOfBoxesParams struct {
|
||||||
|
// Multi-box shipment identifier
|
||||||
|
PostingNumber string `json:"posting_number"`
|
||||||
|
|
||||||
|
// Number of boxes in which the product is packed
|
||||||
|
MultiBoxQuantity int64 `json:"multi_box_qty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SpecifyNumberOfBoxesResponse struct {
|
||||||
|
core.CommonResponse
|
||||||
|
|
||||||
|
// Result of transferring the boxes number
|
||||||
|
Result struct {
|
||||||
|
// Possible values:
|
||||||
|
// - true — the number is successfully passed.
|
||||||
|
// - false — an error occurred while passing the number. Please try again
|
||||||
|
Result bool `json:"result"`
|
||||||
|
} `json:"result"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method for passing the number of boxes for multi-box shipments when working under the rFBS Aggregator scheme (using the Ozon partner delivery)
|
||||||
|
func (c FBS) SpecifyNumberOfBoxes(params *SpecifyNumberOfBoxesParams) (*SpecifyNumberOfBoxesResponse, error) {
|
||||||
|
url := "/v3/posting/multiboxqty/set"
|
||||||
|
|
||||||
|
resp := &SpecifyNumberOfBoxesResponse{}
|
||||||
|
|
||||||
|
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.CopyCommonResponse(&resp.CommonResponse)
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type StatusOfActParams struct {
|
||||||
|
// Document generation task number (freight identifier) received from the POST `/v2/posting/fbs/act/create` method
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type StatusOfActResponse struct {
|
||||||
|
core.CommonResponse
|
||||||
|
|
||||||
|
// Method result
|
||||||
|
Result struct {
|
||||||
|
// Acceptance and transfer certificate and a waybill type.
|
||||||
|
//
|
||||||
|
// If the value is ozon_digital,
|
||||||
|
// use the `/v2/posting/fbs/digital/act/check-status` and `/v2/posting/fbs/digital/act/get-pdf` methods for getting digital acceptance
|
||||||
|
// and transfer certificate and waybill
|
||||||
|
ActType string `json:"act_type"`
|
||||||
|
|
||||||
|
// List with numbers of shipments that are included in the acceptance and transfer certificate.
|
||||||
|
// You should hand these shipments over today
|
||||||
|
AddedToAct []string `json:"added_to_act"`
|
||||||
|
|
||||||
|
// List with numbers of shipments that are not included in the acceptance and transfer certificate.
|
||||||
|
// You should hand these shipments over in the next shipping
|
||||||
|
RemovedFromAct []string `json:"removed_from_act"`
|
||||||
|
|
||||||
|
// Request status:
|
||||||
|
//
|
||||||
|
// - in_process — documents generation in process, please wait.
|
||||||
|
// - ready — documents are ready for downloading.
|
||||||
|
// - error — error occured during document geneartion process. Send a request again.
|
||||||
|
// - cancelled — documents generation was canceled. Send a request again.
|
||||||
|
// - The next postings are not ready — error occured, shipmants are not included in the shipping. Wait and check request results again. If you see the error again, contact our support team
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Indication of a partial freight. true if the freigth is partial.
|
||||||
|
//
|
||||||
|
// Partial freigt means that the shipment was splitted into several parts and
|
||||||
|
// for each of them you need to generate separate acceptance and transfer certificates
|
||||||
|
IsPartial bool `json:"is_partial"`
|
||||||
|
|
||||||
|
// Indication that there are shipments subject to shipping that are not in the current freight. true if there are such shipments.
|
||||||
|
//
|
||||||
|
// If there are such shipments, create a new acceptance and transfer certificate
|
||||||
|
// using the `/v2/posting/fbs/act/create` method and check the creation status. Create acts until this field returns false
|
||||||
|
HasPostingsForNextCarriage bool `json:"has_postings_for_next_carriage"`
|
||||||
|
|
||||||
|
// Serial number of the partial freight
|
||||||
|
PartialSum int64 `json:"partial_sum"`
|
||||||
|
} `json:"result"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// If you are not connected to electronic document circulation (EDC),
|
||||||
|
// the method returns status of generating an acceptance and transfer certificate and a waybill.
|
||||||
|
//
|
||||||
|
// If you are connected to EDC, the method returns status of generating a waybill only
|
||||||
|
func (c FBS) StatusOfAct(params *StatusOfActParams) (*StatusOfActResponse, error) {
|
||||||
|
url := "/v2/posting/fbs/act/check-status"
|
||||||
|
|
||||||
|
resp := &StatusOfActResponse{}
|
||||||
|
|
||||||
|
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.CopyCommonResponse(&resp.CommonResponse)
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type ETGBCustomsDeclarationsParams struct {
|
||||||
|
// Filter by period of declaration creation
|
||||||
|
Date ETGBCustomsDeclarationsDate `json:"date"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ETGBCustomsDeclarationsDate struct {
|
||||||
|
// Start date
|
||||||
|
From time.Time `json:"from"`
|
||||||
|
|
||||||
|
// End date
|
||||||
|
To time.Time `json:"to"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ETGBCustomsDeclarationsResponse struct {
|
||||||
|
core.CommonResponse
|
||||||
|
|
||||||
|
// Request result
|
||||||
|
Result []struct {
|
||||||
|
// Shipment number
|
||||||
|
PostingNumber string `json:"posting_number"`
|
||||||
|
|
||||||
|
// Declaration information
|
||||||
|
ETGB struct {
|
||||||
|
// Number
|
||||||
|
Number string `json:"number"`
|
||||||
|
|
||||||
|
// Creation date
|
||||||
|
Date string `json:"date"`
|
||||||
|
|
||||||
|
// Link to file.
|
||||||
|
//
|
||||||
|
// If the field is empty and you need the file, contact Ozon support
|
||||||
|
URL string `json:"url"`
|
||||||
|
} `json:"etgb"`
|
||||||
|
} `json:"result"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method for getting Elektronik Ticaret Gümrük Beyannamesi (ETGB) customs declarations for sellers from Turkey
|
||||||
|
func (c FBS) ETGBCustomsDeclarations(params *ETGBCustomsDeclarationsParams) (*ETGBCustomsDeclarationsResponse, error) {
|
||||||
|
url := "/v1/posting/global/etgb"
|
||||||
|
|
||||||
|
resp := &ETGBCustomsDeclarationsResponse{}
|
||||||
|
|
||||||
|
response, err := c.client.Request(http.MethodPost, url, params, resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.CopyCommonResponse(&resp.CommonResponse)
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|||||||
704
ozon/fbs_test.go
704
ozon/fbs_test.go
@@ -1822,3 +1822,707 @@ func TestAvailableFreightsList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGenerateAct(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
statusCode int
|
||||||
|
headers map[string]string
|
||||||
|
params *GenerateActParams
|
||||||
|
response string
|
||||||
|
}{
|
||||||
|
// Test Ok
|
||||||
|
{
|
||||||
|
http.StatusOK,
|
||||||
|
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||||
|
&GenerateActParams{
|
||||||
|
Id: 123,
|
||||||
|
},
|
||||||
|
`{
|
||||||
|
"id": 421,
|
||||||
|
"status": "string"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
// Test No Client-Id or Api-Key
|
||||||
|
{
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
map[string]string{},
|
||||||
|
&GenerateActParams{},
|
||||||
|
`{
|
||||||
|
"code": 16,
|
||||||
|
"message": "Client-Id and Api-Key headers are required"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||||
|
|
||||||
|
resp, err := c.FBS().GenerateAct(test.params)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != test.statusCode {
|
||||||
|
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetDigitalAct(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
statusCode int
|
||||||
|
headers map[string]string
|
||||||
|
params *GetDigitalActParams
|
||||||
|
response string
|
||||||
|
}{
|
||||||
|
// Test Ok
|
||||||
|
{
|
||||||
|
http.StatusOK,
|
||||||
|
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||||
|
&GetDigitalActParams{
|
||||||
|
Id: 900000250859000,
|
||||||
|
DocType: "act_of_acceptance",
|
||||||
|
},
|
||||||
|
`{
|
||||||
|
"content": "string",
|
||||||
|
"name": "string",
|
||||||
|
"type": "string"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
// Test No Client-Id or Api-Key
|
||||||
|
{
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
map[string]string{},
|
||||||
|
&GetDigitalActParams{},
|
||||||
|
`{
|
||||||
|
"code": 16,
|
||||||
|
"message": "Client-Id and Api-Key headers are required"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||||
|
|
||||||
|
resp, err := c.FBS().GetDigitalAct(test.params)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != test.statusCode {
|
||||||
|
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode == http.StatusOK {
|
||||||
|
if resp.Content == "" {
|
||||||
|
t.Errorf("Content cannot be empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPackageUnitLabels(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
statusCode int
|
||||||
|
headers map[string]string
|
||||||
|
params *PackageUnitLabelsParams
|
||||||
|
response string
|
||||||
|
}{
|
||||||
|
// Test Ok
|
||||||
|
{
|
||||||
|
http.StatusOK,
|
||||||
|
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||||
|
&PackageUnitLabelsParams{
|
||||||
|
Id: 295662811,
|
||||||
|
},
|
||||||
|
`{
|
||||||
|
"content": "string",
|
||||||
|
"name": "string",
|
||||||
|
"type": "string"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
// Test No Client-Id or Api-Key
|
||||||
|
{
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
map[string]string{},
|
||||||
|
&PackageUnitLabelsParams{},
|
||||||
|
`{
|
||||||
|
"code": 16,
|
||||||
|
"message": "Client-Id and Api-Key headers are required"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||||
|
|
||||||
|
resp, err := c.FBS().PackageUnitLabel(test.params)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != test.statusCode {
|
||||||
|
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode == http.StatusOK {
|
||||||
|
if resp.Content == "" {
|
||||||
|
t.Errorf("Content cannot be empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenDisputeOverShipment(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
statusCode int
|
||||||
|
headers map[string]string
|
||||||
|
params *OpenDisputeOverShipmentParams
|
||||||
|
response string
|
||||||
|
}{
|
||||||
|
// Test Ok
|
||||||
|
{
|
||||||
|
http.StatusOK,
|
||||||
|
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||||
|
&OpenDisputeOverShipmentParams{
|
||||||
|
PostingNumber: []string{"33920143-1195-1"},
|
||||||
|
},
|
||||||
|
`{
|
||||||
|
"result": true
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
// Test No Client-Id or Api-Key
|
||||||
|
{
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
map[string]string{},
|
||||||
|
&OpenDisputeOverShipmentParams{},
|
||||||
|
`{
|
||||||
|
"code": 16,
|
||||||
|
"message": "Client-Id and Api-Key headers are required"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||||
|
|
||||||
|
resp, err := c.FBS().OpenDisputeOverShipment(test.params)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != test.statusCode {
|
||||||
|
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestShipmentCancellationReasons(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
statusCode int
|
||||||
|
headers map[string]string
|
||||||
|
params *ShipmentCancellationReasonsParams
|
||||||
|
response string
|
||||||
|
}{
|
||||||
|
// Test Ok
|
||||||
|
{
|
||||||
|
http.StatusOK,
|
||||||
|
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||||
|
&ShipmentCancellationReasonsParams{
|
||||||
|
RelatedPostingNumbers: []string{"73837363-0010-3"},
|
||||||
|
},
|
||||||
|
`{
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"posting_number": "73837363-0010-3",
|
||||||
|
"reasons": [
|
||||||
|
{
|
||||||
|
"id": 352,
|
||||||
|
"title": "The goods ran out at the seller's warehouse",
|
||||||
|
"type_id": "seller"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 400,
|
||||||
|
"title": "Only defective goods remained",
|
||||||
|
"type_id": "seller"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 402,
|
||||||
|
"title": "Other (seller's fault)",
|
||||||
|
"type_id": "seller"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
// Test No Client-Id or Api-Key
|
||||||
|
{
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
map[string]string{},
|
||||||
|
&ShipmentCancellationReasonsParams{},
|
||||||
|
`{
|
||||||
|
"code": 16,
|
||||||
|
"message": "Client-Id and Api-Key headers are required"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||||
|
|
||||||
|
resp, err := c.FBS().ShipmentCancellationReasons(test.params)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != test.statusCode {
|
||||||
|
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode == http.StatusOK {
|
||||||
|
if len(resp.Result) != len(test.params.RelatedPostingNumbers) {
|
||||||
|
t.Errorf("Length of postings numbers in request and response are not equal")
|
||||||
|
}
|
||||||
|
if len(resp.Result) > 0 {
|
||||||
|
if resp.Result[0].PostingNumber != test.params.RelatedPostingNumbers[0] {
|
||||||
|
t.Errorf("Posting number in request and response are not equal")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestShipmentsCancellationReasons(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
statusCode int
|
||||||
|
headers map[string]string
|
||||||
|
response string
|
||||||
|
}{
|
||||||
|
// Test Ok
|
||||||
|
{
|
||||||
|
http.StatusOK,
|
||||||
|
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||||
|
`{
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": 352,
|
||||||
|
"title": "The goods ran out at the seller's warehouse",
|
||||||
|
"type_id": "seller",
|
||||||
|
"is_available_for_cancellation": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 400,
|
||||||
|
"title": "Only defective goods remained",
|
||||||
|
"type_id": "seller",
|
||||||
|
"is_available_for_cancellation": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 401,
|
||||||
|
"title": "Seller rejects arbitration",
|
||||||
|
"type_id": "seller",
|
||||||
|
"is_available_for_cancellation": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 402,
|
||||||
|
"title": "Other (seller's fault)",
|
||||||
|
"type_id": "seller",
|
||||||
|
"is_available_for_cancellation": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 665,
|
||||||
|
"title": "The buyer did not pick up the order",
|
||||||
|
"type_id": "seller",
|
||||||
|
"is_available_for_cancellation": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 666,
|
||||||
|
"title": "Return from the delivery service: there is no delivery to the specified region",
|
||||||
|
"type_id": "seller",
|
||||||
|
"is_available_for_cancellation": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 667,
|
||||||
|
"title": "Order lost by delivery service",
|
||||||
|
"type_id": "seller",
|
||||||
|
"is_available_for_cancellation": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
// Test No Client-Id or Api-Key
|
||||||
|
{
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
map[string]string{},
|
||||||
|
`{
|
||||||
|
"code": 16,
|
||||||
|
"message": "Client-Id and Api-Key headers are required"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||||
|
|
||||||
|
resp, err := c.FBS().ShipmentsCancellationReasons()
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != test.statusCode {
|
||||||
|
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode == http.StatusOK {
|
||||||
|
if len(resp.Result) > 0 {
|
||||||
|
if resp.Result[0].Id == 0 {
|
||||||
|
t.Errorf("Id cannot be 0")
|
||||||
|
}
|
||||||
|
if resp.Result[0].TypeId == "" {
|
||||||
|
t.Errorf("Type id cannot be empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAddWeightForBulkProduct(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
statusCode int
|
||||||
|
headers map[string]string
|
||||||
|
params *AddWeightForBulkProductParams
|
||||||
|
response string
|
||||||
|
}{
|
||||||
|
// Test Ok
|
||||||
|
{
|
||||||
|
http.StatusOK,
|
||||||
|
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||||
|
&AddWeightForBulkProductParams{
|
||||||
|
Items: AddWeightForBulkProductItem{
|
||||||
|
SKU: 1231428352,
|
||||||
|
WeightReal: []float64{0.3},
|
||||||
|
},
|
||||||
|
PostingNumber: "33920158-0006-1",
|
||||||
|
},
|
||||||
|
`{
|
||||||
|
"result": "33920158-0006-1"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
// Test No Client-Id or Api-Key
|
||||||
|
{
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
map[string]string{},
|
||||||
|
&AddWeightForBulkProductParams{},
|
||||||
|
`{
|
||||||
|
"code": 16,
|
||||||
|
"message": "Client-Id and Api-Key headers are required"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||||
|
|
||||||
|
resp, err := c.FBS().AddWeightForBulkProduct(test.params)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != test.statusCode {
|
||||||
|
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode == http.StatusOK {
|
||||||
|
if resp.Result != test.params.PostingNumber {
|
||||||
|
t.Errorf("Posting numbers in request and response are not equal")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCancelSending(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
statusCode int
|
||||||
|
headers map[string]string
|
||||||
|
params *CancelSendingParams
|
||||||
|
response string
|
||||||
|
}{
|
||||||
|
// Test Ok
|
||||||
|
{
|
||||||
|
http.StatusOK,
|
||||||
|
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||||
|
&CancelSendingParams{
|
||||||
|
PostingNumber: "33920113-1231-1",
|
||||||
|
CancelReasonId: 352,
|
||||||
|
CancelReasonMessage: "Product is out of stock",
|
||||||
|
Items: []CancelSendingItem{
|
||||||
|
{
|
||||||
|
Quantity: 5,
|
||||||
|
SKU: 150587396,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
`{
|
||||||
|
"result": ""
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
// Test No Client-Id or Api-Key
|
||||||
|
{
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
map[string]string{},
|
||||||
|
&CancelSendingParams{},
|
||||||
|
`{
|
||||||
|
"code": 16,
|
||||||
|
"message": "Client-Id and Api-Key headers are required"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||||
|
|
||||||
|
resp, err := c.FBS().CancelSending(test.params)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != test.statusCode {
|
||||||
|
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestListShipmentInCertificate(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
statusCode int
|
||||||
|
headers map[string]string
|
||||||
|
params *ListShipmentInCertificateParams
|
||||||
|
response string
|
||||||
|
}{
|
||||||
|
// Test Ok
|
||||||
|
{
|
||||||
|
http.StatusOK,
|
||||||
|
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||||
|
&ListShipmentInCertificateParams{
|
||||||
|
Id: 900000250859000,
|
||||||
|
},
|
||||||
|
`{
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"multi_box_qty": 0,
|
||||||
|
"posting_number": "string",
|
||||||
|
"status": "string",
|
||||||
|
"seller_error": "string",
|
||||||
|
"updated_at": "2019-08-24T14:15:22Z",
|
||||||
|
"created_at": "2019-08-24T14:15:22Z",
|
||||||
|
"products": [
|
||||||
|
{
|
||||||
|
"name": "string",
|
||||||
|
"offer_id": "string",
|
||||||
|
"price": "string",
|
||||||
|
"quantity": 0,
|
||||||
|
"sku": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
// Test No Client-Id or Api-Key
|
||||||
|
{
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
map[string]string{},
|
||||||
|
&ListShipmentInCertificateParams{},
|
||||||
|
`{
|
||||||
|
"code": 16,
|
||||||
|
"message": "Client-Id and Api-Key headers are required"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||||
|
|
||||||
|
resp, err := c.FBS().ListShipmentInCertificate(test.params)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != test.statusCode {
|
||||||
|
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSpecifyNumberOfBoxes(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
statusCode int
|
||||||
|
headers map[string]string
|
||||||
|
params *SpecifyNumberOfBoxesParams
|
||||||
|
response string
|
||||||
|
}{
|
||||||
|
// Test Ok
|
||||||
|
{
|
||||||
|
http.StatusOK,
|
||||||
|
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||||
|
&SpecifyNumberOfBoxesParams{
|
||||||
|
PostingNumber: "string",
|
||||||
|
},
|
||||||
|
`{
|
||||||
|
"result": {
|
||||||
|
"result": true
|
||||||
|
}
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
// Test No Client-Id or Api-Key
|
||||||
|
{
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
map[string]string{},
|
||||||
|
&SpecifyNumberOfBoxesParams{},
|
||||||
|
`{
|
||||||
|
"code": 16,
|
||||||
|
"message": "Client-Id and Api-Key headers are required"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||||
|
|
||||||
|
resp, err := c.FBS().SpecifyNumberOfBoxes(test.params)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != test.statusCode {
|
||||||
|
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStatusOfAct(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
statusCode int
|
||||||
|
headers map[string]string
|
||||||
|
params *StatusOfActParams
|
||||||
|
response string
|
||||||
|
}{
|
||||||
|
// Test Ok
|
||||||
|
{
|
||||||
|
http.StatusOK,
|
||||||
|
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||||
|
&StatusOfActParams{
|
||||||
|
Id: 900000250859000,
|
||||||
|
},
|
||||||
|
`{
|
||||||
|
"result": {
|
||||||
|
"result": true
|
||||||
|
}
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
// Test No Client-Id or Api-Key
|
||||||
|
{
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
map[string]string{},
|
||||||
|
&StatusOfActParams{},
|
||||||
|
`{
|
||||||
|
"code": 16,
|
||||||
|
"message": "Client-Id and Api-Key headers are required"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||||
|
|
||||||
|
resp, err := c.FBS().StatusOfAct(test.params)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != test.statusCode {
|
||||||
|
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestETGBCustomsDeclarations(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
statusCode int
|
||||||
|
headers map[string]string
|
||||||
|
params *ETGBCustomsDeclarationsParams
|
||||||
|
response string
|
||||||
|
}{
|
||||||
|
// Test Ok
|
||||||
|
{
|
||||||
|
http.StatusOK,
|
||||||
|
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||||
|
&ETGBCustomsDeclarationsParams{
|
||||||
|
Date: ETGBCustomsDeclarationsDate{
|
||||||
|
From: core.TimeFromString(t, "2006-01-02T15:04:05Z", "2023-02-13T12:13:16.818Z"),
|
||||||
|
To: core.TimeFromString(t, "2006-01-02T15:04:05Z", "2023-02-13T12:13:16.818Z"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
`{
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"posting_number": "string",
|
||||||
|
"etgb": {
|
||||||
|
"number": "string",
|
||||||
|
"date": "string",
|
||||||
|
"url": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
// Test No Client-Id or Api-Key
|
||||||
|
{
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
map[string]string{},
|
||||||
|
&ETGBCustomsDeclarationsParams{},
|
||||||
|
`{
|
||||||
|
"code": 16,
|
||||||
|
"message": "Client-Id and Api-Key headers are required"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||||
|
|
||||||
|
resp, err := c.FBS().ETGBCustomsDeclarations(test.params)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != test.statusCode {
|
||||||
|
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user