A class that handles HTTP transport operations with caching, rate limiting, and authentication capabilities.

Transport

get - Performs GET requests with optional caching

post - Performs POST requests

patch - Performs PATCH requests with primary key handling

put - Performs PUT requests with primary key handling

delete - Performs DELETE requests with primary key handling

cu - Performs codeunit requests

batch - Executes multiple requests in parallel or sequentially

filter - Creates OData filter query strings

clearCache - Clears cache for specific endpoint

clearAllCaches - Clears all cached data

const transport = new Transport(config, authHandler);

// GET request with caching
const data = await transport.get<UserData>('/users', { id: 1 }, { useCache: true });

// POST request
const newUser = await transport.post<UserData>('/users', { name: 'John' });

// Batch request
const results = await transport.batch<UserData>([
{ method: 'GET', url: '/users/1' },
{ method: 'GET', url: '/users/2' }
]);

When a request fails

When rate limit is exceeded

When request times out

Constructors

Methods

  • Parameters

    • middleware: (
          config: AxiosRequestConfig,
      ) => AxiosRequestConfig<any> | Promise<AxiosRequestConfig<any>>

    Returns void

  • Clear cache for specific key

    Parameters

    • endpoint: string

      this is the endpoint specified in the get request i.e transport.get(endpoind)

    • params: Record<string, any>

      params passed as the second option argument to a get request i.e transport.get(_, params)

    • Optionaloptions: RequestOptions

      additional options , always useful when want to specify company that was use to get the request explicitly, if not specified, the defaul company is used. If the environment config variable BC_COMPANY_USE was set to Url-Complete this third argument is not useful.

    Returns void

    transport.clearCache('/api/publisher/api-group/v2.0/customers', {'$filter': 'customerNo eq `0000021`'}, {company: 'xyz'});
    
  • Makes a POST request to a codeunit endpoint with optional payload and request options

    Type Parameters

    • T

      The expected response type

    Parameters

    • codeunit: string

      The codeunit endpoint URL

    • Optionalpayload: any

      Optional request payload/body data

    • Optionaloptions: RequestOptions

      Optional request configuration options

    Returns Promise<T>

    Promise that resolves with the response data

    When the request fails with status code 500

  • Type Parameters

    • T

    Parameters

    • endpoint: string
    • Optionalpayload: any
    • Optionaloptions: RequestOptions

    Returns Promise<T>

  • Creates an OData filter query string from the provided parameters

    Parameters

    • params: Record<string, any>

      An object containing key-value pairs to be converted into filter conditions

    Returns undefined | object

    An object with the '$filter' property containing the generated OData filter string, or undefined if no valid parameters

    When there is an error preparing the BC 365 filter query

    • Handles different value types and formats them appropriately for OData filtering
    • Special handling for date strings vs regular strings
    • Combines multiple conditions with 'and' operator
    • Empty or falsy values are skipped
    filter({ name: "John", age: 30 })
    // Returns: { $filter: "name eq 'John' and age eq 30" }
  • Type Parameters

    • T

    Parameters

    • endpoint: string
    • OptionalqueryParams: Record<string, any>
    • Optionaloptions: RequestOptions

    Returns Promise<T>

  • Type Parameters

    • T

    Parameters

    • endpoint: string
    • Optionalpayload: any
    • Optionaloptions: RequestOptions

    Returns Promise<T>

  • Type Parameters

    • T

    Parameters

    • endpoint: string
    • Optionalpayload: any
    • Optionaloptions: RequestOptions

    Returns Promise<T>

  • Type Parameters

    • T

    Parameters

    • endpoint: string
    • Optionalpayload: any
    • Optionaloptions: RequestOptions

    Returns Promise<T>