/** * Lethean Blockchain API * * * * 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, HttpParameterCodec, HttpContext } from '@angular/common/http'; import { CustomHttpParameterCodec } from '../encoder'; import { Observable } from 'rxjs'; // @ts-ignore import { BlockDetailsModel } from '../model/blockDetailsModel'; // @ts-ignore import { BlockTemplateModel } from '../model/blockTemplateModel'; // @ts-ignore import { BlockTemplateRequestModel } from '../model/blockTemplateRequestModel'; // @ts-ignore import { HeightModel } from '../model/heightModel'; // @ts-ignore import { SubmitBlockRequestModel } from '../model/submitBlockRequestModel'; // @ts-ignore import { SubmitBlockResponseModel } from '../model/submitBlockResponseModel'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { lthnConfiguration } from '../configuration'; import { BaseService } from '../api.base.service'; @Injectable({ providedIn: 'root' }) export class BlockService extends BaseService { constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: lthnConfiguration) { super(basePath, configuration); } /** * Create a block template for mining * @param blockTemplateRequestModel * @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. */ public createBlockTemplate(blockTemplateRequestModel: BlockTemplateRequestModel, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; public createBlockTemplate(blockTemplateRequestModel: BlockTemplateRequestModel, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public createBlockTemplate(blockTemplateRequestModel: BlockTemplateRequestModel, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public createBlockTemplate(blockTemplateRequestModel: BlockTemplateRequestModel, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (blockTemplateRequestModel === null || blockTemplateRequestModel === undefined) { throw new Error('Required parameter blockTemplateRequestModel was null or undefined when calling createBlockTemplate.'); } let localVarHeaders = this.defaultHeaders; 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 = `/block/template`; const { basePath, withCredentials } = this.configuration; return this.httpClient.request('post', `${basePath}${localVarPath}`, { context: localVarHttpContext, body: blockTemplateRequestModel, responseType: responseType_, ...(withCredentials ? { withCredentials } : {}), headers: localVarHeaders, observe: observe, transferCache: localVarTransferCache, reportProgress: reportProgress } ); } /** * Get a block by its hash or height (ID) * @param identifier The hash (hex string) or height (integer) of the block to retrieve. * @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. */ public getBlock(identifier: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; public getBlock(identifier: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public getBlock(identifier: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public getBlock(identifier: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (identifier === null || identifier === undefined) { throw new Error('Required parameter identifier was null or undefined when calling getBlock.'); } let localVarHeaders = this.defaultHeaders; 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; 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 = `/block/${this.configuration.encodeParam({name: "identifier", value: identifier, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; const { basePath, withCredentials } = this.configuration; return this.httpClient.request('get', `${basePath}${localVarPath}`, { context: localVarHttpContext, responseType: responseType_, ...(withCredentials ? { withCredentials } : {}), headers: localVarHeaders, observe: observe, transferCache: localVarTransferCache, reportProgress: reportProgress } ); } /** * Get one or more blocks, with optional pagination. * @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. */ public getBlocks(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public getBlocks(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; public getBlocks(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; public getBlocks(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { let localVarHeaders = this.defaultHeaders; 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; 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 = `/block`; const { basePath, withCredentials } = this.configuration; return this.httpClient.request>('get', `${basePath}${localVarPath}`, { context: localVarHttpContext, responseType: responseType_, ...(withCredentials ? { withCredentials } : {}), headers: localVarHeaders, observe: observe, transferCache: localVarTransferCache, reportProgress: reportProgress } ); } /** * Get the current blockchain height * @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. */ public getHeight(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; public getHeight(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public getHeight(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public getHeight(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { let localVarHeaders = this.defaultHeaders; 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; 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 = `/block/height`; const { basePath, withCredentials } = this.configuration; return this.httpClient.request('get', `${basePath}${localVarPath}`, { context: localVarHttpContext, responseType: responseType_, ...(withCredentials ? { withCredentials } : {}), headers: localVarHeaders, observe: observe, transferCache: localVarTransferCache, reportProgress: reportProgress } ); } /** * Submit a new block to the network * @param submitBlockRequestModel * @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. */ public submitBlock(submitBlockRequestModel: SubmitBlockRequestModel, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; public submitBlock(submitBlockRequestModel: SubmitBlockRequestModel, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public submitBlock(submitBlockRequestModel: SubmitBlockRequestModel, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public submitBlock(submitBlockRequestModel: SubmitBlockRequestModel, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (submitBlockRequestModel === null || submitBlockRequestModel === undefined) { throw new Error('Required parameter submitBlockRequestModel was null or undefined when calling submitBlock.'); } let localVarHeaders = this.defaultHeaders; 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 = `/block/submit`; const { basePath, withCredentials } = this.configuration; return this.httpClient.request('post', `${basePath}${localVarPath}`, { context: localVarHttpContext, body: submitBlockRequestModel, responseType: responseType_, ...(withCredentials ? { withCredentials } : {}), headers: localVarHeaders, observe: observe, transferCache: localVarTransferCache, reportProgress: reportProgress } ); } }