import { Injectable } from '@angular/core'; import { HttpClient, HttpParams } from '@angular/common/http'; import { Observable } from 'rxjs'; const API_BASE_URL = '/lightning/api/v1'; @Injectable({ providedIn: 'root' }) export class LightningApiService { constructor( private httpClient: HttpClient, ) { } getNode$(publicKey: string): Observable { return this.httpClient.get(API_BASE_URL + '/nodes/' + publicKey); } getChannel$(shortId: string): Observable { return this.httpClient.get(API_BASE_URL + '/channels/' + shortId); } getChannelsByNodeId$(publicKey: string, index: number = 0, status = 'open'): Observable { let params = new HttpParams() .set('public_key', publicKey) .set('index', index) .set('status', status) ; return this.httpClient.get(API_BASE_URL + '/channels', { params, observe: 'response' }); } getLatestStatistics$(): Observable { return this.httpClient.get(API_BASE_URL + '/statistics/latest'); } listNodeStats$(publicKey: string): Observable { return this.httpClient.get(API_BASE_URL + '/nodes/' + publicKey + '/statistics'); } listTopNodes$(): Observable { return this.httpClient.get(API_BASE_URL + '/nodes/top'); } }