Commit 45f0ffdf authored by dev0tion's avatar dev0tion

Add API documentation

parent 3361c94d
...@@ -7,6 +7,10 @@ import 'rxjs/add/operator/catch'; ...@@ -7,6 +7,10 @@ import 'rxjs/add/operator/catch';
import { SafeCreation } from '../safe-creation'; import { SafeCreation } from '../safe-creation';
import { Mnemonic } from '../mnemonic'; import { Mnemonic } from '../mnemonic';
/**
* For information on the API specification have a look at our Github:
* https://github.com/stratisproject/Breeze/blob/master/Breeze.Documentation/ApiSpecification.md
*/
@Injectable() @Injectable()
export class ApiService { export class ApiService {
constructor(private http: Http) {}; constructor(private http: Http) {};
...@@ -14,13 +18,9 @@ export class ApiService { ...@@ -14,13 +18,9 @@ export class ApiService {
private webApiUrl = 'http://localhost:3000/api/v1'; private webApiUrl = 'http://localhost:3000/api/v1';
private headers = new Headers({'Content-Type': 'application/json'}); private headers = new Headers({'Content-Type': 'application/json'});
isConnected(): Observable<any> { /**
return this.http * Get wallet status info from the API.
.get(this.webApiUrl + '/safe/connected') */
.map((response:Response) => response.json())
.catch(this.handleError);
}
getWalletStatus(): Observable<any> { getWalletStatus(): Observable<any> {
return this.http return this.http
.get(this.webApiUrl + '/wallet/status') .get(this.webApiUrl + '/wallet/status')
...@@ -28,6 +28,9 @@ export class ApiService { ...@@ -28,6 +28,9 @@ export class ApiService {
.catch(this.handleError); .catch(this.handleError);
} }
/**
* Get wallet balance info from the API.
*/
getWalletBalance(): Observable<any> { getWalletBalance(): Observable<any> {
return this.http return this.http
.get(this.webApiUrl + '/wallet/balance') .get(this.webApiUrl + '/wallet/balance')
...@@ -35,6 +38,9 @@ export class ApiService { ...@@ -35,6 +38,9 @@ export class ApiService {
.catch(this.handleError); .catch(this.handleError);
} }
/**
* Get a wallets transaction history info from the API.
*/
getWalletHistory(): Observable<any> { getWalletHistory(): Observable<any> {
return this.http return this.http
.get(this.webApiUrl + '/wallet/history') .get(this.webApiUrl + '/wallet/history')
...@@ -42,6 +48,9 @@ export class ApiService { ...@@ -42,6 +48,9 @@ export class ApiService {
.catch(this.handleError); .catch(this.handleError);
} }
/**
* Get unused receive addresses for a certain wallet from the API.
*/
getUnusedReceiveAddresses(): Observable<any> { getUnusedReceiveAddresses(): Observable<any> {
return this.http return this.http
.get(this.webApiUrl + '/wallet/receive') .get(this.webApiUrl + '/wallet/receive')
...@@ -49,6 +58,9 @@ export class ApiService { ...@@ -49,6 +58,9 @@ export class ApiService {
.catch(this.handleError); .catch(this.handleError);
} }
/**
* Create a new wallet.
*/
createWallet(data: SafeCreation): Observable<any> { createWallet(data: SafeCreation): Observable<any> {
console.log(JSON.stringify(data)); console.log(JSON.stringify(data));
return this.http return this.http
...@@ -56,6 +68,10 @@ export class ApiService { ...@@ -56,6 +68,10 @@ export class ApiService {
.map(response => response.json()); .map(response => response.json());
} }
/**
* Handle errors from the API.
* @param error
*/
private handleError (error: Response | any) { private handleError (error: Response | any) {
let errMsg: string; let errMsg: string;
if (error instanceof Response) { if (error instanceof Response) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment