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


import { sageService } from '@/service/sageService';
import { Gateways, GatewaysRequest, GatewaysResponse } from '@/types/gateways';
import { Societe } from '@/types/societeType';
import { createAsyncThunk } from '@reduxjs/toolkit';


/**
 * get societe
 */
export const getSociete = createAsyncThunk(
  'gateways/getSociete',
  async (): Promise<Societe> => {
    try {
      return await sageService.getSociete();
    } catch (err) {
      throw err;
    }
  }
);


/**
 * get all gateways
 */
export const getGateways = createAsyncThunk(
  'gateways/getGateways',
  async (): Promise<GatewaysResponse> => {
    try {
      return await sageService.getGateways();
    } catch (err) {
      throw err;
    }
  }
);




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



/**
 * add gateways
 */
export const addGateways = createAsyncThunk(
  'gateways/addGateways',
  async (data: GatewaysRequest): Promise<Gateways> => {
    try {
      return await sageService.addGateways(data);
    } catch (err) {
      throw err;
    }
  }
);
