Commit Graph

57 Commits

Author SHA1 Message Date
Fabien O'Carroll
dec46383b7 Updated API to use snake_case for redemption_count
no-issue
2021-10-18 17:29:30 +02:00
Fabien O'Carroll
959fbae83d Published new versions
- @tryghost/member-analytics-service@0.1.3
 - @tryghost/member-events@0.3.0
 - @tryghost/members-analytics-ingress@0.1.4
 - @tryghost/members-api@2.3.0
 - @tryghost/members-offers@0.7.0
2021-10-18 17:28:06 +02:00
Fabien O'Carroll
05619a193c Included redemptions in OfferDTO
refs https://github.com/TryGhost/Team/issues/1132

The DTO is the object which we expose externally so this adds the
Redemptions property for consumption by our external API's
2021-10-18 17:26:34 +02:00
Fabien O'Carroll
dbf549b664 Fixed count for redemptions
no-issue

You must use `where` rather than `forge` when generating counts.
2021-10-18 17:26:34 +02:00
Fabien O'Carroll
3cd26bc11b Updated OfferRepository to handle redemptions
refs https://github.com/TryGhost/Team/issues/1132

The OfferRepository needs to read from the OfferRedemptionModel to get
this data.
2021-10-18 17:26:34 +02:00
Fabien O'Carroll
34c0a7f6af Added redemptionCount to Offer
refs https://github.com/TryGhost/Team/issues/1132

This is a read-only property for tracking how many times an Offer has
been redeemed
2021-10-18 15:17:31 +02:00
Fabien O'Carroll
30fa4158bd Published new versions
- @tryghost/members-api@2.2.3
 - @tryghost/members-offers@0.6.2
2021-10-18 14:33:00 +02:00
Fabien O'Carroll
47ad10629e Used correct methods for reading/writing to db
no-issue

Using `save` was a placeholder and isn't the correct way to interact
with our model layer.
2021-10-15 11:08:30 +02:00
Fabien O'Carroll
c2f85d3742 Used isEqual to compare ValueObjects
no-issue

This ensures that ValueObjects can contain non-primitive types.
2021-10-14 14:56:37 +02:00
Fabien O'Carroll
3fc4bf6239 Published new versions
- @tryghost/members-api@2.2.2
 - @tryghost/members-offers@0.6.1
2021-10-14 12:06:48 +02:00
Fabien O'Carroll
53d24e501d Fixed Stripe Checkout using Offers
refs https://github.com/TryGhost/Members/commit/5172e40646

When we updated to use the OffersAPI instead of OfferRepository this was
missed, and we were passing blank coupon to Stripe Checkout. This should
eventually be replaced with a call like `getCoupon(offerId)` from a
payments service.
2021-10-14 12:02:39 +02:00
Fabien O'Carroll
8ef752a7f7 Published new versions
- @tryghost/members-offers@0.6.0
2021-10-12 18:36:47 +02:00
Fabien O'Carroll
96e87d6798 Ensured that Offers can be filtered on status
refs https://github.com/TryGhost/Team/issues/1131

This adds a mapping between the status property used in the domain & API
and the active column used in the database. As we only have the usecase
of filtering by `status` right now, we have not added support for all
the other columns. Instead of these potentially erroring where the
column name does not match the property name in the domain/api - we've
added a transformer which will ignore all filters for properties other
than `status`. This follows postels law, in that we can be liberal with
the filters we accept, but conservative in the ones we implement.
2021-10-12 18:36:04 +02:00
Fabien O'Carroll
cf8fcc6f35 Installed @nexes/mongo-utils
refs https://github.com/TryGhost/Team/issues/1131

This will allow us to map filters from our domain to the persistence
layer.
2021-10-12 18:32:48 +02:00
Fabien O'Carroll
1e4b5c792a Supported using NQL filter to get Offers
refs https://github.com/TryGhost/Team/issues/1131

This adds initial support for pass through a filter to the Model layer,
so that we can fetch Offers based on an NQL filter.
2021-10-12 18:32:48 +02:00
Fabien O'Carroll
73e11690c1 Published new versions
- @tryghost/members-offers@0.5.0
2021-10-12 17:14:11 +02:00
Fabien O'Carroll
facbfcfa8e Added support for Offer status to API
refs https://github.com/TryGhost/Team/issues/1131

- Includes `status` on OfferDTO so client can use it
- Allows editing `status` of Offers
- Allows setting initial `status` when creating Offers
2021-10-12 17:11:54 +02:00
Fabien O'Carroll
04b9944e67 Defaulted to 'active' status when creating Offers
refs https://github.com/TryGhost/Team/issues/1131

This ensures that Offers are active by default.
2021-10-12 17:10:51 +02:00
Fabien O'Carroll
a772f5b82f Wired up Offer status to the OfferRepository
refs https://github.com/TryGhost/Team/issues/1131

This allows us to persist and hydrate the Offer status from our
database.
2021-10-12 15:29:13 +02:00
Fabien O'Carroll
1f936357d9 Added concept of OfferStatus to domain model
refs https://github.com/TryGhost/Team/issues/1131

This allows us to model the behaviour of archived & active offers, as
well as allowing us to set their status on the model.
2021-10-12 15:27:27 +02:00
Fabien O'Carroll
d148108ae6 Published new versions
- @tryghost/members-api@2.1.1
 - @tryghost/members-offers@0.4.2
2021-10-08 15:21:07 +02:00
Fabien O'Carroll
1312943f5b Updated Offer to only change code once
no-issue

This simplifies the handling of updating redirects for a code, and
doesn't affect our application layer because we never have the need to
change a code twice.

In future this should be replaced with events at the domain level - so
that we do not have to track changed properties and instead a redirect
service can listen to events, which would be dispatched on a successful
save by the repository.
2021-10-08 13:02:22 +02:00
Fabien O'Carroll
1f703920c9 Published new versions
- @tryghost/members-offers@0.4.1
2021-10-08 12:43:16 +02:00
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
9bcd25fe5e Moved application concerns to an application dir
no-issue

Shuffling files to give a better idea of what the files concern, as well
as to add some structure.
2021-10-08 12:27:17 +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
32a88df1d3 Published new versions
- @tryghost/members-offers@0.4.0
2021-10-08 12:13:38 +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
6afb1eae40 Published new versions
- @tryghost/members-offers@0.3.5
2021-10-08 11:41:07 +02:00
Fabien O'Carroll
bd3f1e6456 Fixed sending back currency for Fixed Offers
no-issue

Since we changed the type from "amount" to "fixed" the logic to send
back the currency was not working. This updates it to use the correct
values.
2021-10-08 11:38:47 +02:00
Fabien O'Carroll
a5f4698201 Published new versions
- @tryghost/members-offers@0.3.4
2021-10-07 18:21:52 +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
13b870d0ef Published new versions
- @tryghost/members-offers@0.3.3
2021-10-07 17:42:52 +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
ea0282c80e Published new versions
- @tryghost/members-offers@0.3.2
2021-10-07 16:46:52 +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
Fabien O'Carroll
a673b2ae99 Published new versions
- @tryghost/members-offers@0.3.1
2021-10-07 12:47:03 +02:00
Fabien O'Carroll
d9e40c6070 Ensured Offer code is slugified
refs https://github.com/TryGhost/Team/issues/1083

This ensures that the code will be URL safe for redirects
2021-10-07 12:45:51 +02:00
Fabien O'Carroll
309e827a7f Published new versions
- @tryghost/members-api@2.1.0
 - @tryghost/members-offers@0.3.0
2021-10-06 16:55:51 +02:00
Fabien O'Carroll
6ae8b7eb0c Added stripeCouponId to Offer
refs https://github.com/TryGhost/Team/issues/1090

When creating a Stripe Checkout Session for an Offer - we need access to
the underlying Stripe Coupon. Exposing it here allows consumers of the
OfferRepository access.
2021-10-06 16:12:53 +02:00
Fabien O'Carroll
d57d082c39 Exposed OfferRepository from OffersModule
refs https://github.com/TryGhost/Team/issues/1090

When creating checkout session we will need to be able to look up Offers
from the OfferRepository. This exposes the repository so that it can be
passed as a dependency elsewhere.
2021-10-06 15:15:03 +02:00
Fabien O'Carroll
371581f677 Published new versions
- @tryghost/members-offers@0.2.1
2021-10-06 12:08:48 +02:00
Fabien O'Carroll
dbc7d73be7 Fixed updateOffer API method
no-issue

- Property names were out of sync with API
- Async methods were not awaited
- Transaction was erroneously commited
2021-10-06 12:07:03 +02:00
Fabien O'Carroll
6397438e73 Published new versions
- @tryghost/members-offers@0.2.0
2021-10-05 16:27:31 +02:00
Fabien O'Carroll
33d042ccf7 Added getOffer method to OffersAPI
refs https://github.com/TryGhost/Team/issues/1083
2021-10-05 16:25:56 +02:00