/* 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, WaitNotificationResponse, } from '../models/index'; import { BadRequestErrorFromJSON, BadRequestErrorToJSON, InternalServerErrorFromJSON, InternalServerErrorToJSON, WaitNotificationResponseFromJSON, WaitNotificationResponseToJSON, } from '../models/index'; export interface WaitNotificationRequest { since?: Date; } /** * */ export class NotificationsApi extends runtime.BaseAPI { /** * Creates request options for waitNotification without sending the request */ async waitNotificationRequestOpts(requestParameters: WaitNotificationRequest): Promise { const queryParameters: any = {}; if (requestParameters['since'] != null) { queryParameters['since'] = (requestParameters['since'] as any).toISOString(); } 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/notifications/wait`; return { path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }; } /** * Long-polls for wallet notifications. Returns all notifications received since the given timestamp. If no timestamp is provided, returns all notifications in the buffer. Returned notifications are sorted by timestamp in ascending order. * Long-poll for wallet notifications */ async waitNotificationRaw(requestParameters: WaitNotificationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.waitNotificationRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WaitNotificationResponseFromJSON(jsonValue)); } /** * Long-polls for wallet notifications. Returns all notifications received since the given timestamp. If no timestamp is provided, returns all notifications in the buffer. Returned notifications are sorted by timestamp in ascending order. * Long-poll for wallet notifications */ async waitNotification(requestParameters: WaitNotificationRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.waitNotificationRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for websocketTicket without sending the request */ async websocketTicketRequestOpts(): Promise { const queryParameters: any = {}; 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/notifications/ws/ticket`; return { path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }; } /** * Creates a single-use ticket that authenticates a websocket connection at `ws:///api/v1/notifications/ws?ticket=`. The ticket must be used within 10 minutes of creation; the resulting websocket connection is long-lived. * Create a websocket ticket */ async websocketTicketRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.websocketTicketRequestOpts(); const response = await this.request(requestOptions, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response) as any; } } /** * Creates a single-use ticket that authenticates a websocket connection at `ws:///api/v1/notifications/ws?ticket=`. The ticket must be used within 10 minutes of creation; the resulting websocket connection is long-lived. * Create a websocket ticket */ async websocketTicket(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.websocketTicketRaw(initOverrides); return await response.value(); } }