/* tslint:disable */ /* eslint-disable */ /** * barkd REST API * A simple REST API for barkd, a wallet daemon for integrating bitcoin payments into your app over HTTP. Supports self-custodial Lightning, Ark, and on-chain out of the box. barkd is a long-running daemon best suited for always-on or high-connectivity environments like nodes, servers, desktops, and point-of-sale terminals. All endpoints return JSON. Amounts are denominated in satoshis. * * The version of the OpenAPI document: 0.6.1 * Contact: hello@second.tech * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import * as runtime from '../runtime'; import type { BadRequestError, InternalServerError, Movement, } from '../models/index'; import { BadRequestErrorFromJSON, BadRequestErrorToJSON, InternalServerErrorFromJSON, InternalServerErrorToJSON, MovementFromJSON, MovementToJSON, } from '../models/index'; export interface ListRequest { type?: string; value?: string; } export interface UpdateMetadataRequest { id: number; body: any | null; } /** * */ export class HistoryApi extends runtime.BaseAPI { /** * Creates request options for list without sending the request */ async listRequestOpts(requestParameters: ListRequest): Promise { const queryParameters: any = {}; if (requestParameters['type'] != null) { queryParameters['type'] = requestParameters['type']; } if (requestParameters['value'] != null) { queryParameters['value'] = requestParameters['value']; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v1/history`; return { path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }; } /** * Returns the history of wallet movements ordered from newest to oldest. A movement represents any wallet operation that affects VTXOs—an arkoor send or receive, Lightning send or receive, board, offboard, or refresh. Each entry records which VTXOs were consumed and produced, the effective balance change (if any), fees paid, and the operation status. Supplying the `type` and `value` query parameters (together) restricts the result to movements involving that single payment method, such as all payments sent to one address. * Get wallet history */ async listRaw(requestParameters: ListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { const requestOptions = await this.listRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(MovementFromJSON)); } /** * Returns the history of wallet movements ordered from newest to oldest. A movement represents any wallet operation that affects VTXOs—an arkoor send or receive, Lightning send or receive, board, offboard, or refresh. Each entry records which VTXOs were consumed and produced, the effective balance change (if any), fees paid, and the operation status. Supplying the `type` and `value` query parameters (together) restricts the result to movements involving that single payment method, such as all payments sent to one address. * Get wallet history */ async list(requestParameters: ListRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const response = await this.listRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for updateMetadata without sending the request */ async updateMetadataRequestOpts(requestParameters: UpdateMetadataRequest): Promise { if (requestParameters['id'] == null) { throw new runtime.RequiredError( 'id', 'Required parameter "id" was null or undefined when calling updateMetadata().' ); } if (requestParameters['body'] == null) { throw new runtime.RequiredError( 'body', 'Required parameter "body" was null or undefined when calling updateMetadata().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/merge-patch+json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v1/history/{id}/metadata`; urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))); return { path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters['body'] as any, }; } /** * Applies an [RFC 7396](https://www.rfc-editor.org/rfc/rfc7396) JSON Merge Patch to a movement\'s metadata. Use this to annotate history entries after the fact (e.g. refund notes, counterparty info). Keys set to `null` are removed; other values are recursively merged. * Patch movement metadata */ async updateMetadataRaw(requestParameters: UpdateMetadataRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.updateMetadataRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.VoidApiResponse(response); } /** * Applies an [RFC 7396](https://www.rfc-editor.org/rfc/rfc7396) JSON Merge Patch to a movement\'s metadata. Use this to annotate history entries after the fact (e.g. refund notes, counterparty info). Keys set to `null` are removed; other values are recursively merged. * Patch movement metadata */ async updateMetadata(requestParameters: UpdateMetadataRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.updateMetadataRaw(requestParameters, initOverrides); } }