From c65b2ab771df6cb99b88af0c9e36396ce10785e3 Mon Sep 17 00:00:00 2001 From: Rostyk <34774987+rostyk-kanafotskyy@users.noreply.github.com> Date: Fri, 31 May 2024 11:40:41 +0300 Subject: [PATCH] !feat: added CreateState endpoint to subscription, types update (#928) BREAKING CHANGE: types change --- src/endpoints/subscriptions.js | 9 +++++++++ src/types/subscriptions.d.ts | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/src/endpoints/subscriptions.js b/src/endpoints/subscriptions.js index d5971b597..1e51c0b63 100644 --- a/src/endpoints/subscriptions.js +++ b/src/endpoints/subscriptions.js @@ -24,6 +24,15 @@ class SubscriptionsEndpoint extends CRUDExtend { GetAttachedPlans(id) { return this.request.send(`${this.endpoint}/${id}/plans`, 'GET') } + + CreateState(id, action) { + return this.request.send(`${this.endpoint}/${id}/states`, 'POST', { + type: 'subscription_state', + attributes: { + action + } + }) + } } export default SubscriptionsEndpoint diff --git a/src/types/subscriptions.d.ts b/src/types/subscriptions.d.ts index ef792246e..e4cb869d4 100644 --- a/src/types/subscriptions.d.ts +++ b/src/types/subscriptions.d.ts @@ -103,6 +103,8 @@ export interface Subscription extends Identifiable, SubscriptionBase { owner: string status: 'active' | 'inactive' canceled: boolean + paused: boolean + closed: boolean timestamps: { updated_at: string created_at: string @@ -113,6 +115,8 @@ export interface Subscription extends Identifiable, SubscriptionBase { export type SubscriptionsInclude = 'plans' +export type SubscriptionsStateAction = 'cancel'| 'pause'| 'resume' + export interface SubscriptionsIncluded { plans: SubscriptionOfferingPlan[] } @@ -139,4 +143,6 @@ export interface SubscriptionsEndpoint GetAttachedProducts(id: string) : Promise> GetAttachedPlans(id: string) : Promise> + + CreateState(id: string, action: SubscriptionsStateAction) : Promise }