Browse Source

web-ui: Add the BalancesService

scalafmt-draft
Alexis Hernandez 7 years ago
parent
commit
f0b3cd95d7
  1. 7
      web-ui/src/app/models/balance.ts
  2. 7
      web-ui/src/app/models/paginated-result.ts
  3. 25
      web-ui/src/app/services/balances.service.ts

7
web-ui/src/app/models/balance.ts

@ -0,0 +1,7 @@
export class Balance {
address: string;
available: number;
received: number;
spent: number;
}

7
web-ui/src/app/models/paginated-result.ts

@ -0,0 +1,7 @@
export class PaginatedResult<T> {
offset: number;
limit: number;
total: number;
data: T[];
}

25
web-ui/src/app/services/balances.service.ts

@ -0,0 +1,25 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { environment } from '../../environments/environment';
import { Balance } from '../models/balance';
import { PaginatedResult } from '../models/paginated-result';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' })
};
@Injectable()
export class BalancesService {
private baseUrl = environment.api.url + '/balances';
constructor(private http: HttpClient) { }
getRichest(offset: number = 0, limit: number = 10): Observable<PaginatedResult<Balance>> {
const url = `${this.baseUrl}?offset=${offset}&limit=${limit}`;
return this.http.get<PaginatedResult<Balance>>(url);
}
}
Loading…
Cancel
Save