WebResource class

Creates a new WebResource object.

This class provides an abstraction over a REST call by being library / implementation agnostic and wrapping the necessary properties to initiate a request.

Constructors

WebResource(string, HttpMethods, any, {[key: string]: any}, {[key: string]: any} | HttpHeadersLike, boolean, boolean, AbortSignalLike, number, (progress: TransferProgressEvent) => void, (progress: TransferProgressEvent) => void, ProxySettings, boolean, AgentSettings, number)

Properties

abortSignal
agentSettings
body
formData
headers
keepAlive
method
onDownloadProgress

Callback which fires upon download progress.

onUploadProgress

Callback which fires upon upload progress.

operationResponseGetter

A function that returns the proper OperationResponse for the given OperationSpec and HttpOperationResponse combination. If this is undefined, then a simple status code lookup will be used.

operationSpec
proxySettings
query
redirectLimit
shouldDeserialize

Whether or not the HttpOperationResponse should be deserialized. If this is undefined, then the HttpOperationResponse should be deserialized.

streamResponseBody

Whether or not the body of the HttpOperationResponse should be treated as a stream.

timeout
url
withCredentials

Methods

clone()

Clone this WebResource HTTP request object.

prepare(RequestPrepareOptions)

Prepares the request.

validateRequestProperties()

Validates that the required properties such as method, url, headers["Content-Type"], headers["accept-language"] are defined. It will throw an error if one of the above mentioned properties are not defined.

Constructor Details

WebResource(string, HttpMethods, any, {[key: string]: any}, {[key: string]: any} | HttpHeadersLike, boolean, boolean, AbortSignalLike, number, (progress: TransferProgressEvent) => void, (progress: TransferProgressEvent) => void, ProxySettings, boolean, AgentSettings, number)

new WebResource(url?: string, method?: HttpMethods, body?: any, query?: {[key: string]: any}, headers?: {[key: string]: any} | HttpHeadersLike, streamResponseBody?: boolean, withCredentials?: boolean, abortSignal?: AbortSignalLike, timeout?: number, onUploadProgress?: (progress: TransferProgressEvent) => void, onDownloadProgress?: (progress: TransferProgressEvent) => void, proxySettings?: ProxySettings, keepAlive?: boolean, agentSettings?: AgentSettings, redirectLimit?: number)

Parameters

url

string

method
HttpMethods
body

any

query

{[key: string]: any}

headers

{[key: string]: any} | HttpHeadersLike

streamResponseBody

boolean

withCredentials

boolean

abortSignal
AbortSignalLike
timeout

number

onUploadProgress

(progress: TransferProgressEvent) => void

onDownloadProgress

(progress: TransferProgressEvent) => void

proxySettings
ProxySettings
keepAlive

boolean

agentSettings
AgentSettings
redirectLimit

number

Property Details

abortSignal

abortSignal?: AbortSignalLike

Property Value

agentSettings

agentSettings?: AgentSettings

Property Value

body

body?: any

Property Value

any

formData

formData?: any

Property Value

any

headers

headers: HttpHeadersLike

Property Value

keepAlive

keepAlive?: boolean

Property Value

boolean

method

method: HttpMethods

Property Value

onDownloadProgress

Callback which fires upon download progress.

onDownloadProgress?: (progress: TransferProgressEvent) => void

Property Value

(progress: TransferProgressEvent) => void

onUploadProgress

Callback which fires upon upload progress.

onUploadProgress?: (progress: TransferProgressEvent) => void

Property Value

(progress: TransferProgressEvent) => void

operationResponseGetter

A function that returns the proper OperationResponse for the given OperationSpec and HttpOperationResponse combination. If this is undefined, then a simple status code lookup will be used.

operationResponseGetter?: (operationSpec: OperationSpec, response: HttpOperationResponse) => undefined | OperationResponse

Property Value

(operationSpec: OperationSpec, response: HttpOperationResponse) => undefined | OperationResponse

operationSpec

operationSpec?: OperationSpec

Property Value

proxySettings

proxySettings?: ProxySettings

Property Value

query

query?: {[key: string]: any}

Property Value

{[key: string]: any}

redirectLimit

redirectLimit?: number

Property Value

number

shouldDeserialize

Whether or not the HttpOperationResponse should be deserialized. If this is undefined, then the HttpOperationResponse should be deserialized.

shouldDeserialize?: boolean | (response: HttpOperationResponse) => boolean

Property Value

boolean | (response: HttpOperationResponse) => boolean

streamResponseBody

Whether or not the body of the HttpOperationResponse should be treated as a stream.

streamResponseBody?: boolean

Property Value

boolean

timeout

timeout: number

Property Value

number

url

url: string

Property Value

string

withCredentials

withCredentials: boolean

Property Value

boolean

Method Details

clone()

Clone this WebResource HTTP request object.

function clone(): WebResource

Returns

The clone of this WebResource HTTP request object.

prepare(RequestPrepareOptions)

Prepares the request.

function prepare(options: RequestPrepareOptions): WebResource

Parameters

options
RequestPrepareOptions

Options to provide for preparing the request.

Returns

Returns the prepared WebResource (HTTP Request) object that needs to be given to the request pipeline.

validateRequestProperties()

Validates that the required properties such as method, url, headers["Content-Type"], headers["accept-language"] are defined. It will throw an error if one of the above mentioned properties are not defined.

function validateRequestProperties()