Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit c65b2ab

Browse files
!feat: added CreateState endpoint to subscription, types update (#928)
BREAKING CHANGE: types change
1 parent 1538c77 commit c65b2ab

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/endpoints/subscriptions.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ class SubscriptionsEndpoint extends CRUDExtend {
2424
GetAttachedPlans(id) {
2525
return this.request.send(`${this.endpoint}/${id}/plans`, 'GET')
2626
}
27+
28+
CreateState(id, action) {
29+
return this.request.send(`${this.endpoint}/${id}/states`, 'POST', {
30+
type: 'subscription_state',
31+
attributes: {
32+
action
33+
}
34+
})
35+
}
2736
}
2837

2938
export default SubscriptionsEndpoint

src/types/subscriptions.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ export interface Subscription extends Identifiable, SubscriptionBase {
103103
owner: string
104104
status: 'active' | 'inactive'
105105
canceled: boolean
106+
paused: boolean
107+
closed: boolean
106108
timestamps: {
107109
updated_at: string
108110
created_at: string
@@ -113,6 +115,8 @@ export interface Subscription extends Identifiable, SubscriptionBase {
113115

114116
export type SubscriptionsInclude = 'plans'
115117

118+
export type SubscriptionsStateAction = 'cancel'| 'pause'| 'resume'
119+
116120
export interface SubscriptionsIncluded {
117121
plans: SubscriptionOfferingPlan[]
118122
}
@@ -139,4 +143,6 @@ export interface SubscriptionsEndpoint
139143
GetAttachedProducts(id: string) : Promise<Resource<SubscriptionOfferingProduct[]>>
140144

141145
GetAttachedPlans(id: string) : Promise<Resource<SubscriptionOfferingPlan[]>>
146+
147+
CreateState(id: string, action: SubscriptionsStateAction) : Promise<void>
142148
}

0 commit comments

Comments
 (0)