mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
Updated types of Offers to "fixed" and "percent"
no-issue This is inline with the language used elsewhere to describe these types.
This commit is contained in:
parent
6d383c2d0e
commit
2c04afe810
@ -18,7 +18,7 @@ function toDomain(json) {
|
||||
code: json.code,
|
||||
display_title: json.portal_title,
|
||||
display_description: json.portal_description,
|
||||
type: json.discount_type,
|
||||
type: json.discount_type === 'amount' ? 'fixed' : 'percent',
|
||||
amount: json.discount_amount,
|
||||
cadence: json.interval,
|
||||
currency: json.currency,
|
||||
@ -118,7 +118,7 @@ class OfferRepository {
|
||||
code: offer.code.value,
|
||||
portal_title: offer.displayTitle.value,
|
||||
portal_description: offer.displayDescription.value,
|
||||
discount_type: offer.type.value,
|
||||
discount_type: offer.type.value === 'fixed' ? 'amount' : 'percent',
|
||||
discount_amount: offer.amount.value,
|
||||
interval: offer.cadence.value,
|
||||
product_id: offer.tier.id,
|
||||
|
@ -26,7 +26,7 @@ class OfferPercentageAmount extends OfferAmount {
|
||||
}
|
||||
}
|
||||
|
||||
class OfferAbsoluteAmount extends OfferAmount {
|
||||
class OfferFixedAmount extends OfferAmount {
|
||||
/** @param {unknown} amount */
|
||||
static create(amount) {
|
||||
if (typeof amount !== 'number') {
|
||||
@ -46,4 +46,4 @@ class OfferAbsoluteAmount extends OfferAmount {
|
||||
|
||||
module.exports = OfferAmount;
|
||||
module.exports.OfferPercentageAmount = OfferPercentageAmount;
|
||||
module.exports.OfferAbsoluteAmount = OfferAbsoluteAmount;
|
||||
module.exports.OfferFixedAmount = OfferFixedAmount;
|
||||
|
@ -1,7 +1,7 @@
|
||||
const ValueObject = require('../../shared/ValueObject');
|
||||
const InvalidOfferType = require('../../errors').InvalidOfferType;
|
||||
|
||||
/** @extends ValueObject<'amount'|'percent'> */
|
||||
/** @extends ValueObject<'fixed'|'percent'> */
|
||||
class OfferType extends ValueObject {
|
||||
/** @param {unknown} type */
|
||||
static create(type) {
|
||||
@ -10,18 +10,18 @@ class OfferType extends ValueObject {
|
||||
message: 'Offer `type` must be a string.'
|
||||
});
|
||||
}
|
||||
if (type !== 'percent' && type !== 'amount') {
|
||||
if (type !== 'percent' && type !== 'fixed') {
|
||||
throw new InvalidOfferType({
|
||||
message: 'Offer `type` must be one of "percent" or "amount".'
|
||||
message: 'Offer `type` must be one of "percent" or "fixed".'
|
||||
});
|
||||
}
|
||||
|
||||
return new OfferType(type);
|
||||
}
|
||||
|
||||
static Percent = new OfferType('percent')
|
||||
static Percentage = new OfferType('percent')
|
||||
|
||||
static Amount = new OfferType('amount')
|
||||
static Fixed = new OfferType('fixed')
|
||||
}
|
||||
|
||||
module.exports = OfferType;
|
||||
|
Loading…
Reference in New Issue
Block a user