mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
46e281241e
refs https://github.com/TryGhost/Team/issues/712 closes https://github.com/TryGhost/Team/issues/717 The product API is updated to support `monthly/yearly_price` on each product instead of using list of stripe prices. This change updates the handling of membership settings to use the updated API instead of `stripe_prices` property.
28 lines
863 B
JavaScript
28 lines
863 B
JavaScript
import StripePrice from 'ghost-admin/models/stripe-price';
|
|
import Transform from '@ember-data/serializer/transform';
|
|
import {A as emberA, isArray as isEmberArray} from '@ember/array';
|
|
|
|
export default Transform.extend({
|
|
deserialize(serialized) {
|
|
if (serialized === null || serialized === undefined) {
|
|
return null;
|
|
} else if (Array.isArray(serialized)) {
|
|
const stripePrices = serialized.map(itemDetails => StripePrice.create(itemDetails));
|
|
|
|
return emberA(stripePrices);
|
|
} else {
|
|
return StripePrice.create(serialized);
|
|
}
|
|
},
|
|
|
|
serialize(deserialized) {
|
|
if (isEmberArray(deserialized)) {
|
|
return deserialized.map((item) => {
|
|
return item;
|
|
}).compact();
|
|
} else {
|
|
return deserialized || null;
|
|
}
|
|
}
|
|
});
|