| /** |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| |
| /* |
| * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| * https://openapi-generator.tech |
| * Do not edit the class manually. |
| */ |
| |
| /* tslint:disable:no-unused-variable member-ordering */ |
| |
| import { Inject, Injectable, Optional } from '@angular/core'; |
| import { HttpClient, HttpHeaders, HttpParams, |
| HttpResponse, HttpEvent, HttpContext |
| } from '@angular/common/http'; |
| import { Observable } from 'rxjs'; |
| import { OpenApiHttpParams, QueryParamStyle } from '../query.params'; |
| |
| // @ts-ignore |
| import { BatchRequest } from '../model/batchRequest'; |
| // @ts-ignore |
| import { BatchResponse } from '../model/batchResponse'; |
| |
| // @ts-ignore |
| import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; |
| import { Configuration } from '../configuration'; |
| import { BaseService } from '../api.base.service'; |
| |
| |
| |
| @Injectable({ |
| providedIn: 'root' |
| }) |
| export class BatchAPIService extends BaseService { |
| |
| constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: Configuration) { |
| super(basePath, configuration); |
| } |
| |
| /** |
| * Batch requests in a single transaction |
| * The Apache Fineract Batch API is also capable of executing all the requests in a single transaction, by setting a Query Parameter, \"enclosingTransaction=true\". So, if one or more of the requests in a batch returns an erroneous response all of the Data base transactions made by other successful requests will be rolled back. If there has been a rollback in a transaction then a single response will be provided, with a \'400\' status code and a body consisting of the error details of the first failed request. |
| * @endpoint post /v1/batches |
| * @param batchRequest |
| * @param enclosingTransaction enclosingTransaction |
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. |
| * @param reportProgress flag to report request and response progress. |
| * @param options additional options |
| */ |
| public postBatches(batchRequest: Array<BatchRequest>, enclosingTransaction?: boolean, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Array<BatchResponse>>; |
| public postBatches(batchRequest: Array<BatchRequest>, enclosingTransaction?: boolean, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Array<BatchResponse>>>; |
| public postBatches(batchRequest: Array<BatchRequest>, enclosingTransaction?: boolean, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Array<BatchResponse>>>; |
| public postBatches(batchRequest: Array<BatchRequest>, enclosingTransaction?: boolean, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> { |
| if (batchRequest === null || batchRequest === undefined) { |
| throw new Error('Required parameter batchRequest was null or undefined when calling postBatches.'); |
| } |
| |
| let localVarQueryParameters = new OpenApiHttpParams(this.encoder); |
| |
| localVarQueryParameters = this.addToHttpParams( |
| localVarQueryParameters, |
| 'enclosingTransaction', |
| <any>enclosingTransaction, |
| QueryParamStyle.Form, |
| true, |
| ); |
| |
| |
| let localVarHeaders = this.defaultHeaders; |
| |
| // authentication (basicAuth) required |
| localVarHeaders = this.configuration.addCredentialToHeaders('basicAuth', 'Authorization', localVarHeaders, 'Basic '); |
| |
| // authentication (tenantid) required |
| localVarHeaders = this.configuration.addCredentialToHeaders('tenantid', 'fineract-platform-tenantid', localVarHeaders); |
| |
| const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ |
| 'application/json' |
| ]); |
| if (localVarHttpHeaderAcceptSelected !== undefined) { |
| localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); |
| } |
| |
| const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); |
| |
| const localVarTransferCache: boolean = options?.transferCache ?? true; |
| |
| |
| // to determine the Content-Type header |
| const consumes: string[] = [ |
| 'application/json' |
| ]; |
| const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); |
| if (httpContentTypeSelected !== undefined) { |
| localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); |
| } |
| |
| let responseType_: 'text' | 'json' | 'blob' = 'json'; |
| if (localVarHttpHeaderAcceptSelected) { |
| if (localVarHttpHeaderAcceptSelected.startsWith('text')) { |
| responseType_ = 'text'; |
| } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { |
| responseType_ = 'json'; |
| } else { |
| responseType_ = 'blob'; |
| } |
| } |
| |
| let localVarPath = `/v1/batches`; |
| const { basePath, withCredentials } = this.configuration; |
| return this.httpClient.request<Array<BatchResponse>>('post', `${basePath}${localVarPath}`, |
| { |
| context: localVarHttpContext, |
| body: batchRequest, |
| params: localVarQueryParameters.toHttpParams(), |
| responseType: <any>responseType_, |
| ...(withCredentials ? { withCredentials } : {}), |
| headers: localVarHeaders, |
| observe: observe, |
| ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), |
| reportProgress: reportProgress |
| } |
| ); |
| } |
| |
| } |