diff --git a/src/endpoints/subscription-offerings.js b/src/endpoints/subscription-offerings.js index 9bf377107..e1b927942 100644 --- a/src/endpoints/subscription-offerings.js +++ b/src/endpoints/subscription-offerings.js @@ -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 diff --git a/src/types/subscription-offerings.d.ts b/src/types/subscription-offerings.d.ts index 07fd2a088..eb54734d1 100644 --- a/src/types/subscription-offerings.d.ts +++ b/src/types/subscription-offerings.d.ts @@ -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 { @@ -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 @@ -138,4 +161,6 @@ export interface SubscriptionOfferingsEndpoint AttachPlans(offeringId: string, body: SubscriptionOfferingAttachPlanBody): Promise> RemovePlan(offeringId: string, planId: string): Promise + + AttachProrationPolicy(offeringId: string, body: SubscriptionOfferingAttachProrationPolicyBody): Promise> }