Commit Graph

11 Commits

Author SHA1 Message Date
Fabien O'Carroll
08d3e6e99c Allowed for OfferDescription to be null/empty
refs https://github.com/TryGhost/Team/issues/1083

OfferDescription is not a required field, so we must not throw when it
is falsy or not present.
2021-10-08 12:40:57 +02:00
Fabien O'Carroll
35f150bcf4 Moved errors to domain/errors
no-issue

More cleanup to pull files into their appropriate responsibility
2021-10-08 12:31:11 +02:00
Fabien O'Carroll
78be4b55c9 Moved ValueObject to domain/models/shared
no-issue

This is only ever used in this directory so it makes sense to be
colocated.
2021-10-08 12:23:40 +02:00
Fabien O'Carroll
4a27ef68df Moved events into domain directory
no-issue

Events are a domain concern and as such should live in this directory
2021-10-08 12:21:27 +02:00
Fabien O'Carroll
9f7a922415 Added support for "repeating" duration Offers
refs https://github.com/TryGhost/Team/issues/1083

We combine the duration and duration_in_months into a single value
object which can be validated together, meaning we will never have
properties which are out of sync (e.g. forever durations with 2 months).
2021-10-08 12:10:36 +02:00
Fabien O'Carroll
c8933c9abd Fixed handling of null currency & used duration
no-issue

Currency is not always present on an offer so we need to handle it.
Duration was incorrectly not passed to Stripe when creating the coupon.
2021-10-07 18:18:53 +02:00
Fabien O'Carroll
170591a113 Improved types for Offer
no-issue

This splits out the types of the Offers properties from the types of the
expected values to be passed to create.
2021-10-07 17:37:48 +02:00
Fabien O'Carroll
2b58ecd82e Added support for creating fixed offers with currency
refs https://github.com/TryGhost/Team/issues/1083

We now allow creating offers for a fixed amount, rather than a
percentage. These require a currency to be passed as a fixed amount is
meaningless without one.
2021-10-07 17:37:48 +02:00
Fabien O'Carroll
2c04afe810 Updated types of Offers to "fixed" and "percent"
no-issue

This is inline with the language used elsewhere to describe these types.
2021-10-07 17:35:34 +02:00
Fabien O'Carroll
6d383c2d0e Added support for "once" and "forever" Offer duration
refs https://github.com/TryGhost/Team/issues/1083

Instead of Offers being hardcoded to the "once" duration this will allow
Admins to start creating offers of variable durations.
2021-10-07 17:13:23 +02:00
Fabien O'Carroll
504fb1bfa1 Used Value Objects to validate outside of Offer factory
no-issue

This adds the concept of "Value Objects" to an Offers properties,
allowing us to move validation out and ensure that an Offer will only
ever have valid properties, without having to duplicate checks - or
leave them to the persistent layer. This means we can fail early, as
well as write unit tests for all of our validation.
2021-10-07 16:46:08 +02:00