Hierarchy

  • NetworkClient
    • EventBusClient

Constructors

Methods

  • Parameters

    • error: HttpError

    Returns StackspotAPIError

  • Makes a request (same signature as globalThis.fetch). This request will prepend the base url to the url and, if there's an active session, include authentication headers.

    Parameters

    • input: string | URL | Request

      the url or request object.

    • Optionalinit: RequestInit

      the fetch options.

    Returns Promise<Response>

    a promise with the Response.

  • Checks whether or not the current account is freemium.

    Returns boolean

    true if it's a freemium account, false otherwise.

  • Verifies if the current user is allowed to send the given request.

    Parameters

    • method: HTTPMethod

      the request's method.

    • path: string

      the path to the resource.

    • Optionalbody: string | object

      the request's body.

    Returns Promise<boolean>

    a promise that resolves to true if it's allowed or false otherwise.

  • Builds a URL with the baseUrl of this network client and the path passed as parameter.

    Parameters

    • path: string

      the path to the resource.

    Returns URL

    a full URL.

  • Reads an EventSource from the endpoint. Differently than the original specification, this allows common HTTP requests with method and body to be made.

    Parameters

    • input: string | URL | Request

      the url or request object.

    • Optionalinit: RequestInit

      the fetch options.

    Returns Promise<FetchEventStream>

    a promise with a FetchEventStream, which is an AsyncGenerator.

    let events = this.stream('url', options)
    for await (let event of events) {
    console.log('<<', event.data)
    }
  • Sets up all network clients. Must be called before attempting to make any request.

    Parameters

    • sessionManager: SessionManager

      An object with functions capable of checking, retrieving and ending the current session.

    • env: Env

      The environment to send the requests to.

    Returns void