polarity-integration-utils
    Preparing search index...

    Class PolarityRequest

    A utility class for making HTTP requests

    Index
    hooks: Required<PolarityRequestHooks> = ...

    Lifecycle hooks for customizing request behavior. Hooks are configured via the PolarityRequestOptions.hooks property when creating a new instance of the PolarityRequest class.

    PolarityRequestHooks for hook type details.

    httpResponseErrorMessageProperties: string[] = []

    One or more HTTP response properties specified using JSON dot notation that point to an error message that should be displayed to the user in the event of an API error.

    The property should be a string value. If the property does not exist or is not a string value, a default error message will be used instead.

    httpResponseErrorProperties: string[] = []

    One or more HTTP response properties specified using JSON dot notation. If the specified path exists within the body property of the HTTP Response, an ApiRequestError will be thrown.

    By default, this value is an empty array and response properties are not used to detect errors.

    []
    
    isApiError: IsApiErrorFunction = null

    Optional method that can be implemented to determine if an API error was encountered after an HTTP request is made.

    If the isApiError method is implemented the property roundedSuccessStatusCodes and httpResponseErrorProperties are not used to determine API errors.

    An object indicating whether an API error was encountered and an optional message.

    limiter: PolarityRequestLimiter = null

    An optional rate limiter instance used to throttle HTTP requests. When set, all requests made via PolarityRequest.run are scheduled through this limiter. Typically provided by the Polarity server via the integration context.

    network: NetworkContext = null

    Per-integration network configuration from context.network.

    When set, proxy and TLS settings are applied dynamically on each PolarityRequest.run call, overriding any static values from the constructor defaults. Set this before each run() call to reflect the latest runtime config.

    polarityRequest.network = context.network;
    const response = await polarityRequest.run(requestOptions);
    requestOptionsToSanitize: string[] = []

    An array of JSON dot notation paths to omit from the request options when logging.

    This property can be used to sanitize sensitive request properties that should not appear in logging.

    Note that the requestOptions object is automatically sanitized to remove properties that typically contain sensitive API key and passwords. For a list of properties that are automatically sanitized, see the sanitizeRequestOptions method.

    roundedSuccessStatusCodes: number[] = ...
    userOptions: DoLookupUserOptions = null
    • Runs multiple requests in parallel with a limit on the maximum number of concurrent requests.

      When running multiple request at once it is often useful to be able to tie a specific request back to the entity the request is for. To support this, the HttpRequestOptions object accepts an optional entity property which can be assigned to the Entity the request is being made for. The HttpRequestResponse object returned by this method will include the same entity property making it easy to match the response to the entity.

      Alternatively, for requests that are made for multiple entities at once (e.g., a query that can search multiple entities at a time), the HttpRequestOptions object also has an entities property which accept an array of entity objects. Similar to the entity, the entities property will be set on the HttpRequestResponse object.

      Finally, if you are looking to pass through a custom request id you can do that using the requestId property.

      Parameters

      Returns Promise<HttpRequestResponse[]>

      A promise that resolves to an array of responses in the same order as the input request options. If the returnErrors property is set to true, the response objects will have their error property set to the thrown error. If onNetworkError hooks are configured and suppress an error (return without throwing), the corresponding entry will be undefined.