All files / apis/wallet identification.api.ts

66.66% Statements 2/3
100% Branches 0/0
0% Functions 0/2
66.66% Lines 2/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 541x                     1x                                                                                    
import { WalletApi } from "./api";
import type { IdentificationBase, IdentificationResponse } from "./wallet.types";
 
/**
 * # Идентификация
 * [Документация QIWI] (https://developer.qiwi.com/ru/qiwi-wallet-personal/#identification)
 *
 * @export
 * @class WalletIdentificationApi
 * @extends {WalletApi}
 */
export class WalletIdentificationApi extends WalletApi {
  /**
   * # Идентификация пользователя
   *
   * Данный запрос позволяет отправить данные для идентификации
   * вашего QIWI кошелька.
   *
   * **Этот метод требует наличия валидного `walletId` (номера телефона привязанного к кошельку) в конфигурации API.**
   *
   * @param {IdentificationBase} data
   * @param {StringOrNumber} wallet
   * @return {Promise<IdentificationResponse>} {Promise<IdentificationResponse>}
   * @memberof WalletIdentificationApi
   */
  async set(data: IdentificationBase): Promise<IdentificationResponse> {
    // Тесты не могут покрыть этот метод. Он - деструктивный
    // Он не может быть вызван много раз
    /* istanbul ignore next */
    return await this.http.post(
      `identification/v1/persons/${this.walletId}/identification`,
      data
    );
  }
 
  /**
   * # Данные идентификации
   *
   * Данный запрос позволяет выгрузить маскированные данные и
   * статус идентификации своего QIWI кошелька.
   *
   * **Этот метод требует наличия валидного `walletId` (номера телефона привязанного к кошельку) в конфигурации API.**
   *
   * @param {StringOrNumber} wallet
   * @return {Promise<IdentificationResponse>} {Promise<IdentificationResponse>}
   * @memberof WalletIdentificationApi
   */
  async get(): Promise<IdentificationResponse> {
    return await this.http.get(
      `identification/v1/persons/${this.walletId}/identification`
    );
  }
}