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

Commit

Permalink
feat!: added endpoint to attach proration policy to offerings (#937)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
  • Loading branch information
rostyk-kanafotskyy authored Jun 26, 2024
1 parent 58b715c commit 8379a71
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/endpoints/subscription-offerings.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class SubscriptionOfferingsEndpoint extends CRUDExtend {
return this.request.send(`${this.endpoint}/${id}/plans`, 'GET')
}

AttachProrationPolicy(offeringId, body) {
return this.request.send(`${this.endpoint}/${offeringId}/relationships/proration-policies`, 'PUT', {
...body
})
}

}

export default SubscriptionOfferingsEndpoint
45 changes: 35 additions & 10 deletions src/types/subscription-offerings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,37 @@ export interface SubscriptionOfferingBase {
attributes: {
name: string
description: string
},
}
}

export interface SubscriptionOfferingRelationships {
relationships?: {
[key: string]: {
links?: {
related?: string
self?: string
},
data?: {
type?: string
id?: string
plans?: {
data: {
id: string
type: 'subscription_offering_plan'
}[]
links: {
related: string
}
}
products?: {
data: {
id: string
type: 'subscription_offering_product'
}[]
links: {
related: string
}
}
proration_policy?: {
data: {
id: string
type: 'proration_policy'
}
}
}

}

export interface SubscriptionOfferingBuildProduct {
Expand Down Expand Up @@ -67,7 +85,12 @@ export interface SubscriptionOfferingAttachPlanBody {
plans: string[]
}

export interface SubscriptionOffering extends Identifiable, SubscriptionOfferingBase {
export interface SubscriptionOfferingAttachProrationPolicyBody {
type: 'proration_policy'
id: string
}

export interface SubscriptionOffering extends Identifiable, SubscriptionOfferingBase, SubscriptionOfferingRelationships {
meta: {
external_product_refs: string[]
owner: string
Expand Down Expand Up @@ -138,4 +161,6 @@ export interface SubscriptionOfferingsEndpoint
AttachPlans(offeringId: string, body: SubscriptionOfferingAttachPlanBody): Promise<Resource<SubscriptionPlan[]>>

RemovePlan(offeringId: string, planId: string): Promise<void>

AttachProrationPolicy(offeringId: string, body: SubscriptionOfferingAttachProrationPolicyBody): Promise<Resource<SubscriptionOfferingAttachProrationPolicyBody>>
}

0 comments on commit 8379a71

Please sign in to comment.