Created
July 15, 2020 23:59
-
-
Save mariobittencourt/6dcb63073b7e4c81788f99693adb8984 to your computer and use it in GitHub Desktop.
Order updated with the versioning conversion
This file contains 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
class Order { | |
protected whenOrderCreated(event: OrderCreated): void { | |
this._items = event.items; | |
this._status = OrderStatus.OPEN; | |
this._amount = event.amount; | |
this._destination = event.destination; | |
this._customerId = event.customerId; | |
// New code - detect if we have the property first | |
if (event.hasOwnProperty('deliveryMethod') { | |
this._deliveryMethod = event.deliveryMethod; | |
} else { | |
// Assume one default from business | |
this._deliveryMethod = 'Standard'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment