Added support for benefits to Admin Products API

refs https://github.com/TryGhost/Team/issues/806
This commit is contained in:
Fabien O'Carroll 2021-06-24 17:34:17 +01:00
parent c57e612286
commit a6592566bb
4 changed files with 23 additions and 12 deletions

View File

@ -5,7 +5,7 @@ const membersService = require('../../services/members');
const i18n = require('../../../shared/i18n');
const allowedIncludes = ['stripe_prices', 'monthly_price', 'yearly_price'];
const allowedIncludes = ['stripe_prices', 'monthly_price', 'yearly_price', 'benefits'];
module.exports = {
docName: 'products',

View File

@ -77,7 +77,8 @@ function serializeProduct(product, options, apiType) {
updated_at: json.updated_at,
stripe_prices: json.stripePrices ? json.stripePrices.map(price => serializeStripePrice(price, hideStripeData)) : null,
monthly_price: serializeStripePrice(json.monthlyPrice, hideStripeData),
yearly_price: serializeStripePrice(json.yearlyPrice, hideStripeData)
yearly_price: serializeStripePrice(json.yearlyPrice, hideStripeData),
benefits: json.benefits || null
};
return serialized;
@ -164,6 +165,16 @@ function createSerializer(debugString, serialize) {
* @prop {StripePrice[]} [stripe_prices]
* @prop {StripePrice} [monthly_price]
* @prop {StripePrice} [yearly_price]
* @prop {Benefit[]} [benefits]
*/
/**
* @typedef {object} Benefit
* @prop {string} id
* @prop {string} name
* @prop {string} slug
* @prop {Date} created_at
* @prop {Date} updated_at
*/
/**

View File

@ -45,7 +45,7 @@
"@nexes/nql": "0.5.2",
"@sentry/node": "6.8.0",
"@tryghost/adapter-manager": "0.2.14",
"@tryghost/admin-api-schema": "2.3.0",
"@tryghost/admin-api-schema": "2.4.0",
"@tryghost/bookshelf-plugins": "0.1.3",
"@tryghost/bootstrap-socket": "0.2.9",
"@tryghost/config-url-helpers": "0.1.0",
@ -65,7 +65,7 @@
"@tryghost/limit-service": "0.6.1",
"@tryghost/logging": "0.1.3",
"@tryghost/magic-link": "1.0.4",
"@tryghost/members-api": "1.15.0",
"@tryghost/members-api": "1.17.0",
"@tryghost/members-csv": "1.1.0",
"@tryghost/members-ssr": "1.0.4",
"@tryghost/mw-session-from-token": "0.1.22",

View File

@ -586,10 +586,10 @@
dependencies:
"@tryghost/errors" "^0.2.13"
"@tryghost/admin-api-schema@2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@tryghost/admin-api-schema/-/admin-api-schema-2.3.0.tgz#3ec7dd98576e26166ff4c8082e6cd7542c3322d0"
integrity sha512-f69N5TE4Wzff0xr13Pa+HyfqCVktiIg+5L3we2TWYUO8XSrZcLKo5ionj/ybMHUY1M3DMVL2yVFjOfRWnV2TpA==
"@tryghost/admin-api-schema@2.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@tryghost/admin-api-schema/-/admin-api-schema-2.4.0.tgz#d84885ba138d7da709f8934f18abe3a4635e6f09"
integrity sha512-A1b/lohwKmR2u26ycQvvSzC9MrRwk3ZLvHPPbHeFxH4g2yH2N3JX420WHvi4Vk0e2E5gFzir2e7itG9BJ9SaoQ==
dependencies:
"@tryghost/errors" "^0.2.10"
bluebird "^3.5.3"
@ -893,10 +893,10 @@
jsonwebtoken "^8.5.1"
lodash "^4.17.15"
"@tryghost/members-api@1.15.0":
version "1.15.0"
resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-1.15.0.tgz#f5367ab208a9658f116ece9fa30fc87fd6bc4ab7"
integrity sha512-UwXmMIZhAiCatbIKfFzeNQUPrIJg3yPbPYGg8Yp5TfIRIjeBEOXyauNc5XR8616Wc2mktkvTs/BBs5er6QBvoQ==
"@tryghost/members-api@1.17.0":
version "1.17.0"
resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-1.17.0.tgz#375217d3e2aacaaaca2a6556b940e2961991a8f4"
integrity sha512-H2gsg3EhRZxYIdr8eOVSgkNRYoHjEQrYdGqGqnnhe5y38xm/IZHPazHwm7Vj3za9ayZzLN1MJISNA8a0qovVlQ==
dependencies:
"@tryghost/errors" "^0.2.9"
"@tryghost/magic-link" "^1.0.4"