Options
All
  • Public
  • Public/Protected
  • All
Menu

Defines a connection to a Salesforce org.

Hierarchy

  • SalesforceConnection

Index

Properties

consumerKey: string

The consumer key of the Connected App used to connect.

orgUrl: string

The URL of the connected Salesforce org.

Methods

  • disconnect(): Promise<void>
  • Closes the connection with the currently connected Salesforce org. Stored auth keys are expired and removed.

    Returns Promise<void>

  • Executes a custom REST API request to the specified endpoint.

    Typically, every Salesforce REST API data endpoint must include the REST API version that is being requested. However, when calling the executeApiRequest function you can either explicitly set the REST API version to call or simply use "vXX.X" to default to the REST API version set by the API.

    For POST/PATCH requests, Content-Type header is set to "application/json" by default and so data parameter can simply be set to an object.

    Note: depending on which REST API endpoint you attempt to request, you may need to add additional OAuth scopes to your Connected App.

    throws

    ConnectionError Thrown if the connection object is no longer valid, for example if the session has been disconnected.

    throws

    ParameterError Thrown if invalid function parameter values are detected.

    throws

    RestApiError Thrown if an error occurs calling the Salesforce REST API.

    Type parameters

    Parameters

    • apiEndpoint: string

      The relative Salesforce REST API endpoint being requested (e.g. /services/data/vXX.X/sobjects/Contact).

    • Optional httpMethod: HttpMethod

      The HTTP Method to use when making the request (defaults to GET).

    • Optional data: any

      Optional data to pass with the request (for POST/PATCH requests).

    • Optional headers: any

      Optional headers to include with the request. Important: do not attempt to set the Authorization header manually as the API will include it automatically (as long as includeAuthorization is not set to false).

    • Optional includeAuthorization: boolean

      Whether the Authorization header will be added automatically. Set this to false when making requests to endpoints that do not expect an Authorization header, such as the OAuth endpoints.

    Returns Promise<SalesforceRestApiResult<T>>

    A {@link SalesforceRestApiResponse response} object containing the status code and response data (if provided). The data is expected to be of the given generic type, but this is not enforced.

  • Retrieves the connection’s auth tokens from local storage.

    Returns AuthTokenSet

    An object containing the access and refresh tokens.

Generated using TypeDoc