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

Commit

Permalink
!feat: added CreateState endpoint to subscription, types update (#928)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: types change
  • Loading branch information
rostyk-kanafotskyy authored May 31, 2024
1 parent 1538c77 commit c65b2ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/endpoints/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions src/types/subscriptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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[]
}
Expand All @@ -139,4 +143,6 @@ export interface SubscriptionsEndpoint
GetAttachedProducts(id: string) : Promise<Resource<SubscriptionOfferingProduct[]>>

GetAttachedPlans(id: string) : Promise<Resource<SubscriptionOfferingPlan[]>>

CreateState(id: string, action: SubscriptionsStateAction) : Promise<void>
}

0 comments on commit c65b2ab

Please sign in to comment.