Skip to content

Instantly share code, notes, and snippets.

@martijnvdbrug
Created December 17, 2019 13:09
Show Gist options
  • Save martijnvdbrug/f7479158a399c67639c0f56367508145 to your computer and use it in GitHub Desktop.
Save martijnvdbrug/f7479158a399c67639c0f56367508145 to your computer and use it in GitHub Desktop.
export class CompleteFlow implements Flow {
createConfiguration(): Promise<ProductConfiguration> {
// blijft hetzelfde?
return undefined;
}
getOptions(): Promise<ProductConfigurationOption> {
// is anders per flow
return undefined;
}
publish(): Promise<ProductConfigurationOption> {
// verschilt per flow
return undefined;
}
updateConfiguration(): Promise<ProductConfiguration> {
// verschilt per flow
return undefined;
}
}
export class Configurator {
mistergreen_nl = new CompleteFlow();
mistergreen_be = new ShortFlow();
private getFlow(tenant: string): Flow {
switch(tenant) {
case 'mistergreen_nl': return this.mistergreen_nl;
case 'mistergreen_be': return this.mistergreen_be;
default: throw Error(`No tenant available for ${tenant}`);
}
}
async createConfiguration(auth: Authentication, input: ConfiguratorConfigurationInput) {
await this.getFlow(auth.tenant).createConfiguration();
}
async updateOption(auth: Authentication) {
await this.getFlow(auth.tenant).updateConfiguration()
}
async approveConfiguration(auth: Authentication, configurationId: string, agreementIds: string[]) {
await this.getFlow(auth.tenant).publish();
}
}
export interface Flow {
createConfiguration(): Promise<ProductConfiguration>;
updateConfiguration(): Promise<ProductConfiguration>;
getOptions(): Promise<ProductConfigurationOption>;
publish(): Promise<ProductConfigurationOption>;
}
export class ShortFlow implements Flow {
createConfiguration(): Promise<ProductConfiguration> {
// blijft hetzelfde?
return undefined;
}
getOptions(): Promise<ProductConfigurationOption> {
// is anders per flow
// Dit kan de bestaande services aanroepen
return undefined;
}
publish(): Promise<ProductConfigurationOption> {
// verschilt per flow
return undefined;
}
updateConfiguration(): Promise<ProductConfiguration> {
// verschilt per flow
return undefined;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment