import {
  APIRequest,
  APIResponse,
  APIEncoder,
  APIDecoder
} from '@ucap-webmessenger/api';

export interface CheckUserInfoExRequest extends APIRequest {
  userId: string;
  companyCode: string;
  userSession: string;
}

export interface CheckUserInfoExResponse extends APIResponse {
  userId?: string;
}

export const encodeCheckUserInfoEx: APIEncoder<CheckUserInfoExRequest> = (
  req: CheckUserInfoExRequest
) => {
  return {
    p_user_id: req.userId,
    p_comp_code: req.companyCode,
    p_user_session: req.userSession
  };
};

export const decodeCheckUserInfoEx: APIDecoder<CheckUserInfoExResponse> = (
  res: any
) => {
  return {
    statusCode: res.StatusCode,
    errorMessage: res.ErrorMessage,
    userId: res.UserID
  } as CheckUserInfoExResponse;
};
