mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 04:13:30 +03:00
Wired trial days to tiers API
refs https://github.com/TryGhost/Team/issues/1724 - Added `trial_days` to api serializers
This commit is contained in:
parent
a0dca653e7
commit
2d12d9aa89
@ -1,4 +1,5 @@
|
|||||||
const localUtils = require('../../index');
|
const localUtils = require('../../index');
|
||||||
|
const labs = require('../../../../../../shared/labs');
|
||||||
|
|
||||||
const forceActiveFilter = (frame) => {
|
const forceActiveFilter = (frame) => {
|
||||||
if (frame.options.filter) {
|
if (frame.options.filter) {
|
||||||
@ -22,6 +23,10 @@ function convertTierInput(input) {
|
|||||||
visibility: input.visibility
|
visibility: input.visibility
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (labs.isSet('freeTrial')) {
|
||||||
|
converted.trial_days = input.trial_days;
|
||||||
|
}
|
||||||
|
|
||||||
if (input.monthly_price && input.currency) {
|
if (input.monthly_price && input.currency) {
|
||||||
converted.monthly_price = {
|
converted.monthly_price = {
|
||||||
amount: input.monthly_price,
|
amount: input.monthly_price,
|
||||||
|
@ -4,6 +4,7 @@ const debug = require('@tryghost/debug')('api:endpoints:utils:serializers:output
|
|||||||
const allowedIncludes = ['monthly_price', 'yearly_price'];
|
const allowedIncludes = ['monthly_price', 'yearly_price'];
|
||||||
const localUtils = require('../../index');
|
const localUtils = require('../../index');
|
||||||
const utils = require('../../../../shared/utils');
|
const utils = require('../../../../shared/utils');
|
||||||
|
const labs = require('../../../../../../shared/labs');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
browse: createSerializer('browse', paginatedTiers),
|
browse: createSerializer('browse', paginatedTiers),
|
||||||
@ -69,6 +70,10 @@ function serializeTier(tier, options, frame) {
|
|||||||
benefits: null
|
benefits: null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (labs.isSet('freeTrial')) {
|
||||||
|
serialized.trial_days = json.trial_days;
|
||||||
|
}
|
||||||
|
|
||||||
if (Array.isArray(json.benefits)) {
|
if (Array.isArray(json.benefits)) {
|
||||||
serialized.benefits = json.benefits.map(benefit => benefit.name);
|
serialized.benefits = json.benefits.map(benefit => benefit.name);
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,6 +21,7 @@ Object {
|
|||||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
"name": "Free",
|
"name": "Free",
|
||||||
"slug": "free",
|
"slug": "free",
|
||||||
|
"trial_days": 0,
|
||||||
"type": "free",
|
"type": "free",
|
||||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
"visibility": "public",
|
"visibility": "public",
|
||||||
@ -34,6 +35,7 @@ Object {
|
|||||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
"name": "Default Product",
|
"name": "Default Product",
|
||||||
"slug": "default-product",
|
"slug": "default-product",
|
||||||
|
"trial_days": 0,
|
||||||
"type": "paid",
|
"type": "paid",
|
||||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
"visibility": "public",
|
"visibility": "public",
|
||||||
|
@ -21,6 +21,7 @@ Object {
|
|||||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
"name": "Free",
|
"name": "Free",
|
||||||
"slug": "free",
|
"slug": "free",
|
||||||
|
"trial_days": 0,
|
||||||
"type": "free",
|
"type": "free",
|
||||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}/,
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}/,
|
||||||
"visibility": "public",
|
"visibility": "public",
|
||||||
@ -36,6 +37,7 @@ Object {
|
|||||||
"monthly_price": 1200,
|
"monthly_price": 1200,
|
||||||
"name": "Default Product",
|
"name": "Default Product",
|
||||||
"slug": "default-product",
|
"slug": "default-product",
|
||||||
|
"trial_days": 0,
|
||||||
"type": "paid",
|
"type": "paid",
|
||||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}/,
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}/,
|
||||||
"visibility": "public",
|
"visibility": "public",
|
||||||
@ -50,7 +52,7 @@ exports[`Tiers Content API Can request only active tiers 2: [headers] 1`] = `
|
|||||||
Object {
|
Object {
|
||||||
"access-control-allow-origin": "*",
|
"access-control-allow-origin": "*",
|
||||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||||
"content-length": "700",
|
"content-length": "730",
|
||||||
"content-type": "application/json; charset=utf-8",
|
"content-type": "application/json; charset=utf-8",
|
||||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||||
"vary": "Accept-Encoding",
|
"vary": "Accept-Encoding",
|
||||||
|
Loading…
Reference in New Issue
Block a user