From f0b3cd95d7f501e5e0ad9168aa0c68cc919bbc87 Mon Sep 17 00:00:00 2001 From: Alexis Hernandez Date: Thu, 12 Apr 2018 21:37:30 -0500 Subject: [PATCH] web-ui: Add the BalancesService --- web-ui/src/app/models/balance.ts | 7 ++++++ web-ui/src/app/models/paginated-result.ts | 7 ++++++ web-ui/src/app/services/balances.service.ts | 25 +++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 web-ui/src/app/models/balance.ts create mode 100644 web-ui/src/app/models/paginated-result.ts create mode 100644 web-ui/src/app/services/balances.service.ts diff --git a/web-ui/src/app/models/balance.ts b/web-ui/src/app/models/balance.ts new file mode 100644 index 0000000..86a0e55 --- /dev/null +++ b/web-ui/src/app/models/balance.ts @@ -0,0 +1,7 @@ + +export class Balance { + address: string; + available: number; + received: number; + spent: number; +} diff --git a/web-ui/src/app/models/paginated-result.ts b/web-ui/src/app/models/paginated-result.ts new file mode 100644 index 0000000..12c3e29 --- /dev/null +++ b/web-ui/src/app/models/paginated-result.ts @@ -0,0 +1,7 @@ + +export class PaginatedResult { + offset: number; + limit: number; + total: number; + data: T[]; +} diff --git a/web-ui/src/app/services/balances.service.ts b/web-ui/src/app/services/balances.service.ts new file mode 100644 index 0000000..e87b8e1 --- /dev/null +++ b/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> { + const url = `${this.baseUrl}?offset=${offset}&limit=${limit}`; + return this.http.get>(url); + } +}