/** * OriginStamp Client * * OpenAPI spec version: 3.0 * OriginStamp Documentation: https://doc.originstamp.org * Contact: mail@originstamp.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; import { HttpClient, HttpHeaders, HttpParams, HttpResponse, HttpEvent } from '@angular/common/http'; import { CustomHttpUrlEncodingCodec } from '../encoder'; import { Observable } from 'rxjs'; import { DefaultTimestampResponse } from '../model/defaultTimestampResponse'; import { DefaultUsageResponse } from '../model/defaultUsageResponse'; import { Defaultstring } from '../model/defaultstring'; import { ProofRequest } from '../model/proofRequest'; import { TimestampRequest } from '../model/timestampRequest'; import { WebhookRequest } from '../model/webhookRequest'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; @Injectable() export class TimestampService { protected basePath = 'https://api.originstamp.com'; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { if (basePath) { this.basePath = basePath; } if (configuration) { this.configuration = configuration; this.basePath = basePath || configuration.basePath || this.basePath; } } /** * @param consumes string[] mime-types * @return true: consumes contains 'multipart/form-data', false: otherwise */ private canConsumeForm(consumes: string[]): boolean { const form = 'multipart/form-data'; for (let consume of consumes) { if (form === consume) { return true; } } return false; } /** * Submission * You can submit your hash with this function. If your api key is valid, your hash is added to batch and is scheduled for timestamping. If the hash already exists, the created flag in the response is set to false and the notification(s) of the current request will be totally ignored. You are also able to submit additional information, such as comment or notification credentials. Once a hash is successfully created for a certain crypto-currency, we can notify your desired target with the timestamp information (POST Request). The webhook is triggered as soon as the tamper-proof timestamp with the selected crypto currency has been created. Additionally, it is possible to include a preprint URL in the hash submission. Before the generation of the timestamp hash you can create a random UUID Version 4 and include https://originstamp.com/u/UUID where UUID is your UUID e.g. in a document you want to timestamp. In the preprint URL field you include your UUID and then it is possible to verify the timestamp within the document (or whatever). * @param authorization A valid API key is essential for authorization to handle the request. * @param timestampRequest DTO for the hash submission. Add all relevant information concerning your hash submission. * @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 createTimestamp(authorization: string, timestampRequest: TimestampRequest, observe?: 'body', reportProgress?: boolean): Observable; public createTimestamp(authorization: string, timestampRequest: TimestampRequest, observe?: 'response', reportProgress?: boolean): Observable>; public createTimestamp(authorization: string, timestampRequest: TimestampRequest, observe?: 'events', reportProgress?: boolean): Observable>; public createTimestamp(authorization: string, timestampRequest: TimestampRequest, observe: any = 'body', reportProgress: boolean = false ): Observable { if (authorization === null || authorization === undefined) { throw new Error('Required parameter authorization was null or undefined when calling createTimestamp.'); } if (timestampRequest === null || timestampRequest === undefined) { throw new Error('Required parameter timestampRequest was null or undefined when calling createTimestamp.'); } let headers = this.defaultHeaders; if (authorization !== undefined && authorization !== null) { headers = headers.set('Authorization', String(authorization)); } // to determine the Accept header let httpHeaderAccepts: string[] = [ 'application/json' ]; let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { headers = headers.set("Accept", httpHeaderAcceptSelected); } // to determine the Content-Type header let consumes: string[] = [ 'application/json' ]; let httpContentTypeSelected:string | undefined = this.configuration.selectHeaderContentType(consumes); if (httpContentTypeSelected != undefined) { headers = headers.set("Content-Type", httpContentTypeSelected); } return this.httpClient.post(`${this.basePath}/v3/timestamp/create`, timestampRequest, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Usage * With this interface you can receive the current api usage. * @param authorization A valid API key is essential for authorization to handle the request. * @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 getApiKeyUsage(authorization: string, observe?: 'body', reportProgress?: boolean): Observable; public getApiKeyUsage(authorization: string, observe?: 'response', reportProgress?: boolean): Observable>; public getApiKeyUsage(authorization: string, observe?: 'events', reportProgress?: boolean): Observable>; public getApiKeyUsage(authorization: string, observe: any = 'body', reportProgress: boolean = false ): Observable { if (authorization === null || authorization === undefined) { throw new Error('Required parameter authorization was null or undefined when calling getApiKeyUsage.'); } let headers = this.defaultHeaders; if (authorization !== undefined && authorization !== null) { headers = headers.set('Authorization', String(authorization)); } // to determine the Accept header let httpHeaderAccepts: string[] = [ '*/*' ]; let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { headers = headers.set("Accept", httpHeaderAcceptSelected); } // to determine the Content-Type header let consumes: string[] = [ ]; return this.httpClient.get(`${this.basePath}/v3/api_key/usage`, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Status * The request returns information of a certain hash read from the URL parameter. The input parameter is a hash in hex representation. Field \"created\" always set to false. * @param authorization A valid API key is essential for authorization to handle the request. * @param hashString The hash in string representation. * @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 getHashStatus(authorization: string, hashString: string, observe?: 'body', reportProgress?: boolean): Observable; public getHashStatus(authorization: string, hashString: string, observe?: 'response', reportProgress?: boolean): Observable>; public getHashStatus(authorization: string, hashString: string, observe?: 'events', reportProgress?: boolean): Observable>; public getHashStatus(authorization: string, hashString: string, observe: any = 'body', reportProgress: boolean = false ): Observable { if (authorization === null || authorization === undefined) { throw new Error('Required parameter authorization was null or undefined when calling getHashStatus.'); } if (hashString === null || hashString === undefined) { throw new Error('Required parameter hashString was null or undefined when calling getHashStatus.'); } let headers = this.defaultHeaders; if (authorization !== undefined && authorization !== null) { headers = headers.set('Authorization', String(authorization)); } // to determine the Accept header let httpHeaderAccepts: string[] = [ 'application/json' ]; let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { headers = headers.set("Accept", httpHeaderAcceptSelected); } // to determine the Content-Type header let consumes: string[] = [ ]; return this.httpClient.get(`${this.basePath}/v3/timestamp/${encodeURIComponent(String(hashString))}`, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Proof * This request can be used to proof a submission of a hash. This interface is required to request the evidence. With the help of this proof the verification of a timestamp independent from OriginStamp is necessary. A guide for the verification can be found herehttps://github.com/OriginStampTimestamping/originstamp-verification . Usually, the proof should be requested for each transferred hash and kept with the timestamped data so that an independent verification of the timestamp is possible at any time. As input, the used currency, the hash string and the type of proof is required. Then a file with the information for the submission proof will be returned. If the hash was submitted in an API version lower than 3, a XML file containing the essential information of the Merkle Tree will be returned. Otherwise, the seed file will be returned. The file name can be found in the header of the response. An example could look like this: content-disposition: attachment; filename=\"certificate_6d70a947e19398f1106ad70a60bd34a8305bdcb624b5b7d43782315517e79cad.pdf\" A sample XML file can be found here https://originstamp.org/assets/proof/proof_6d70a947e19398f1106ad70a60bd34a8305bdcb624b5b7d43782315517e79cad.xml and a sample PDF can be found here https://originstamp.org/assets/proof/certificate_6d70a947e19398f1106ad70a60bd34a8305bdcb624b5b7d43782315517e79cad.pdf . * @param authorization A valid API key is essential for authorization to handle the request. * @param proofRequest Information needed to return the hash status information. * @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 getProof(authorization: string, proofRequest: ProofRequest, observe?: 'body', reportProgress?: boolean): Observable; public getProof(authorization: string, proofRequest: ProofRequest, observe?: 'response', reportProgress?: boolean): Observable>; public getProof(authorization: string, proofRequest: ProofRequest, observe?: 'events', reportProgress?: boolean): Observable>; public getProof(authorization: string, proofRequest: ProofRequest, observe: any = 'body', reportProgress: boolean = false ): Observable { if (authorization === null || authorization === undefined) { throw new Error('Required parameter authorization was null or undefined when calling getProof.'); } if (proofRequest === null || proofRequest === undefined) { throw new Error('Required parameter proofRequest was null or undefined when calling getProof.'); } let headers = this.defaultHeaders; if (authorization !== undefined && authorization !== null) { headers = headers.set('Authorization', String(authorization)); } // to determine the Accept header let httpHeaderAccepts: string[] = [ 'application/octet-stream' ]; let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { headers = headers.set("Accept", httpHeaderAcceptSelected); } // to determine the Content-Type header let consumes: string[] = [ 'application/json' ]; let httpContentTypeSelected:string | undefined = this.configuration.selectHeaderContentType(consumes); if (httpContentTypeSelected != undefined) { headers = headers.set("Content-Type", httpContentTypeSelected); } return this.httpClient.post(`${this.basePath}/v3/timestamp/proof`, proofRequest, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Dev * With this interface you can trigger manual webhook to see how a webhooks looks like. Please use a hash, that was already timestamped before such as https://originstamp.org/s/9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 . Usually, the webhook is triggered as soon as the tamper-proof time stamp with the selected crypto currency has been created. * @param authorization A valid API key is essential for authorization to handle the request. * @param webhookRequest DTO for webhook request. * @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 triggerTimestampWebhook(authorization: string, webhookRequest: WebhookRequest, observe?: 'body', reportProgress?: boolean): Observable; public triggerTimestampWebhook(authorization: string, webhookRequest: WebhookRequest, observe?: 'response', reportProgress?: boolean): Observable>; public triggerTimestampWebhook(authorization: string, webhookRequest: WebhookRequest, observe?: 'events', reportProgress?: boolean): Observable>; public triggerTimestampWebhook(authorization: string, webhookRequest: WebhookRequest, observe: any = 'body', reportProgress: boolean = false ): Observable { if (authorization === null || authorization === undefined) { throw new Error('Required parameter authorization was null or undefined when calling triggerTimestampWebhook.'); } if (webhookRequest === null || webhookRequest === undefined) { throw new Error('Required parameter webhookRequest was null or undefined when calling triggerTimestampWebhook.'); } let headers = this.defaultHeaders; if (authorization !== undefined && authorization !== null) { headers = headers.set('Authorization', String(authorization)); } // to determine the Accept header let httpHeaderAccepts: string[] = [ '*/*' ]; let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { headers = headers.set("Accept", httpHeaderAcceptSelected); } // to determine the Content-Type header let consumes: string[] = [ 'application/json' ]; let httpContentTypeSelected:string | undefined = this.configuration.selectHeaderContentType(consumes); if (httpContentTypeSelected != undefined) { headers = headers.set("Content-Type", httpContentTypeSelected); } return this.httpClient.post(`${this.basePath}/v3/webhook/start`, webhookRequest, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } }