Skip to content
Merged
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
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,27 @@ Types of application are generated automatically from swagger structure via [ope
To generate new types after OpenAPI structure has been changed please run
```
npx openapi-typescript ./tatrapayplus_api_sandbox.json -o ./src/paths.d.ts
```

# Logging

`TBPlusLogger` is exported from the package and can be subclassed to customize log output:

```typescript
import { TBPlusSDK, TBPlusLogger } from "@tatrabanka/tatrapayplus-node";

class ConsoleLogger extends TBPlusLogger {
protected writeLine(line: string): void {
console.log("[ConsoleLogger]", line);
}
}

const logger = new ConsoleLogger();
const sdk = new TBPlusSDK(API_KEY, API_SECRET, {}, logger);
```

Pass `false` to the logger constructor to disable masking of sensitive fields:

```typescript
const logger = new TBPlusLogger(false);
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tatrabanka/tatrapayplus-node",
"version": "1.0.1",
"version": "1.0.2",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import fs from "node:fs";
import path from "node:path";

export * from "./enums";
export { TBPlusLogger } from "./logger";

export class TBPlusSDK {
private clientId: string;
Expand Down
12 changes: 7 additions & 5 deletions tests/live.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { describe, expect, it, vi } from "vitest";
import { GatewayMode, TBPlusSDK, PaymentMethod, SimpleStatus } from "../src";
import {
GatewayMode,
TBPlusSDK,
TBPlusLogger,
PaymentMethod,
SimpleStatus,
} from "../src";
import dotenv from "dotenv";
import { getAvailable } from "../src/helpers";
import { TBPlusLogger } from "../src/logger";

dotenv.config();

Expand All @@ -17,7 +22,6 @@ describe("TBPlusSDK tests on live", () => {
const sdk = new TBPlusSDK(
process.env.API_KEY as string,
process.env.API_SECRET as string,
"192.0.2.123",
);
const { data, error } = await sdk.getPaymentMethods();
expect(error).toBeUndefined();
Expand All @@ -32,7 +36,6 @@ describe("TBPlusSDK tests on live", () => {
const sdk = new TBPlusSDK(
process.env.API_KEY as string,
process.env.API_SECRET as string,
"192.0.2.123",
{},
new TestLogger(),
);
Expand Down Expand Up @@ -75,7 +78,6 @@ describe("TBPlusSDK tests on live", () => {
const sdk = new TBPlusSDK(
process.env.API_KEY as string,
process.env.API_SECRET as string,
"192.0.2.123",
);
const { data, error } = await sdk.createPayment(
{
Expand Down
Loading