From 8379a71cee55fe4f3289b98d0d503e0ee0caf448 Mon Sep 17 00:00:00 2001 From: Rostyk <34774987+rostyk-kanafotskyy@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:44:11 +0300 Subject: [PATCH] feat!: added endpoint to attach proration policy to offerings (#937) BREAKING CHANGE: --- src/endpoints/subscription-offerings.js | 6 ++++ src/types/subscription-offerings.d.ts | 45 +++++++++++++++++++------ 2 files changed, 41 insertions(+), 10 deletions(-) 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> }