Add sendOperationRequest() and remove OperationSpec from sendRequest()

This commit is contained in:
Dan Schulte 2018-05-15 12:16:02 -07:00
Родитель 3fd5f366ce
Коммит 9044297181
1 изменённых файлов: 13 добавлений и 7 удалений

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

@ -121,10 +121,9 @@ export class ServiceClient {
}
/**
* Send the provided httpRequest. If an operationSpec value is provided, then the httpRequest will
* be populated by the values provided in the operationSpec.
* Send the provided httpRequest.
*/
async sendRequest(options: RequestPrepareOptions | WebResource, operationSpec?: OperationSpec): Promise<HttpOperationResponse> {
async sendRequest(options: RequestPrepareOptions | WebResource): Promise<HttpOperationResponse> {
if (options === null || options === undefined || typeof options !== "object") {
throw new Error("options cannot be null or undefined and it must be of type object.");
}
@ -142,10 +141,6 @@ export class ServiceClient {
return Promise.reject(error);
}
if (operationSpec) {
httpRequest.method = operationSpec.httpMethod;
}
// send request
let operationResponse: HttpOperationResponse;
try {
@ -161,6 +156,17 @@ export class ServiceClient {
}
return Promise.resolve(operationResponse);
}
/**
* Send an HTTP request that is populated using the provided OperationSpec.
* @param {WebResource} httpRequest - The HTTP request to populate and then to send.
* @param {operationSpec} operationSpec - The OperationSpec to use to populate the httpRequest.
*/
async sendOperationRequest(httpRequest: WebResource, operationSpec: OperationSpec): Promise<HttpOperationResponse> {
httpRequest.method = operationSpec.httpMethod;
return this.sendRequest(httpRequest);
}
}
function createDefaultRequestPolicyCreators(credentials: ServiceClientCredentials | undefined, options: ServiceClientOptions, userAgentInfo: string[]): RequestPolicyCreator[] {