How to use the @here/olp-sdk-dataservice-api.ArtifactApi.getArtifactUsingGET function in @here/olp-sdk-dataservice-api

To help you get started, we’ve selected a few @here/olp-sdk-dataservice-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heremaps / here-olp-sdk-typescript / @here / olp-sdk-dataservice-read / lib / client / ArtifactClient.ts View on Github external
public async getSchema(schemaRequest: SchemaRequest): Promise {
        const variant = schemaRequest.getVariant();
        if (!variant) {
            return Promise.reject(
                new Error(
                    `Please provide the schema variant by schemaRequest.withVariant()`
                )
            );
        }
        const request = await RequestFactory.create(
            "artifact",
            this.apiVersion,
            this.settings
        ).catch(error => Promise.reject(error));
        const response = await ArtifactApi.getArtifactUsingGET(request, {
            artifactHrn: variant.url
        }).catch(() => Promise.reject(`Cannot download schema bundle`));

        if (response.status === 200) {
            return response.arrayBuffer();
        }

        const messages: { [key: number]: string } = {
            401: "You are not authorized to view the schema",
            403: "Accessing the schema is forbidden",
            404: "The schema was not found",
            500: "Internal server error"
        };
        const message = response.statusText || messages[response.status];
        return Promise.reject(
            `Artifact Service error: HTTP ${response.status}: ${message}`