@congminh1254/shopee-sdk
Version:
Shopee SDK maintaining by community
337 lines • 13.8 kB
JavaScript
import { BaseManager } from "./base.manager.js";
import { ShopeeFetch } from "../fetch.js";
export class ReturnsManager extends BaseManager {
constructor(config) {
super(config);
}
/**
* Use this API to get detail information of many returns by shop ID.
*
* @param params - Parameters for getting return list
* @param params.page_no - Page number (required)
* @param params.page_size - Page size, max 100 (required)
* @param params.create_time_from - Filter by create time from (timestamp)
* @param params.create_time_to - Filter by create time to (timestamp)
* @param params.update_time_from - Filter by update time from (timestamp)
* @param params.update_time_to - Filter by update time to (timestamp)
* @param params.status - Filter by return status
* @param params.negotiation_status - Filter by negotiation status
* @param params.seller_proof_status - Filter by seller proof status
* @param params.seller_compensation_status - Filter by seller compensation status
*
* @returns A promise that resolves to the return list response containing:
* - more: Whether there are more pages
* - return: List of return details
*
* @throws {Error} When the API request fails or returns an error
*/
async getReturnList(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/get_return_list", {
method: "GET",
auth: true,
params,
});
return response;
}
/**
* Use this API to get detail information of a return by return serial number.
*
* @param params - Parameters for getting return detail
* @param params.return_sn - Return serial number (required)
*
* @returns A promise that resolves to the return detail response containing:
* - Complete return information including items, user, status, etc.
*
* @throws {Error} When the API request fails or returns an error
*/
async getReturnDetail(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/get_return_detail", {
method: "GET",
auth: true,
params,
});
return response;
}
/**
* Confirm refund for a return request.
*
* @param params - Parameters for confirming return
* @param params.return_sn - Return serial number (required)
*
* @returns A promise that resolves to the confirm response containing:
* - return_sn: The confirmed return serial number
*
* @throws {Error} When the API request fails or returns an error
*/
async confirm(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/confirm", {
method: "POST",
auth: true,
body: params,
});
return response;
}
/**
* Dispute a return request. Support raising dispute when return_status is REQUESTED/PROCESSING/ACCEPTED.
*
* @param params - Parameters for disputing return
* @param params.return_sn - Return serial number (required)
* @param params.email - Email for contact (required)
* @param params.dispute_reason - Dispute reason ID (required)
* @param params.dispute_text_reason - Text explanation for dispute
* @param params.images - Image URLs for dispute evidence
*
* @returns A promise that resolves to the dispute response containing:
* - return_sn: The disputed return serial number
*
* @throws {Error} When the API request fails or returns an error
*/
async dispute(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/dispute", {
method: "POST",
auth: true,
body: params,
});
return response;
}
/**
* Offer a solution to the buyer during negotiation.
*
* @param params - Parameters for offering solution
* @param params.return_sn - Return serial number (required)
* @param params.solution - Solution to offer (required)
* @param params.refund_amount - Refund amount (if applicable)
*
* @returns A promise that resolves to the offer response containing:
* - return_sn: The return serial number
*
* @throws {Error} When the API request fails or returns an error
*/
async offer(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/offer", {
method: "POST",
auth: true,
body: params,
});
return response;
}
/**
* Accept an offer from the buyer.
*
* @param params - Parameters for accepting offer
* @param params.return_sn - Return serial number (required)
*
* @returns A promise that resolves to the accept offer response containing:
* - return_sn: The return serial number
*
* @throws {Error} When the API request fails or returns an error
*/
async acceptOffer(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/accept_offer", {
method: "POST",
auth: true,
body: params,
});
return response;
}
/**
* Get the available solutions offered to buyers.
*
* @param params - Parameters for getting available solutions
* @param params.return_sn - Return serial number (required)
*
* @returns A promise that resolves to the available solutions response containing:
* - solution: List of available solution options with max refund amounts
*
* @throws {Error} When the API request fails or returns an error
*/
async getAvailableSolutions(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/get_available_solutions", {
method: "GET",
auth: true,
params,
});
return response;
}
/**
* Cancel a compensation dispute. Sellers can only cancel compensation disputes, not normal disputes.
* This means sellers can only cancel disputes when return_status is ACCEPTED and compensation_status is COMPENSATION_REQUESTED.
*
* @param params - Parameters for cancelling dispute
* @param params.return_sn - Return serial number (required)
*
* @returns A promise that resolves to the cancel dispute response containing:
* - return_sn: The return serial number
*
* @throws {Error} When the API request fails or returns an error
*/
async cancelDispute(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/cancel_dispute", {
method: "POST",
auth: true,
body: params,
});
return response;
}
/**
* Get the dispute return reasons available for a return.
*
* @param params - Parameters for getting dispute reasons
* @param params.return_sn - Return serial number (required)
*
* @returns A promise that resolves to the dispute reason response containing:
* - dispute_reason: List of available dispute reasons with IDs and text
*
* @throws {Error} When the API request fails or returns an error
*/
async getReturnDisputeReason(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/get_return_dispute_reason", {
method: "GET",
auth: true,
params,
});
return response;
}
/**
* Convert image files to URLs. Supports specific formats and pictures within 10MB.
*
* @param params - Parameters for converting images
* @param params.images - Array of images to convert (required)
*
* @returns A promise that resolves to the convert image response containing:
* - images: Array of converted image URLs
*
* @throws {Error} When the API request fails or returns an error
*/
async convertImage(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/convert_image", {
method: "POST",
auth: true,
body: params,
});
return response;
}
/**
* Upload evidence for a return, including text, pictures, and videos.
*
* @param params - Parameters for uploading proof
* @param params.return_sn - Return serial number (required)
* @param params.proof_text - Array of text evidence
* @param params.proof_image - Array of image URLs as evidence
* @param params.proof_video - Array of video URLs as evidence
*
* @returns A promise that resolves to the upload proof response containing:
* - return_sn: The return serial number
*
* @throws {Error} When the API request fails or returns an error
*/
async uploadProof(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/upload_proof", {
method: "POST",
auth: true,
body: params,
});
return response;
}
/**
* Query the evidence uploaded through the upload evidence API.
*
* @param params - Parameters for querying proof
* @param params.return_sn - Return serial number (required)
*
* @returns A promise that resolves to the query proof response containing:
* - proof_text: Uploaded text evidence
* - proof_image: Uploaded image evidence
* - proof_video: Uploaded video evidence
*
* @throws {Error} When the API request fails or returns an error
*/
async queryProof(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/query_proof", {
method: "GET",
auth: true,
params,
});
return response;
}
/**
* Get the list of shipping carriers and required parameters for uploading shipping proof.
* Only for TW and BR returns with is_seller_arrange = true.
*
* @param params - Parameters for getting shipping carriers
* @param params.return_sn - Return serial number (required)
*
* @returns A promise that resolves to the shipping carrier response containing:
* - carrier_list: List of available shipping carriers with required fields
*
* @throws {Error} When the API request fails or returns an error
*/
async getShippingCarrier(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/get_shipping_carrier", {
method: "GET",
auth: true,
params,
});
return response;
}
/**
* Upload shipping proof for seller-arranged returns.
* Only for TW and BR returns with is_seller_arrange = true. This is not to upload evidence for disputes.
*
* @param params - Parameters for uploading shipping proof
* @param params.return_sn - Return serial number (required)
* @param params.carrier_id - Carrier ID (required)
* @param params.tracking_number - Tracking number (required)
*
* @returns A promise that resolves to the upload shipping proof response containing:
* - return_sn: The return serial number
*
* @throws {Error} When the API request fails or returns an error
*/
async uploadShippingProof(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/upload_shipping_proof", {
method: "POST",
auth: true,
body: params,
});
return response;
}
/**
* Get reverse and post-return logistics information of return request.
*
* For Normal RR, returns complete reverse logistics information. For In-transit RR and Return-on-the-Spot,
* only returns latest reverse logistics status without providing complete reverse logistics information.
*
* For seller_validation, only one segment of reverse (buyer to seller), use tracking_info.
* For warehouse_validation, two segments of reverse (buyer to warehouse and warehouse to seller),
* use post_return_logistics_tracking_info for the second segment.
*
* @param params - Parameters for getting reverse tracking info
* @param params.return_sn - Shopee's unique identifier for a return/refund request (required)
*
* @returns A promise that resolves to the reverse tracking info response containing:
* - return_sn: Return serial number
* - return_refund_request_type: Type of return refund request (0=Normal RR, 1=In-transit RR, 2=Return-on-the-Spot)
* - validation_type: Whether seller or warehouse validates (seller_validation/warehouse_validation)
* - reverse_logistics_status: Latest reverse logistic status
* - reverse_logistics_update_time: Last update time of reverse logistics status
* - estimated_delivery_date_max/min: Estimated delivery dates (for Normal RR with integrated reverse logistics)
* - tracking_number: Tracking number for reverse logistics
* - tracking_info: Detailed tracking information list
* - post_return_logistics_status: Status for warehouse to seller logistics (warehouse_validation only)
* - post_return_logistics_update_time: Update time for post-return logistics
* - rts_tracking_number: Return to Seller tracking number
* - post_return_logistics_tracking_info: Tracking info for warehouse to seller logistics
*
* @throws {Error} When the API request fails or returns an error
*/
async getReverseTrackingInfo(params) {
const response = await ShopeeFetch.fetch(this.config, "/returns/get_reverse_tracking_info", {
method: "GET",
auth: true,
params,
});
return response;
}
}
//# sourceMappingURL=returns.manager.js.map