import BaseService from '../index'; import type { IValidateDiscountResponse } from './discount.interface'; /** * @var {string} REDEEM_DISCOUNT_CODE * Redeems an EXTEND_TRIAL_DAYS code for the authenticated user */ export const REDEEM_DISCOUNT_CODE = 'v2/discount-code/redeem'; /** * @var {string} VALIDATE_DISCOUNT_CODE * Checks a code: its kind, its value and whether Stripe checkouts take it */ export const VALIDATE_DISCOUNT_CODE = 'v2/discount-code/validate'; /** * Redeem a voucher code for the current user (grants trial days). * The auth token is attached by the axios default headers in service/config. * @param {string} code * @return {Promise} */ export const redeemDiscountCode = async (code: string): Promise => await BaseService.post(REDEEM_DISCOUNT_CODE, { code }); /** * Check a discount code before anything is bought: what kind it is, what it * is worth, and whether it can ride a Stripe checkout from here. * @param {string} code * @return {Promise} */ export const validateDiscountCode = async ( code: string ): Promise => await BaseService.post(VALIDATE_DISCOUNT_CODE, { code });