Essentially there would be a class looking something like:
class GoogleSheetIngester {
constructor(strategy) {
this._strategy = strategy;
}
ingest(sheet_link_or_something) {
// Logic here around getting the sheet data and serialising it into a standard format like JSON
return this._strategy.ingest(sheet_data)
}
}
class DeliverySheet:
ingest(sheet_data) {
// Handle the specific logic for the delivery sheet, keeping the knowledge of what to expect from that sheet inside this class.
}
}
result = GoogleSheetIngester(DeliverySheet).ingest(sheet_link_or_something)
The way I usually handle this kind of problem is by applying the Strategy pattern; https://refactoring.guru/design-patterns/strategy
Essentially there would be a class looking something like: