Efficy SDK build around crm JSON web requests with endpoints such as "crm/query", "crm/global-search" and "crm/save". Each method immediatly invokes a request to the server and returns the received data object.

Hierarchy

  • CrmFetch
    • CrmApi

Constructors

Properties

crmEnv: CrmEnv = ...
fetchOptions: RequestInit = ...
name: string = "CrmFetch"
requestCounter: number = 0
sessionId?: string

Accessors

  • get lastResponseObject(): null | object
  • Returns null | object

  • get lastResponseStatus(): number
  • Returns number

Methods

  • Type Parameters

    • R

    Parameters

    Returns Promise<R>

  • Parameters

    • requestUrl: string
    • Optional requestPayload: ModulePostPayload
    • Optional requestOptions: RequestInit
    • isRetry: boolean = false

    Returns Promise<object>

  • Parameters

    Returns string

  • Parameters

    • method: "POST" | "GET"

    Returns void

  • Generate a list summary query

    Type Parameters

    • T = unknown

    Parameters

    Returns Promise<undefined | ListSummaryResponse<T>>

    Example

    const currencyPayload: ListSummaryPayload = {
    fields: ["crcyName", "crcyCode", "crcySymbol", "crcyCode", "crcyKey"],
    tableName: "Currency",
    query: [["crcyIsDisabled = 0"]]
    };
    const result = await crm.listSummary<Crcy>(currencyPayload);
    const euro = result?.list.find(item => item.crcyCode === "EUR")

    const companyPayload: ListSummaryPayload = {
    fields: ["compKey", "compName"],
    tableName: "Company",
    query: [["compArchived = 1", "compName like 'Efficy%'"]]
    };
  • Some operations cannot create their own session (e.g. systemClearCaches), hence this explicit logon

    Returns Promise<void>

  • Global elastic search in Efficy, with various filtering options

    Parameters

    Returns Promise<EntitySearch[]>

    Example

    const payload: GetSearchResultPayload = {
    identifier: "",
    search: {
    entities: ["cont"],
    value: searchedContact.toLocaleLowerCase(),
    offset: 0,
    quantity: 5,
    refinedOptions: {
    onlyItemsLinkedToMe: false
    }
    }
    }
    const searchResult: EntitySearch[] = await crm.searchGlobal(payload);
  • Returns void

  • Refresh the Crm server cache. Useful after modifying security or reference values. Requires an active session.

    Returns Promise<SystemClearCachesDataResponse>

    Example

    const crmApi = new CrmApi(crmEnv);
    await crmApi.logon(); // Makes sure there is an active session
    const result = await crmApi.clearServerCaches();
  • Get an optionally refresh the Crm reference cache. Requires an active session.

    Parameters

    • noCache: boolean

    Returns Promise<SystemCachesDataResponse>

    Example

    const crmApi = new CrmApi(crmEnv);
    await crmApi.logon(); // Makes sure there is an active session
    const references = await crmApi.systemReference(false);