Skip to content

Commit

Permalink
fix #9: updates for list mmethods
Browse files Browse the repository at this point in the history
  • Loading branch information
jfkz committed Feb 2, 2025
1 parent ef673c8 commit c0cc5fa
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ A Node.js SDK for Tinkoff Bank's Payment API.
## Version difference

- 0.x - old interface for Merchant provider, only CryptoPro is supported
- 1.x - updated interface for Merchant provider, support both CryptoPro and RSA signatures for request signatures
- 1.x and higher - updated interface for Merchant provider, support both CryptoPro and RSA signatures for request signatures

## Installation

Expand Down Expand Up @@ -102,7 +102,7 @@ ApiManagerInstance.initPayment({

## License (MIT)

Copyright (c) 2020 jfkz, Slava Fomin II
Copyright (c) 2020-2025 jfkz, Slava Fomin II

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions src/api-client/clients/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class ApiClient extends BaseClient {
super(options, apiClientDefaultOptions);
}

public async sendRequest<ResponsePayloadType extends ResponsePayload>(options: {
public async sendRequest<ResponsePayloadType extends object = ResponsePayload>(options: {
request: HttpRequest;
requestSchema: Schema;
responseSchema: Schema;
Expand Down Expand Up @@ -50,7 +50,7 @@ export class ApiClient extends BaseClient {
const { payload } = response;

// Throwing error in case if request failed
if (payload.ErrorCode !== '0') {
if ((payload as ResponsePayload).ErrorCode !== '0') {
throw new SdkError({ payload });
}

Expand Down
2 changes: 1 addition & 1 deletion src/api-client/clients/base-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export abstract class BaseClient extends Loggable {
this.options = Object.assign({}, defaultOptions, options);
}

public abstract sendRequest<ResponsePayloadType extends BaseResponsePayload>(options: {
public abstract sendRequest<ResponsePayloadType extends object = BaseResponsePayload>(options: {
request: HttpRequest;
requestSchema: Schema;
responseSchema: Schema;
Expand Down
4 changes: 2 additions & 2 deletions src/api-client/clients/merchant-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class MerchantClient extends BaseClient {
this.signProvider = signProvider;
}

public async sendRequest<ResponsePayloadType extends ResponsePayload>(options: {
public async sendRequest<ResponsePayloadType extends object = ResponsePayload>(options: {
request: HttpRequest;
requestSchema: Schema;
responseSchema: Schema;
Expand Down Expand Up @@ -67,7 +67,7 @@ export class MerchantClient extends BaseClient {
const { payload } = response;

// Throwing error in case if request failed
if (payload.ErrorCode !== '0') {
if ((payload as ResponsePayload).ErrorCode !== '0') {
throw new SdkError({ payload });
}

Expand Down
4 changes: 2 additions & 2 deletions src/api-client/clients/safedeal-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class SafeDealClient extends BaseClient {
super(options, safedealMerchantClientDefaultOptions);
}

public async sendRequest<ResponsePayloadType extends ResponsePayload>(options: {
public async sendRequest<ResponsePayloadType extends object = ResponsePayload>(options: {
request: HttpRequest;
requestSchema: Schema;
responseSchema: Schema;
Expand Down Expand Up @@ -53,7 +53,7 @@ export class SafeDealClient extends BaseClient {
const { payload } = response;

// Throwing error in case if request failed
if (payload.ErrorCode !== '0') {
if ((payload as ResponsePayload).ErrorCode !== '0') {
throw new SdkError({ payload });
}

Expand Down
5 changes: 1 addition & 4 deletions src/api-client/requests/get-card-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { SdkError } from '../..';
import { HttpRequestMethod } from '../../http-client/http-client';
import { Schema } from '../../serialization/schema';
import { BaseClient } from '../clients/base-client';
import { ResponsePayload as BaseResponsePayload } from '../response-payload';

export enum ECardStatus {
ACTIVE = 'A',
Expand Down Expand Up @@ -55,7 +54,7 @@ const getCardListRequestSchema: Schema = [];
// RESPONSE //
//==========//

export type GetCardListResponsePayload = BaseResponsePayload & ICardInfo[];
export type GetCardListResponsePayload = ICardInfo[];

/** TODO: Add verification to ICardInfo */
const getCardListResponseSchema: Schema = [];
Expand Down Expand Up @@ -97,7 +96,5 @@ export async function getCardList(options: {
if (typeof response.payload === 'string') {
response.payload = JSON.parse(response.payload);
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error incorrect typing
return response.payload;
}

0 comments on commit c0cc5fa

Please sign in to comment.