UNPKG

@heroku/applink

Version:

Applink SDK for Heroku Apps.

60 lines (59 loc) 1.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataCloudApiImpl = void 0; const request_1 = require("../utils/request"); class DataCloudApiImpl { constructor(accessToken, domainUrl) { this.accessToken = accessToken; this.domainUrl = domainUrl; this.request = new request_1.HttpRequestUtil(); } async query(sql) { const url = `${this.domainUrl}/api/v2/query`; const opts = { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${this.accessToken}`, }, retry: { limit: 1, }, body: JSON.stringify({ sql }), }; const response = await this.request.request(url, opts); return response; } async queryNextBatch(nextBatchId) { const url = `${this.domainUrl}/api/v2/query/${nextBatchId}`; const opts = { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${this.accessToken}`, }, retry: { limit: 1, }, }; const response = await this.request.request(url, opts); return response; } async upsert(name, objectName, data) { const url = `${this.domainUrl}/api/v1/ingest/sources/${name}/${objectName}`; const opts = { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${this.accessToken}`, }, retry: { limit: 1, }, body: JSON.stringify(data), }; const response = await this.request.request(url, opts); return response; } } exports.DataCloudApiImpl = DataCloudApiImpl;