From 935ea556d89332e9bce976312c2f8a6d40be3ff7 Mon Sep 17 00:00:00 2001 From: Gijs Date: Wed, 27 Nov 2024 09:18:14 +0100 Subject: [PATCH 1/2] feat: add set articles to KlarnaKP pay function --- src/PaymentMethods/KlarnaKP/Models/IPay.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/PaymentMethods/KlarnaKP/Models/IPay.ts b/src/PaymentMethods/KlarnaKP/Models/IPay.ts index d3a7b69..184f09b 100644 --- a/src/PaymentMethods/KlarnaKP/Models/IPay.ts +++ b/src/PaymentMethods/KlarnaKP/Models/IPay.ts @@ -1,13 +1,22 @@ -import { IPaymentRequest, Person, ServiceParameter } from '../../../Models'; +import { IArticle, IPaymentRequest, Person, ServiceParameter } from '../../../Models'; +import Article, { IKlarnaKpArticle } from './Article'; export interface IPay extends IPaymentRequest { reservationNumber?: string; + articles?: Partial[]; } export class Pay extends ServiceParameter { set reservationNumber(value: string) { this.set('reservationNumber', value); } + + set articles(articles: IArticle[]) { + this.set( + 'articles', + articles.map((article) => new Article(article)) + ); + } } export class Customer extends Person { From e34325e2c3923578d74cd271bb23ce4a32c5a204 Mon Sep 17 00:00:00 2001 From: Gijs Date: Wed, 27 Nov 2024 13:38:44 +0100 Subject: [PATCH 2/2] PR feedback --- src/PaymentMethods/KlarnaKP/Models/IPay.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/PaymentMethods/KlarnaKP/Models/IPay.ts b/src/PaymentMethods/KlarnaKP/Models/IPay.ts index 184f09b..d7cdf8a 100644 --- a/src/PaymentMethods/KlarnaKP/Models/IPay.ts +++ b/src/PaymentMethods/KlarnaKP/Models/IPay.ts @@ -17,6 +17,16 @@ export class Pay extends ServiceParameter { articles.map((article) => new Article(article)) ); } + + protected getGroups() { + return super.getGroups({ + Articles: 'Article', + }); + } + + protected getCountable() { + return super.getCountable(['Articles']); + } } export class Customer extends Person {