Rename bodyAsJson to parsedBody

This commit is contained in:
Rikki Gibson 2018-04-02 16:57:42 -07:00
Родитель aa8fd5c108
Коммит 4df2d14009
3 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -171,8 +171,8 @@ export class RPRegistrationFilter extends BaseFilter {
} catch (err) {
return Promise.reject(err);
}
const obj = (res.bodyAsJson as any);
if (res.bodyAsJson && obj.registrationState && obj.registrationState === "Registered") {
const obj = (res.parsedBody as any);
if (res.parsedBody && obj.registrationState && obj.registrationState === "Registered") {
result = true;
} else {
setTimeout(() => { return this.getRegistrationStatus(url, originalRequest); }, retryTimeout * 1000);

Просмотреть файл

@ -5,7 +5,7 @@ import { WebResource } from "./webResource";
/**
* Wrapper object for http request and response. Deserialized object is stored in
* the `bodyAsJson` property when the response body is received in JSON.
* the `parsedBody` property when the response body is received in JSON or XML.
* @class
* Initializes a new instance of the HttpOperationResponse class.
* @constructor
@ -27,7 +27,7 @@ export class HttpOperationResponse {
/**
* The response body as parsed JSON or XML
*/
bodyAsJson?: { [key: string]: any } | Array<any> | string | number | boolean | null | void;
parsedBody?: { [key: string]: any } | Array<any> | string | number | boolean | null | void;
constructor(request: WebResource, response: Response) {
/**
@ -45,6 +45,6 @@ export class HttpOperationResponse {
this.response = response;
/* tslint:disable:no-null-keyword */
this.bodyAsText = null;
this.bodyAsJson = null;
this.parsedBody = null;
}
}

Просмотреть файл

@ -253,7 +253,7 @@ export function promiseToServiceCallback<T>(promise: Promise<HttpOperationRespon
}
return (cb: ServiceCallback<T>): void => {
promise.then((data: HttpOperationResponse) => {
process.nextTick(cb, undefined, data.bodyAsJson as T, data.request, data.response);
process.nextTick(cb, undefined, data.parsedBody as T, data.request, data.response);
}, (err: Error) => {
process.nextTick(cb, err);
});
@ -356,9 +356,9 @@ export async function dispatchRequest(options: WebResource): Promise<HttpOperati
});
});
operationResponse.bodyAsJson = await parseString;
operationResponse.parsedBody = await parseString;
} else {
operationResponse.bodyAsJson = JSON.parse(operationResponse.bodyAsText);
operationResponse.parsedBody = JSON.parse(operationResponse.bodyAsText);
}
}
} catch (err) {