Skip to content

Commit 58016d3

Browse files
Create a new class for library constants (#1298)
1 parent 282caf9 commit 58016d3

File tree

5 files changed

+529
-211
lines changed

5 files changed

+529
-211
lines changed

src/client.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Config from "./config";
22
import HttpURLConnectionClient from "./httpClient/httpURLConnectionClient";
3-
import { version } from "../package.json";
43
import ClientInterface from "./httpClient/clientInterface";
54

65
type ClientParametersOverload =
@@ -38,8 +37,6 @@ class Client {
3837
public static MARKETPAY_HOP_API_VERSION = "v6";
3938
public static MARKETPAY_NOTIFICATION_API_VERSION = "v5";
4039
public static MARKETPAY_NOTIFICATION_CONFIGURATION_API_VERSION = "v6";
41-
public static LIB_NAME = "adyen-node-api-library";
42-
public static LIB_VERSION: string = version;
4340
public static TERMINAL_API_ENDPOINT_TEST = "https://terminal-api-test.adyen.com";
4441
public static TERMINAL_API_ENDPOINT_LIVE = "https://terminal-api-live.adyen.com";
4542

src/constants/libraryConstants.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { version } from "../../package.json";
2+
3+
class LibraryConstants {
4+
public static LIB_NAME = "adyen-node-api-library";
5+
public static LIB_VERSION: string = version;
6+
}
7+
8+
export default LibraryConstants;

src/httpClient/httpURLConnectionClient.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { HttpsProxyAgent } from "https-proxy-agent";
2323

2424
import * as fs from "fs";
2525
import { URL, URLSearchParams } from "url";
26-
import Client from "../client";
26+
import LibraryConstants from "../constants/libraryConstants";
2727
import Config from "../config";
2828
import HttpClientException from "./httpClientException";
2929

@@ -111,9 +111,9 @@ class HttpURLConnectionClient implements ClientInterface {
111111
}
112112

113113
requestOptions.headers[ApiConstants.ACCEPT_CHARSET] = HttpURLConnectionClient.CHARSET;
114-
requestOptions.headers[ApiConstants.USER_AGENT] = `${applicationName} ${Client.LIB_NAME}/${Client.LIB_VERSION}`;
115-
requestOptions.headers[ApiConstants.ADYEN_LIBRARY_NAME] = Client.LIB_NAME;
116-
requestOptions.headers[ApiConstants.ADYEN_LIBRARY_VERSION] = Client.LIB_VERSION;
114+
requestOptions.headers[ApiConstants.USER_AGENT] = `${applicationName} ${LibraryConstants.LIB_NAME}/${LibraryConstants.LIB_VERSION}`;
115+
requestOptions.headers[ApiConstants.ADYEN_LIBRARY_NAME] = LibraryConstants.LIB_NAME;
116+
requestOptions.headers[ApiConstants.ADYEN_LIBRARY_VERSION] = LibraryConstants.LIB_VERSION;
117117

118118
return httpsRequest(requestOptions);
119119
}

src/typings/applicationInfo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
// Generated using typescript-generator version 2.14.505 on 2019-06-11 10:28:22.
2121

22-
import Client from "../client";
22+
import LibraryConstants from "../constants/libraryConstants";
2323

2424
export class ApplicationInfo {
2525
adyenLibrary?: CommonField;
@@ -32,8 +32,8 @@ export class ApplicationInfo {
3232

3333
constructor() {
3434
this.adyenLibrary = {
35-
name: Client.LIB_NAME,
36-
version: Client.LIB_VERSION,
35+
name: LibraryConstants.LIB_NAME,
36+
version: LibraryConstants.LIB_VERSION,
3737
};
3838
}
3939
}

0 commit comments

Comments
 (0)