Advertisement
Fire_Ball_20001

Class

Aug 14th, 2022 (edited)
1,016
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { api } from 'config/api';
  2. import { globalConfig } from 'config/globalConfig';
  3. import { BaseActions } from 'modules/Global/actions/baseActions';
  4. import { BaseService } from 'modules/Global/services/baseService';
  5. import { CommonQuestionDto } from '../model/commonQuestionDto';
  6. import { CommonQuestionListDto } from '../model/commonQuestionListDto';
  7. import { CreateCommonQuestionDto } from '../model/createCommonQuestionDto';
  8. import QuestionStandart, { QuestionStandartDto, QuestionStandartType } from '../model/questionStandart';
  9.  
  10. export class StandartQuestionsActions extends BaseActions {
  11.     static DEFAULT_URL: string = `${globalConfig.api}/support-service/common-question/`;
  12.  
  13.     static async getQuestions(
  14.         sort?: string,
  15.     ): Promise<CommonQuestionListDto[]> {
  16.         try {
  17.             const data = await api
  18.                 .get<CommonQuestionListDto[]>(
  19.                     `${this.DEFAULT_URL}list`,
  20.                     { params: { sort } });
  21.             return data.data;
  22.         } catch (err) {
  23.             throw err;
  24.         }
  25.     }
  26.  
  27.     static async getQuestion(uuid: string): Promise<QuestionStandart | null> {
  28.         return BaseActions.MODEL_API_RESOURCE<QuestionStandartDto, QuestionStandart>({
  29.             url: `${uuid}`,
  30.             method: BaseService.GET_METHOD,
  31.             model: QuestionStandart,
  32.             modelType: QuestionStandartType,
  33.         });
  34.     }
  35.  
  36.     static createQuestion(question: CreateCommonQuestionDto) {
  37.         return api.post(`${this.DEFAULT_URL}create`, question);
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement