UNPKG

@selfcommunity/api-services

Version:
64 lines (57 loc) 2.36 kB
import { ReactionParams, SCPaginatedResponse } from '../../types'; import { SCReactionType } from '@selfcommunity/types'; import { AxiosRequestConfig } from 'axios'; export interface ReactionApiClientInterface { getAllReactions(params?: ReactionParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCReactionType>>; getSpecificReaction(id: number, config?: AxiosRequestConfig): Promise<SCReactionType>; } /** * Contains all the endpoints needed to manage features. */ export declare class ReactionApiClient { /** * This endpoint retrieves all reactions. * @param params * @param config */ static getAllReactions(params?: ReactionParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCReactionType>>; /** * This endpoint retrieves all reactions data without pagination. * @param params * @param config */ static getAllReactionsList(params?: ReactionParams, config?: AxiosRequestConfig): Promise<SCReactionType[]>; /** * This endpoint retrieves a specific reaction. * @param id * @param config */ static getSpecificReaction(id: number, config?: AxiosRequestConfig): Promise<SCReactionType>; } /** * :::tip Feature service can be used in the following way: ```jsx 1. Import the service from our library: import {ReactionService} from "@selfcommunity/api-services"; ``` ```jsx 2. Create a function and put the service inside it! The async function `getAllReactions` will return the list of reactions. async getAllReactions() { return await ReactionService.getAllReactions(); } ``` ```jsx If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type). 1. Declare it(or declare them, it is possible to add multiple params) const headers = headers: {Authorization: `Bearer ${yourToken}`} 2. Add it inside the brackets and pass it to the function, as shown in the previous example! ``` ::: */ export default class ReactionService { static getAllReactions(params?: ReactionParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCReactionType>>; static getAllReactionsList(params?: ReactionParams, config?: AxiosRequestConfig): Promise<SCReactionType[]>; static getSpecificReaction(id: number, config?: AxiosRequestConfig): Promise<SCReactionType>; }