From 0d62b87dbeb702b04d88ce7d62dfb27cc12fa68f Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Wed, 13 Aug 2025 11:29:57 +0200 Subject: [PATCH] Added discounts and fixed push notifications. Signed-off-by: Thomas Smith --- package.json | 2 +- src/resources.ts | 2 ++ src/resources/Client/Discounts.ts | 37 +++++++++++++++++++++++++++++++ types/Client/Discounts.d.ts | 14 ++++++++++++ types/index.d.ts | 3 +++ 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/resources/Client/Discounts.ts create mode 100644 types/Client/Discounts.d.ts diff --git a/package.json b/package.json index 161ba07..e42110e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sfpy/node-core", - "version": "0.2.9", + "version": "0.3.0", "description": "Official NodeJS Core to create SDKs for Safepay APIs", "main": "cjs/safepay.cjs.node.js", "types": "types/index.d.ts", diff --git a/src/resources.ts b/src/resources.ts index 0ebcc0f..ed58ddb 100644 --- a/src/resources.ts +++ b/src/resources.ts @@ -15,6 +15,7 @@ import { Logout } from "./resources/Auth/Logout.js"; import { Quicklinks } from "./resources/Invoice/Quicklinks.js"; import { Payments as PaymentsResources } from "./resources/Reporter/Payments.js"; import { Passport } from "./resources/Client/Passport.js"; +import { Discounts } from "./resources/Client/Discounts.js"; import { Discount } from "./resources/Order/Discount.js"; import { Cards } from "./resources/User/Cards.js"; import { Vault } from "./resources/Order/Vault.js"; @@ -65,4 +66,5 @@ export const Reporter = resourceNamespace("reporter", { export const Client = resourceNamespace("client", { Passport: Passport, + Discounts: Discounts, }); diff --git a/src/resources/Client/Discounts.ts b/src/resources/Client/Discounts.ts new file mode 100644 index 0000000..37b8e37 --- /dev/null +++ b/src/resources/Client/Discounts.ts @@ -0,0 +1,37 @@ +import { SafepayResource } from "../../SafepayResource.js"; +const safepayMethod = SafepayResource.method; + +export const Discounts = SafepayResource.extend({ + basePath: "/client", + + create: safepayMethod({ + method: "POST", + path: "/discounts/v2/", + }), + + find: safepayMethod({ + method: "GET", + path: "/discounts/v2/{discount_token}", + }), + + archive: safepayMethod({ + method: "DELETE", + path: "/discounts/v2/{discount_token}", + }), + + update: safepayMethod({ + method: "PUT", + path: "/discounts/v2/{discount_token}", + }), + + list: safepayMethod({ + method: "GET", + path: "/discounts/v2/", + }), + + appliedList: safepayMethod({ + method: "GET", + path: "/discounts/v2/applied/list", + }), +}); + diff --git a/types/Client/Discounts.d.ts b/types/Client/Discounts.d.ts new file mode 100644 index 0000000..3cf3564 --- /dev/null +++ b/types/Client/Discounts.d.ts @@ -0,0 +1,14 @@ +declare module "@sfpy/node-core" { + namespace Safepay { + namespace Client { + class Discounts { + create(params?: any, options?: any): Promise; + find(params?: any, options?: any): Promise; + archive(params?: any, options?: any): Promise; + update(params?: any, options?: any): Promise; + list(params?: any, options?: any): Promise; + appliedList(params?: any, options?: any): Promise; + } + } + } +} diff --git a/types/index.d.ts b/types/index.d.ts index 462b76b..3709b28 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -16,11 +16,13 @@ /// /// /// +/// /// /// /// /// /// +/// declare module "@sfpy/node-core" { // Added to in other modules, referenced above. @@ -83,6 +85,7 @@ declare module "@sfpy/node-core" { client: { passport: Safepay.Client.Passport; + discounts: Safepay.Client.Discounts; }; } export default Safepay;