Request
Constructor Summary
Public Constructor | ||
public |
constructor(name: string, params: object) |
Member Summary
Public Members | ||
public |
The endpoint schematic. |
|
public |
Which custom headers to be added to the request. |
|
public |
The request name (used to reference the endpoint). |
|
public |
The request parameters, used for the path, body etc... |
Method Summary
Public Methods | ||
public |
Adds a header to the Request. |
|
public |
addHeaders(headers: Object<string, string>): Request Adds multiple headers to the Request. |
|
public |
A parameter to add to the Request. |
|
public |
Adds multiple parameters to the Request. |
|
public |
build(): {method: string, path: string, query: string, body: string, headers: Object<string, string>} Returns an object containing all the final metadata about the request. |
|
public |
Gets the request body (serialised). |
|
public |
getHeaders(): Object<string, string> Gets the headers to be used when making the request. |
|
public |
Gets the request method (verb). |
|
public |
Gets the full pathname of the endpoint, plus any additional parameters or trailing slashes as defined in the endpoint schematic. |
|
public |
Gets the query string of the url. |
Public Constructors
Public Members
Public Methods
public addHeaders(headers: Object<string, string>): Request source
Adds multiple headers to the Request.
public addParams(params: Object<string, *>): Request source
Adds multiple parameters to the Request.
public build(): {method: string, path: string, query: string, body: string, headers: Object<string, string>} source
Returns an object containing all the final metadata about the request.
This return value is also the value used to pass through to the IRequestAdapter. It's intended to make it easy to write request adapters without having to implement the serialisation of requests per adapter.
public getBody(): string source
Gets the request body (serialised).
This method is in charge of serialising the request body in the correct format, as defined in the endpoint's
version value. Version 1 of the API uses x-www-form-urlencoded
, where as version 2 uses application/json
.
public getHeaders(): Object<string, string> source
Gets the headers to be used when making the request.
This method automatically adds headers like Content-Type
and X-PageProof-JavaScript-SDK
.
public getPath(): string source
Gets the full pathname of the endpoint, plus any additional parameters or trailing slashes as defined in the endpoint schematic.
public getQuery(): string source
Gets the query string of the url. This string is appended after the path.
This method is seperated from the Request.getPath method, as the authorization HMAC does not include the query parameter as part of it's calculation.
If there is no query string, this method always returns an empty string.