Options
All
  • Public
  • Public/Protected
  • All
Menu

ApiService provide functions for GET, POST, PUT and DELETE query

Usage:

const apiService = new ApiService('kalvad-poc'); // contact center name you want to connect to apiService.get(apiService.endpoints.authenticate) ; // ApiService already defined the endpoints available on Ziwo API .then( (e) => console.log('User > ', e.data)); // Request object is available under data;

Hierarchy

  • ApiService

Index

Constructors

constructor

  • new ApiService(contactCenterName: string): ApiService

Properties

Private Readonly API_PREFIX

API_PREFIX: "-api.aswat.co" = "-api.aswat.co"

Private Readonly API_PROTOCOL

API_PROTOCOL: "https://" = "https://"

Private Readonly baseUrl

baseUrl: string

Private Readonly contactCenterName

contactCenterName: string

Readonly endpoints

endpoints: any

Private Optional token

token: undefined | string

Methods

delete

  • Execute a DELETE query

    endpoint

    url endpoint. Base url should not be included

    Type parameters

    • T

    Parameters

    • endpoint: string

    Returns AsyncApiResult<T>

get

  • Execute a GET query

    endpoint

    url endpoint. Base url should not be included

    Type parameters

    • T

    Parameters

    • endpoint: string

    Returns AsyncApiResult<T>

getHostname

  • getHostname(): string

post

  • Execute a POST query

    endpoint

    url endpoint. Base url should not be included

    Type parameters

    • T

    Parameters

    • endpoint: string
    • payload: any

    Returns AsyncApiResult<T>

put

  • Execute a PUT query

    endpoint

    url endpoint. Base url should not be included

    Type parameters

    • T

    Parameters

    • endpoint: string
    • payload: any

    Returns AsyncApiResult<T>

Private query

  • query<T>(endpoint: string, method: "GET" | "POST" | "PUT" | "DELETE", payload?: any): Promise<ApiResult<T>>

setToken

  • setToken(token: string): void
  • Set Authorization token for further requests

    Parameters

    • token: string

    Returns void

Legend

  • Constructor
  • Property
  • Method
  • Private property
  • Private method
  • Static property
  • Static method
  • Property
  • Protected method

Generated using TypeDoc