mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +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 labs = require('../../../../../../shared/labs');
|
||||
|
||||
const forceActiveFilter = (frame) => {
|
||||
if (frame.options.filter) {
|
||||
@ -22,6 +23,10 @@ function convertTierInput(input) {
|
||||
visibility: input.visibility
|
||||
};
|
||||
|
||||
if (labs.isSet('freeTrial')) {
|
||||
converted.trial_days = input.trial_days;
|
||||
}
|
||||
|
||||
if (input.monthly_price && input.currency) {
|
||||
converted.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 localUtils = require('../../index');
|
||||
const utils = require('../../../../shared/utils');
|
||||
const labs = require('../../../../../../shared/labs');
|
||||
|
||||
module.exports = {
|
||||
browse: createSerializer('browse', paginatedTiers),
|
||||
@ -69,6 +70,10 @@ function serializeTier(tier, options, frame) {
|
||||
benefits: null
|
||||
};
|
||||
|
||||
if (labs.isSet('freeTrial')) {
|
||||
serialized.trial_days = json.trial_days;
|
||||
}
|
||||
|
||||
if (Array.isArray(json.benefits)) {
|
||||
serialized.benefits = json.benefits.map(benefit => benefit.name);
|
||||
} else {
|
||||
|
@ -21,6 +21,7 @@ Object {
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"name": "Free",
|
||||
"slug": "free",
|
||||
"trial_days": 0,
|
||||
"type": "free",
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"visibility": "public",
|
||||
@ -34,6 +35,7 @@ Object {
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"name": "Default Product",
|
||||
"slug": "default-product",
|
||||
"trial_days": 0,
|
||||
"type": "paid",
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"visibility": "public",
|
||||
|
@ -21,6 +21,7 @@ Object {
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"name": "Free",
|
||||
"slug": "free",
|
||||
"trial_days": 0,
|
||||
"type": "free",
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}/,
|
||||
"visibility": "public",
|
||||
@ -36,6 +37,7 @@ Object {
|
||||
"monthly_price": 1200,
|
||||
"name": "Default Product",
|
||||
"slug": "default-product",
|
||||
"trial_days": 0,
|
||||
"type": "paid",
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}/,
|
||||
"visibility": "public",
|
||||
@ -50,7 +52,7 @@ exports[`Tiers Content API Can request only active tiers 2: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "*",
|
||||
"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",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Accept-Encoding",
|
||||
|
Loading…
Reference in New Issue
Block a user