Skip to main content

Add Turn Around Time

Description

The Turn Around Time (TAT) captures the estimated time required to deliver shipments to specific regions/pin codes. This data enables the platform to display indicative delivery dates during the storefront journey—across the Product Detail Page (PDP), Cart, and Checkout stages. Therefore, it is up to the extension’s owner to choose whether to update the data and the frequency of the data.

It is essential to provide TAT data once a new Scheme is created, as the data will be stored and mapped to the corresponding Scheme to ensure seamless order processing and delivery estimates.

Get Countries Hierarchy Data for Data Upload

Refer to Get Countries Hierarchy Data for Data Upload for the steps.

Sample File Download

This FDK method is used to download the TAT template file.

Request

In the previous step, the getCountries method retrieved hierarchical data for India to manage logistics at the pincode level. In the request, specifies India as the target country and pincode as the region.

basicRouter.get('/sample_tat_file', async function view(req, res, next) {
try {
const partnerClient = await fdkExtension.getPartnerClient('66a0f176a257365a44f33d4c');
const response = await partnerClient.logistics.sampleFileServiceability({
"organizationId": organizationId,
"body": {
"country": "INDIA",
"region": "city",
"type": "tat"
}
});
console.log(JSON.stringify(response))
res.json(response);
} catch (err) {
console.error(err);
console.log(JSON.stringify(err))
res.status(404).json({ success: false });
}
});

Response

In the response, a unique batch ID (batch_id) is generated to track the process, and the "region": "pincode" confirms the granularity at which serviceability is being assessed.

{
"status": "processing",
"batch_id": "677e577e8dbd10e115955690",
"file_path": null,
"region": "pincode",
"type": "tat",
"country": "INDIA",
"failed_records": []
}

TAT File Upload Process

Start Uploading TAT File

The startUpload initiates the assets upload. In returns, you will receive a storage link (CDN URL) to upload the TAT file to the file storage. Make a PUT request on storage link received from startUpload API with file as a request body.

FDK MEthod: startUpload

Request

In the below given example request, details such as the file name: sample_tat_file.csv, content type (text/csv), and size are specified. The file is tagged under tat for easy identification, is defined by the namespace and subpath parameters.

basicRouter.post('/start_upload_tat', async function view(req, res, next) {
try {
const partnerClient = await fdkExtension.getPartnerClient('6720b51d25f94c22e87376a5');
const response = await partnerClient.fileStorage.startUpload({
"namespace": "test",
"organizationId": organizationId,
"body": {
"file_name": "sample_tat_file.csv",
"content_type": "text/csv",
"size": 500,
"tags": [
"tat",
],
"params": {
"subpath": "test"
}
}
});
console.log(JSON.stringify(response))

const uploadUrl = response.upload.url;
// Replace with the path to your local file
const filePath = path.resolve(__dirname, '../sample_tat_file.csv');
// Replace with your file's MIME type
const mimeType = "text/csv";
console.log("---------------------------------------------")
console.log(uploadUrl, filePath)
console.log("---------------------------------------------")
await uploadFileToStorage(uploadUrl, filePath, mimeType);
console.log(JSON.stringify(response))
res.json(response_complte);
} catch (err) {
console.error(err);
console.log(JSON.stringify(err))
res.status(404).json({ success: false });
}
});

Response

The response returns essential information to store the file directly in cloud storage. This URL has an expiration period (expiry: 1800 seconds), ensuring the upload must be completed within the specified timeframe.

{
"file_name": "sample_tat_file.csv",
"operation": "putObject",
"size": 500,
"content_type": "text/csv",
"namespace": "test",
"file_path": "/test/general/free/original/sample_tat_file.csv",
"method": "PUT",
"tags": [
"tat"
],
"upload": {
"url": "https://storage.googleapis.com/fynd-obscuro-media-new/test/general/free/original/sample_tat_file.csv?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=grindor-prod%40fynd-prod-393805.iam.gserviceaccount.com%2F20250108%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250108T105745Z&X-Goog-Expires=1800&X-Goog-SignedHeaders=host&X-Goog-Signature=89a82e1db5d5d1399849e8ea1da7379f7be2a4e6462e10db0574c912b8046590db6c7f08b69b566d3c1397c6a34d7bad53f82e80aaeebcbfdc52fd940390dc36faa997fb71f1bf57fd5e1950a5ce8a242965e447737ba8d47492f3e821359390a269b057f5e81beb00d3f8998172c2aee9cae6d4bdc500a84af6c33b490b7f92afc9bbb6058f7696006c28c5b4e5f48f6c6aacf22bd0af31fc5250a114b93a1bd52ef7d118692d6d8ab286271071add7e359be3789162f66505e92329f8a18b2ba30383a7c024e9f70266e33aeb0b7b2882fe9df7fe4c733075f0029faba2b2ebccd9af418622ba04d120dae85115b3e24aa6654a4aec792cf03be767478fabe",
"expiry": 1800
}
}

Complete Uploading TAT File

The completeUpload FDK method finalizes the process of uploading the serviceability file to cloud storage, providing a CDN URL for accessing the uploaded file. This step ensures that the TAT file is correctly stored.

FDK Method: completeUpload

Request

In the below given example request, the parameters from the initial startUpload response (such as file name, path, and upload URL) are passed to completeUpload, confirming the file’s successful transfer to the storage location. This FDK method validates the upload and generates URLs for accessing the file via CDN.

basicRouter.post('/complete_upload_tat', async function view(req, res, next) {
try {
const partnerClient = await fdkExtension.getPartnerClient('6720b51d25f94c22e87376a5');
const response_complte = await partnerClient.fileStorage.completeUpload({
"namespace": "test",
"organizationId": organizationId,
"body": {
"file_name": response.file_name,
"file_path": response.file_path,
"content_type": response.content_type,
"method": response.method,
"namespace": response.namespace,
"operation": response.operation,
"size": response.size,
"upload": {
"expiry": response.upload.expiry,
"url": response.upload.url
},
"tags": response.tags
}
});
console.log(JSON.stringify(response_complte))
res.json(response_complte);
} catch (err) {
console.error(err);
console.log(JSON.stringify(err))
res.status(404).json({ success: false });
}
});

Response

The response confirms the success of the operation (success: true) and returns multiple URLs link to access the file through Fynd’s network.

Developers can use the CDN link to reference the file without re-uploading or handling additional storage configurations. The response also tracks metadata like upload time (created_on), file size, and the developer responsible for the upload.

{
"file_name": "sample_tat_file.csv",
"file_path": "/test/general/free/original/sample_tat_file.csv",
"success": true,
"namespace": "test",
"content_type": "text/csv",
"size": 500,
"operation": "putObject",
"tags": [
"tat"
],
"cdn": {
"url": "https://cdn.fynd.com/v2/falling-surf-7c8bb8/fyprod/wrkr/test/general/free/original/sample_tat_file.csv",
"absolute_url": "https://cdn.fynd.com/v2/falling-surf-7c8bb8/fyprod/wrkr/test/general/free/original/sample_tat_file.csv",
"relative_url": "/test/general/free/original/sample_tat_file.csv"
},
"upload": {
"url": "https://storage.googleapis.com/fynd-obscuro-media-new/test/general/free/original/sample_tat_file.csv?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=grindor-prod%40fynd-prod-393805.iam.gserviceaccount.com%2F20250107%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250107T071601Z&X-Goog-Expires=1800&X-Goog-SignedHeaders=host&X-Goog-Signature=a492b5f8401e6fe1b7f7e14c6f4dc82000b8ec32d49b4952bad7cf7771829fbccca99ab5093e7dba404ee5c5719e8f447ac6acef5c14197fcebcc65f44389a47473a7e7b624694cacb7577bb468a1f62355c2852d93afad6f7a2f0cf4997e4b9155d55c58f6dd2280597ec79d2ab9cdcf8a9fb668ebc4338ed30eba8bed922e472d443164e5e8477b5fbf76613df3117ed81350818190e9a2854dd79b42350f808245c6cc85a0a9357a5df0635b1c48fe4a9d83adda64bb30627b89efd686500b05d582be64081c18f00678a996aa89dcd99f68a66d2dfd1eaa5ef1e28a93bf1b65690fba7d497842003b86e63049d9169f773344781bb4c6a62fc982ae3a142",
"expiry": 1800
},
"_id": "677cd4b1f23cf2837ff50a4b",
"created_by": {
"username": "6777d5612f3ce766efa51482"
},
"created_on": "2025-01-07T07:16:01.795Z",
"modified_on": "2025-01-07T07:16:01.795Z"
}

TAT Export

The bulkTat FDK method uploads the TAT file from cloud storage to the database.

FDK Method: bulkTat

Request

In the below given example request, the uploaded serviceability file identified by its CDN URL (collected from completeUpload FDK method in the previous step) is passed along with metadata such as the country (India), action (import), and region (Pincode). This initiates the process of transferring the file’s contents into the database under a specified scheme (schemeId).

basicRouter.post('/upload_scheme_tat', async function view(req, res, next) {
try {
const partnerClient = await fdkExtension.getPartnerClient('66a0f176a257365a44f33d4c');
const response = await partnerClient.logistics.bulkTat({
"organizationId": organizationId,
"extensionId": process.env.EXTENSION_API_KEY,
"schemeId": "Scheme_id_126",
"body": {
"file_path": "https://cdn.fynd.com/v2/falling-surf-7c8bb8/fyprod/wrkr/test/general/free/original/sample_tat_file.csv",
"country": "India",
"action": "import",
"region": "Pincode"
}
});
console.log(JSON.stringify(response))
res.json(response);
} catch (err) {
console.error(err);
console.log(JSON.stringify(err))
res.status(404).json({ success: false });
}
});

Response

A unique batch_id is generated to track the import. The response also shows metrics, such as total: 0, success: 0, failed: 0. If any errors occur during import, they will appear under failed_records.

{
"success": 0,
"status": "processing",
"total": 0,
"action": "import",
"failed": 0,
"file_path": "https://cdn.fynd.com/v2/falling-surf-7c8bb8/fyprod/wrkr/test/general/free/original/sample_tat_file.csv",
"batch_id": "677e5e79e54af83725bc73b0",
"region": "Pincode",
"country": "India",
"failed_records": []
}

TAT File Generator Status

The getSampleFileServiceabilityStatus FDK method is used to check the status of a previously initiated TAT file generation process. You will get a log file that contains list of rows which are not uploaded in the database. You can download the log file and correct the serviceability file and reupload again.

Request

In the below given example request, the batchId is passed, which uniquely identifies the file generation process initiated earlier.

basicRouter.get('/sample_tat_file_status', async function view(req, res, next) {
try {
const partnerClient = await fdkExtension.getPartnerClient('6720b51d25f94c22e87376a5');
const response = await partnerClient.logistics.getSampleFileServiceabilityStatus({
"organizationId": organizationId,
"batchId": "6761363a0456c5b5dcaa3b4a"
});
console.log(JSON.stringify(response))
res.json(response);
} catch (err) {
console.error(err);
console.log(JSON.stringify(err))
res.status(404).json({ success: false });
}
});

Response

The response shows that no errors have occurred failed_records: [], and the batch is associated with generating a serviceability sample for India at the pincode level.

{
"status": "processing",
"file_path": null,
"batch_id": "677e657440482cb2d096a014",
"country": "INDIA",
"failed_records": [],
"region": "pincode",
"type": "tat"
}

Get TAT History

This FDK method is used to get the history of uploaded serviceability. The getBulkTat FDK method is used to retrieve the history and status of previously uploaded TAT files. This functionality allows developers to track past imports.

FDK Method: getBulkTat

Request

In the below given example request, the method queries TAT uploads for India at the pincode level within a defined date range (startDate to endDate). Additionally, the method targets a specific scheme (schemeId) and batch (batchId).

basicRouter.get('/scheme_tat_history', async function view(req, res, next) {
try {
const partnerClient = await fdkExtension.getPartnerClient('6720b51d25f94c22e87376a5');
const response = await partnerClient.logistics.getBulkTat({
"organizationId": organizationId,
"extensionId": process.env.EXTENSION_API_KEY,
"schemeId": "Scheme_id_3",
"batchId": "674eda8262b934d3a7c31f22",
"action": "import",
"status": "processing",
"country": "India",
"region": "Pincode",
"startDate": "2024-12-01T18:30:00Z",
"endDate": "2024-12-04T18:30:00Z"
});
console.log(JSON.stringify(response))
res.json(response);
} catch (err) {
console.error(err);
console.log(JSON.stringify(err))
res.status(404).json({ success: false });
}
});

Response

The response indicates that no matching records were found (items: []), suggesting that no uploads met the provided criteria during the specified period.

{
"page": {
"current": 1,
"has_next": false,
"size": 0,
"item_total": 0,
"type": "number"
},
"items": []
}

Was this section helpful?