# Interface BimCoreApiClient

Implementing this interface allows the developer to customize where the container and IFC data is loaded from.

interface BimCoreApiClient {
id: string;
layers: LayerApiClient;
mapBox: MapBoxApiClient;
get<T>(
absoluteOrRelativeUrl: string | URL,
converter: (r: Response) => TypedResponse<T>,
init?: RequestInit,
): Promise<TypedResponse<T>>;
getChanges<T extends BimChange = BimChange>(
parent: BimChange | BimContainer | URL,
query: BimChangeIdQuery<T> | BimChangeMetadataQuery<T>,
): Promise<TypedResponse<T[]>>;
getContainers(id?: string): Promise<BimContainer[]>;
getIfcChanges(
parent: BimChange | BimContainer | URL,
): Promise<BimChangeIfc[]>;
}

#### Hierarchy (View Summary)

- BimCoreApiClient
  - TwinfinityApiClient

##### Index

### Properties

id
layers
mapBox

### Methods

get
getChanges
getContainers
getIfcChanges

## Properties

### `Readonly` id

id: string

Uniquely identifies the backend the client connects to. If the client connects to a REST API its probably the host name of the API.

### `Readonly` layers

layers: LayerApiClient

API to handle layer functionality. A Layer is a way to enrich an existing change in the database with extra data. This data will be versioned separately from the change the layer is attached to.

### `Readonly` mapBox

mapBox: MapBoxApiClient

API to access MapBox functionality.

## Methods

### get

- get<T>(
  absoluteOrRelativeUrl: string | URL,
  converter: (r: Response) => TypedResponse<T>,
  init?: RequestInit,
  ): Promise<TypedResponse<T>>

  Issues an HTTP GET specified url.

  #### Type Parameters

  - T

    The type of data the specified converter will convert the HTTP response body to.

  #### Parameters

  - absoluteOrRelativeUrl: string | URL

    Url to issue HTTP GET to.

  - converter: (r: Response) => TypedResponse<T>

    Converter for response. See HttpResponseType for predefined converters.

  - `Optional` init: RequestInit

    Optional settings for to HTTP GET (fetch).

  #### Returns Promise<TypedResponse<T>>

  a TypedResponse containing the status code and the response value that resulted from using the specified converter.

  #### Example

      // Gets a JSON object and convert it to the MyObj interface.
      const myObjResponse = this.get<MyObj>("http://foo.com/jsonendpoint", HttpResponseType.json)
      const myObj = myObjResponse.status === 200 ? (await myObjResponse.value) : undefined;
      // Gets a binary ArrayBuffer.
      const myArrayBufferResponse = this.get("http://foo.com/jsonendpoint", HttpResponseType.arrayBuffer)
      const myArrayBuffer = myArrayBufferResponse.status === 200 ? (await myArrayBufferResponse.value) : undefined;

### getChanges

- getChanges<T extends BimChange = BimChange>(
  parent: BimChange | BimContainer | URL,
  query: BimChangeIdQuery<T> | BimChangeMetadataQuery<T>,
  ): Promise<TypedResponse<T[]>>

  Retrieves all changes in and below a specified parent change and that matches a specific query. Use typescript type inference cast directly to a specific BimChange type if you know exactly which types the query will return

  #### Type Parameters

  - T extends BimChange = BimChange

  #### Parameters

  - parent: BimChange | BimContainer | URL

    Parent to get changes from.

  - query: BimChangeIdQuery<T> | BimChangeMetadataQuery<T>

    example: `ifc.status=processed`, `dwg.status=processed` or `_system.layers.format=sensors`

  #### Returns Promise<TypedResponse<T[]>>

  Changes in container that matched the filterQuery.

  #### Example: type inference by specifying return type.

      const dwgChanges: BimChangeDwg[] = api.getChanges(container, {query: "dwg.status=Processed"});

  #### Example: Predefined queries. Type is included in query so no need to specify on return value.

      const ifcFailures = api.getChanges(container, PredefinedBimChangeMetadataQuery.ifc(BimChangeStatus.Failed));

  #### Remarks

  It is expensive to get all changes in a container. Use a `query` to filter out only the changes you are interested in. Getting everything is discouraged as there can be 100k+ `changes` in a `container`. Be specific. As it is expensive DO NOT use this method to get the `changes` for many/all `containers` in the system. There can be many `containers` and many `changes` (like 100k+) in each `container`.

### getContainers

- getContainers(id?: string): Promise<BimContainer[]>

  Gets all containers (and workspaces) or just a specific one.

  #### Parameters

  - `Optional` id: string

    If given, only container with specific id is returned. Otherwise all containers are returned.

  #### Returns Promise<BimContainer[]>

  List of containers. May be empty if no containers were found or matched the specified id.

### getIfcChanges

- getIfcChanges(parent: BimChange | BimContainer | URL): Promise<BimChangeIfc[]>

  Retrieves all (successfully processed) IFC changes located in and below a specified parent.

  #### Parameters

  - parent: BimChange | BimContainer | URL

    Parent change to get IFC changes from.

  #### Returns Promise<BimChangeIfc[]>

  All successfully processed IFC changes in the specified container.

  #### Remarks

  As it is expensive DO NOT use this method to get the IFC `changes` for many/all `containers` in the system. It is however reasonable to use this method to get the `changes` for a few specific containers.