Commit Graph

15 Commits

Author SHA1 Message Date
Fabien O'Carroll
ff2da8a417 Added and emitted events for Offer Created
refs https://github.com/TryGhost/Team/issues/1166

Since we removed the creation of coupons from the Offers module, we must
emit events so that the Payments module can handle creating Coupons when
Offers are created.

We also export the events from the module so that they can be listened
to by the Payments module.

We also export other internals of the module so that the types can be
used.
2021-10-21 15:40:55 +02:00
Fabien O'Carroll
947fa74b9e Removed stripe_coupon_id handling from Offers
refs https://github.com/TryGhost/Team/issues/1166

This will be handled by a payments module instead. In order to
disconnect Stripe we must delete all Stripe related data, which means an
Offer doesn't inherently have a stripe coupon id. Instead we can use a
payments service which will get/create the coupon for us when we need
it.
2021-10-21 15:40:55 +02:00
Fabien O'Carroll
e744c0f82e Fixed issue with updating offer to empty description
no-issue

Because we were checking for truthyness rather than existence when
updating properties on an Offer - it was impossible to set the
description to a blank string, as this is falsy.
2021-10-19 11:00:18 +02:00
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
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
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
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
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
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
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
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
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
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