Skip to content

Instantly share code, notes, and snippets.

@godfern
Created March 13, 2020 03:14
Show Gist options
  • Save godfern/c7aebc4da098919cc89f7964b108d656 to your computer and use it in GitHub Desktop.
Save godfern/c7aebc4da098919cc89f7964b108d656 to your computer and use it in GitHub Desktop.
var fbfLiteSchema = require('../schema/fbf-lite-schema.js');
var fbfLiteError = require("../errors/fbf-lite-error.js");
module.exports = {
base:{
input: {
constructPayload: (payload, listing_id) => {
return payload.map(item => {
return {
bin_id: item.binId,
quantity: item.quantity,
listing_id: listing_id
};
})
}
}
},
nodes: [
{
name: "serviceabilityCheckFlow",
type: "flow",
config: require("../../orders/flows/check-serviceability.js"),
skipIf: "#{updateLBHW, $not}",
input: {
payload: {
products: [
{
id:"#{fsn}",
length:"#{length}",
breadth:"#{breadth}",
height:"#{height}",
weight:"#{weight}"
}
]
},
postal_codes: "#{pincode}"
},
onError: fbfLiteError.serviceabilityCheckFlow,
configContext: {
identifier: "FA_SERVICEABILITY_CHECK"
}
},
{
name: "updateListingsFlow",
type: "flow",
config: require("../../common/flows/update-listings.js"),
skipIf: "#{updateLBHW, $not}",
input: {
serviceability: "#{serviceabilityCheckFlow.serviceabilityCheck.response.serviceability}",
payload: {
sellerId: "#{sellerId}",
bulkListingRequest: {
listings: [
{
listingId: "#{listing_id}",
attributeValues: {
package_length: "#{length}",
package_breadth: "#{breadth}",
package_height: "#{height}",
package_weight: "#{weight}"
}
}
]
}
},
headers: {
'FK-CLIENT-ID': 'sp.sd'
}
},
schema: fbfLiteSchema.updateListingsFlow,
onError: fbfLiteError.updateListingsFlow,
configContext: {
identifier: "LISTING_UPDATE_LISTINGS_LBHW",
terminateOnError: true
},
dependencies: ['serviceabilityCheckFlow']
},
{
name: 'inwardProductsFlow',
type: 'flow',
config: require('../../common/flows/fbf-lite-fa.js'),
input: {
payload: {
requests: "#{inventory, listing_id, constructPayload}"
}
},
configContext: {
apiName: "inwardProducts"
},
dependencies: ['updateListingsFlow']
},
{
name: 'sendResponse',
type: 'send-response',
config: {
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
},
input: {
response: {
success: true
}
},
dependencies: ['inwardProductsFlow']
}
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment