From 490e68f15f8fc3b1064bdba02fe850156b5598d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Semp=C3=A9?= Date: Mon, 6 Mar 2023 10:52:56 +0100 Subject: [PATCH] feat(instant_charge): Ability to define charge as instant --- lib/models/charge.js | 1 + test/plan.test.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/models/charge.js b/lib/models/charge.js index c87c851..1bfbbdd 100644 --- a/lib/models/charge.js +++ b/lib/models/charge.js @@ -13,6 +13,7 @@ export default class Charge { if (isPresent(this.attributes.id)) result.id = this.attributes.id; if (isPresent(this.attributes.billableMetricId)) result.billable_metric_id = this.attributes.billableMetricId; if (isPresent(this.attributes.chargeModel)) result.charge_model = this.attributes.chargeModel; + if (isPresent(this.attributes.instant)) result.instant = this.attributes.instant; if (isPresent(this.attributes.properties)) result.properties = this.attributes.properties; if (isPresent(this.attributes.groupProperties)) result.group_properties = this.attributes.groupProperties; diff --git a/test/plan.test.js b/test/plan.test.js index cb32a2f..b40f31f 100644 --- a/test/plan.test.js +++ b/test/plan.test.js @@ -5,8 +5,11 @@ import Plan from '../lib/models/plan.js'; import Charge from '../lib/models/charge.js'; let client = new Client('api_key') -let charge = new Charge({billableMetricId: 'billable_metric_id', amountCurrency: 'EUR', - chargeModel: 'standard' +let charge = new Charge({ + billableMetricId: 'billable_metric_id', + amountCurrency: 'EUR', + chargeModel: 'standard', + instant: false }) let charges = [charge] let plan = new Plan({name: 'name1', code: 'code1', interval: 'weekly', amountCents: 1000, @@ -33,6 +36,7 @@ let response = { lago_billable_metric_id: 'id', created_at: '2022-04-29T08:59:51Z', charge_model: 'standard', + instant: false, properties: {}, group_properties: [] }