UNPKG

salesforce-alm

Version:

This package contains tools, and APIs, for an improved salesforce.com developer experience.

48 lines (46 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConnectExecutor = void 0; const core_1 = require("@salesforce/core"); /** * An executor which calls a connect api for the given org */ class ConnectExecutor { constructor(connectService, org) { this.connectService = connectService; this.org = org; } /** * Call the connect resource as defined by the given ConnectResource for the given org */ async callConnectApi() { return this.org .getConnection() .request(await this.fetchRequestInfo()) .then((result) => this.connectService.handleSuccess(result)) .catch((err) => this.connectService.handleError(err)); } async fetchRequestInfo() { const connectUrl = encodeURI(await this.connectService.fetchRelativeConnectUrl()); let method = this.connectService.getRequestMethod(); if (method === 'GET') { return { url: connectUrl, method, body: null, }; } else if (method === 'POST') { return { url: connectUrl, method, body: await this.connectService.fetchPostParams(), }; } else { throw new core_1.SfdxError(`Unsupported method is given: ${method}`, 'UNSUPPORTED_OPERATION'); } } } exports.ConnectExecutor = ConnectExecutor; //# sourceMappingURL=ConnectExecutor.js.map