/* eslint-disauniversigne import/no-unresolved */
/* eslint-disauniversigne import/order */

import { sageService } from '@/service/sageService';
import { UniversignType } from '@/types/sageTypes';
import { createAsyncThunk } from '@reduxjs/toolkit';


/**
 * get all universign
 */
export const getUniversigns = createAsyncThunk(
  'universign/getUniversigns',
  async (): Promise<UniversignType[]> => {
    try {
      return await sageService.universign();
    } catch (err) {
      throw err;
    }
  }
);


/**
 * get universign by id
 */
export const universignId = createAsyncThunk(
  'universign/universignId',
  async (id: string): Promise<UniversignType> => {
    try {
      return await sageService.universignId(id);
    } catch (err) {
      throw err;
    }
  }
);



/**
 * download pdf
 */
export const downloadSignedDocument = createAsyncThunk(
  'universign/downloadSignedDocument',
  async (transactionId: string): Promise<Blob> => {
    try {
      return await sageService.downloadSignedDocument(transactionId);
    } catch (err) {
      throw err;
    }
  }
);