Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -65,4 +66,5 @@ export const Reporter = resourceNamespace("reporter", {

export const Client = resourceNamespace("client", {
Passport: Passport,
Discounts: Discounts,
});
37 changes: 37 additions & 0 deletions src/resources/Client/Discounts.ts
Original file line number Diff line number Diff line change
@@ -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",
}),
});

14 changes: 14 additions & 0 deletions types/Client/Discounts.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
declare module "@sfpy/node-core" {
namespace Safepay {
namespace Client {
class Discounts {
create(params?: any, options?: any): Promise<any>;
find(params?: any, options?: any): Promise<any>;
archive(params?: any, options?: any): Promise<any>;
update(params?: any, options?: any): Promise<any>;
list(params?: any, options?: any): Promise<any>;
appliedList(params?: any, options?: any): Promise<any>;
}
}
}
}
3 changes: 3 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
///<reference path='./User/Password.d.ts' />
///<reference path='./User/Object.d.ts' />
///<reference path='./User/Cards.d.ts' />
///<reference path='./User/PushNotifications.d.ts' />
///<reference path='./Auth/Login.d.ts' />
///<reference path='./Auth/Logout.d.ts' />
///<reference path='./Invoice/Quicklinks.d.ts' />
///<reference path='./Reporter/Payments.d.ts' />
///<reference path='./Client/Passport.d.ts' />
///<reference path='./Client/Discounts.d.ts' />

declare module "@sfpy/node-core" {
// Added to in other modules, referenced above.
Expand Down Expand Up @@ -83,6 +85,7 @@ declare module "@sfpy/node-core" {

client: {
passport: Safepay.Client.Passport;
discounts: Safepay.Client.Discounts;
};
}
export default Safepay;
Expand Down