Created
December 17, 2019 13:09
-
-
Save martijnvdbrug/f7479158a399c67639c0f56367508145 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface Flow { | |
createConfiguration(): Promise<ProductConfiguration>; | |
updateConfiguration(): Promise<ProductConfiguration>; | |
getOptions(): Promise<ProductConfigurationOption>; | |
publish(): Promise<ProductConfigurationOption>; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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