UNPKG

@iotize/tap

Version:

IoTize Device client for Javascript

49 lines (48 loc) 1.75 kB
import { BodyDecoder } from '@iotize/tap/client/api'; /** * @deprecated * Use TapResponse class instead... */ export interface ResponseInterface<DataType> { /** * Get decoded response content * Raw body is lazy converted, meaning the conversion is only done the first time. It's then store inside a * cache variable. See `setBody()` to unset or override the cached value. * @throws if response code is not a successful code or if there is no converter * @param decoder you can give a custom decoder to convert payload data (Uint8Aray) to the given type */ body<BodyType = DataType>(decoder?: BodyDecoder<BodyType>): BodyType; /** * You can overwrite body value. It will not be converted from raw body anymore * Use `setBody(undefined)` to remove body overwrite. It means that `BodyDecoder` instance will be used to * converter raw body into the givent type * @param body */ setBody(body: DataType | undefined): void; /** * Raw body (not converted) */ rawBody(): Uint8Array; hasBody(): boolean; /** * @deprecated use status instead */ codeRet(): number; status: number; toBytes(): Uint8Array; /** * Return tue if tap device returned a successful response code */ isSuccessful(): boolean; /** * Assert that request was successful * @throws DeviceResponseError if response was not successful */ successful(): void; /** * Specify the `BodyConver` used to decode raw body into the given type. * It is used by `body()` method. * @param converter */ setBodyDecoder(converter: BodyDecoder<DataType> | undefined): void; }