|
22 | 22 | import * as NodeFormData from 'form-data' |
23 | 23 | import 'isomorphic-fetch' |
24 | 24 | import * as objectAssign from 'object-assign' |
25 | | -import * as stream from 'stream' |
| 25 | +import {Readable} from 'stream' |
26 | 26 | import {INTERNAL_PREFIX} from 'workfront-api-constants' |
27 | 27 |
|
28 | | -export type THttpParams = any |
29 | 28 | export interface IHttpOptions { |
30 | 29 | path?: string |
31 | 30 | method?: string |
@@ -56,9 +55,7 @@ export class Api { |
56 | 55 | DELETE: 'DELETE', |
57 | 56 | POST: 'POST' |
58 | 57 | } |
59 | | - |
60 | 58 | _httpOptions: IHttpOptions |
61 | | - _httpParams: THttpParams = {} |
62 | 59 |
|
63 | 60 | constructor(config) { |
64 | 61 | this._httpOptions = { |
@@ -350,8 +347,8 @@ export class Api { |
350 | 347 | * @param {String} [method=GET] The method which the request will do (GET|POST|PUT|DELETE) |
351 | 348 | * @return {Promise} A promise which will resolved with results if everything went ok and rejected otherwise |
352 | 349 | */ |
353 | | - request(path: string, params: THttpParams, fields?: TFields, method: string = Api.Methods.GET): Promise<any> { |
354 | | - const clonedParams = objectAssign({}, params || {}, this._httpParams) |
| 350 | + request(path: string, params, fields?: TFields, method: string = Api.Methods.GET): Promise<any> { |
| 351 | + const clonedParams = objectAssign({}, params) |
355 | 352 |
|
356 | 353 | const alwaysUseGet = this._httpOptions.alwaysUseGet |
357 | 354 |
|
@@ -388,8 +385,8 @@ export class Api { |
388 | 385 | } |
389 | 386 |
|
390 | 387 | let bodyParams = null, queryString = '' |
391 | | - if (NodeFormData && clonedParams instanceof NodeFormData) { |
392 | | - bodyParams = clonedParams |
| 388 | + if (NodeFormData && params instanceof NodeFormData) { |
| 389 | + bodyParams = params |
393 | 390 | } |
394 | 391 | else if (GlobalScope.FormData && clonedParams instanceof GlobalScope.FormData) { |
395 | 392 | bodyParams = clonedParams |
@@ -480,7 +477,7 @@ export class Api { |
480 | 477 | * @param {fs.ReadStream} stream A readable stream with file contents |
481 | 478 | * @param {String} filename Override the filename |
482 | 479 | */ |
483 | | - uploadFromStream(stream: stream.Readable, filename: string) { |
| 480 | + uploadFromStream(stream: Readable, filename: string) { |
484 | 481 | const data = new NodeFormData() |
485 | 482 | data.append('uploadedFile', stream, filename) |
486 | 483 | return this.request('upload', data, null, Api.Methods.POST) |
|
0 commit comments