Add transaction data service.

This commit is contained in:
Spencer Ofwiti 2020-11-04 15:35:20 +03:00
parent a4c287f9f7
commit cbe51520fa
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { TransactionService } from './transaction.service';
describe('TransactionService', () => {
let service: TransactionService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(TransactionService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,27 @@
import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {map} from 'rxjs/operators';
import {Observable} from 'rxjs';
import {environment} from '../../environments/environment';
@Injectable({
providedIn: 'root'
})
export class TransactionService {
constructor(private http: HttpClient) { }
getAllTransactions(offset: number, limit: number): Observable<any> {
return this.http.get(`${environment.cicCacheUrl}/tx/${offset}/${limit}`)
.pipe(map(response => {
return response;
}));
}
getAddressTransactions(address: string, offset: number, limit: number): Observable<any> {
return this.http.get(`${environment.cicCacheUrl}/tx/${address}/${offset}/${limit}`)
.pipe(map(response => {
return response;
}));
}
}