polarity-integration-utils
    Preparing search index...

    Class PolarityRequest

    A utility class for making HTTP requests

    Index

    Constructors

    Properties

    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.

    postprocessRequestFailure: PostprocessRequestFailure = ...

    Method that can be implemented to post-process the HTTP response after a failed request. This method is typically used to inspect the error thrown and either alter the error object (e.g., to change the error message property to something more specific), to ignore the error (by not rethrowing it), or to take a specific action based on the error (e.g., in the case of a RetryRequestError you may want to retry the request or return a special payload to the integration front end).

    The error thrown during the request.

    The request options used for the request.

    The user options passed into the doLookup method.

    postprocessRequestSuccess: PostprocessRequestSuccess = ...

    Optional middleware method for modifying the HttpRequestResponse after a successful request. The passed in HttpRequestResponse object is not a copy but can be safely modified without side effects. The returned HttpRequestResponse object will be used for the response.

    The HTTP response from the request.

    The request options used for the request.

    The user options passed into the doLookup method.

    preprocessRequestOptions: PreprocessRequestOptions = ...

    Optional middleware method for modifying HttpRequestOptions before a request is made via the PolarityRequest.run method or PolarityRequest.runInParallel method. The returned requestOptions object will be used for the request. This method is passed a copy of the original requestOptions object so it can be modified without side effects.

    This method is typically used for adding authentication (e.g., auth headers, or basic auth) to every request. It can also be used to add headers that are required on every request or conditionally add headers based on the passed in userOptions.

    This method can be set as part of the PolarityRequestOptions when creating a new instance of the PolarityRequest class or can be set after the fact.

    A copy of the request options used for the request. This object can be modified without side effects.

    The user options passed into the doLookup method.

    The modified request options to use for the request.

    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

    Accessors

    Methods

    • 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. If the returnErrors property is set to true then the response objects will have their error property set to the thrown error.