Skip to content

Commit dcefc84

Browse files
committed
v1.2.2
1 parent 1797baf commit dcefc84

File tree

4 files changed

+51
-7
lines changed

4 files changed

+51
-7
lines changed

package-lock.json

Lines changed: 40 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rantalainen/ytj-api-client",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "",
55
"main": "dist/index.js",
66
"scripts": {
@@ -28,6 +28,7 @@
2828
"access": "public"
2929
},
3030
"dependencies": {
31+
"axios-retry": "^4.0.0",
3132
"dayjs": "^1.11.10",
3233
"soap": "^1.0.0",
3334
"wsdl-tsclient": "^1.4.0"

src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import crypto from 'crypto';
33
import dayjs from 'dayjs';
44
import path from 'path';
55
import { HttpsApiTietopalveluYtjFiYritystiedotClient, createClientAsync } from './generated/httpsapitietopalveluytjfiyritystiedot';
6+
import axios from 'axios';
7+
import axiosRetry from 'axios-retry';
8+
9+
// Create global axios instance that has retry functionality and longer timeout
10+
const globalAxiosInstance = axios.create({ timeout: 60000 });
11+
axiosRetry(globalAxiosInstance, { retries: 3 });
612

713
export class YtjApiClient {
814
private options: YtjApiClientOptions;
@@ -44,7 +50,8 @@ export class YtjApiClient {
4450
async createSoapClient(): Promise<HttpsApiTietopalveluYtjFiYritystiedotClient> {
4551
try {
4652
const soapClient = await createClientAsync(
47-
path.resolve(__dirname, '..', 'resources', `https_api_tietopalvelu_ytj_fi_yritystiedot.wsdl`)
53+
path.resolve(__dirname, '..', 'resources', `https_api_tietopalvelu_ytj_fi_yritystiedot.wsdl`),
54+
{ request: globalAxiosInstance }
4855
);
4956

5057
// Add authBody to all function calls - every function needs authBody as argument

src/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export interface YtjApiClientOptions {
22
userId: string;
33
apiKey: string;
4-
timestamp: string;
4+
timestamp?: string;
55

66
ticket?: string;
77
apiBaseUrl?: string;

0 commit comments

Comments
 (0)