MCPcopy
hub / github.com/slackapi/node-slack-sdk / apiCall

Method apiCall

packages/web-api/src/WebClient.ts:140–163  ·  view source on GitHub ↗

* Generic method for calling a Web API method * * @param method the Web API method to call {@see https://api.slack.com/methods} * @param options options

(method: string, options?: WebAPICallOptions)

Source from the content-addressed store, hash-verified

138 * @param options options
139 */
140 public async apiCall(method: string, options?: WebAPICallOptions): Promise<WebAPICallResult> {
141 this.logger.debug('apiCall() start');
142
143 if (typeof options === 'string' || typeof options === 'number' || typeof options === 'boolean') {
144 throw new TypeError(`Expected an options argument but instead received a ${typeof options}`);
145 }
146
147 const response = await this.makeRequest(method, Object.assign(
148 { token: this.token },
149 options,
150 ));
151 const result = this.buildResult(response);
152
153 // log warnings in response metadata
154 if (result.response_metadata !== undefined && result.response_metadata.warnings !== undefined) {
155 result.response_metadata.warnings.forEach(this.logger.warn.bind(this.logger));
156 }
157
158 if (!result.ok) {
159 throw platformErrorFromResult(result as (WebAPICallResult & { error: string; }));
160 }
161
162 return result;
163 }
164
165 /**
166 * Iterate over the result pages of a cursor-paginated Web API method. This method can return two types of values,

Callers 4

generatePagesMethod · 0.95
proxy-test.jsFile · 0.80
WebClient.spec.jsFile · 0.80
RTMClientClass · 0.80

Calls 4

makeRequestMethod · 0.95
buildResultMethod · 0.95
platformErrorFromResultFunction · 0.90
debugMethod · 0.65

Tested by

no test coverage detected