Skip to content

Commit 34b0741

Browse files
committed
Merge branch 'release'
2 parents b32e4c6 + f072d02 commit 34b0741

8 files changed

Lines changed: 46 additions & 49 deletions

File tree

ionic.config.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,7 @@
22
"name": "CryptoWallet",
33
"app_id": "1bbfbbf6",
44
"type": "ionic-angular",
5-
"proxies": [
6-
{
7-
"path": "/coinmarketcapticker",
8-
"proxyUrl": "https://api.coinmarketcap.com/v1/ticker/"
9-
},
10-
{
11-
"path": "/coinmarketcapgraphs",
12-
"proxyUrl": "https://graphs2.coinmarketcap.com/currencies/"
13-
}
14-
],
5+
"proxies": [],
156
"integrations": {
167
"cordova": {
178
}

src/entities/graphs.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export class Graphs {
2+
3+
public marketCapByAvailableSupply: Array<Array<number>>;
4+
public priceBtc: Array<Array<number>>;
5+
public priceUsd: Array<Array<number>>;
6+
public volumeUsd: Array<Array<number>>;
7+
8+
constructor() {}
9+
}

src/entities/ticker.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export class Ticker {
2+
3+
public priceBtc: number;
4+
public priceUsd: number;
5+
6+
constructor() {}
7+
}

src/pages/all-assets/all-assets.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { Wallet } from '../../entities/wallet';
55
import { Asset } from '../../entities/asset';
66

77
import { RegisteredUserProvider } from '../../providers/registered/user';
8+
import { CoinMarketCapProvider } from '../../providers/coinmarketcap/coinmarketcap';
89
import { LocalStorageProvider } from '../../providers/storage/localstorage';
910

1011
import { UserAuthenticationPage } from '../user-authentication/user-authentication';
1112
import { InsertAssetPage } from '../insert-asset/insert-asset';
1213
import { UpdateAssetPage } from '../update-asset/update-asset';
1314
import { AllWalletsPage } from '../all-wallets/all-wallets';
14-
import { CoinMarketCapProvider } from '../../providers/coinmarketcap/coinmarketcap';
1515

1616
@Component({
1717
selector: 'page-all-assets',
@@ -58,9 +58,9 @@ export class AllAssetsPage {
5858
for (let offset = 0; offset < this.all.length; offset++) {
5959
let asset: Asset = this.all[offset];
6060
this.purchasePrice = this.purchasePrice + asset.purchasePrice;
61-
this.coinMarketCapProvider.getPrice(asset.cryptocurrency).subscribe(result => {
62-
console.log(result);console.log(asset.amount);console.log(parseFloat(result[0].price_btc));
63-
this.currentPrice = this.currentPrice + (asset.amount * parseFloat(result[0].price_btc));
61+
62+
this.coinMarketCapProvider.getCurrentPrice(asset.cryptocurrency).subscribe(result => {
63+
this.currentPrice = this.currentPrice + (asset.amount * result.data.priceBtc);
6464
}, error => {
6565
console.error(error);
6666
this.toastCtrl.create({ message: 'An error occured...', duration: 3000, position: 'top' }).present();

src/pages/chart/chart.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import * as moment from 'moment';
66

77
import { Cryptocurrency } from '../../entities/cryptocurrency';
88
import { ChartPeriod } from '../../entities/chartperiod';
9-
import { CoinMarketCapGraphsResponse } from '../../responses/coinmarketcapgraphsresponse';
9+
import { Graphs } from '../../entities/graphs';
10+
import { CryptoWalletResponse } from '../../responses/cryptowalletresponse';
1011

1112
import { CoinMarketCapProvider } from '../../providers/coinmarketcap/coinmarketcap';
1213
import { UnregisteredChartPeriodProvider } from '../../providers/unregistered/chartperiod';
@@ -242,9 +243,9 @@ export class ChartPage {
242243
let loadingOverlay = this.loadingCtrl.create({ content: 'Please wait...' });
243244
loadingOverlay.present();
244245

245-
let coinMarketCapGraphsResponse: Observable<CoinMarketCapGraphsResponse> = (period === "ALL" ? this.coinMarketCapProvider.allPrices(this.cryptocurrency) : this.coinMarketCapProvider.allPricesBetween(this.cryptocurrency, startDateValue, endDateValue));
246-
coinMarketCapGraphsResponse.subscribe(result => {
247-
refreshChartCallback(refreshChart, chart, result, this.getFormatValue(period), this.getMaxTicksValue(period));
246+
let graphsResponse: Observable<CryptoWalletResponse<Graphs>> = (period === "ALL" ? this.coinMarketCapProvider.allPrices(this.cryptocurrency) : this.coinMarketCapProvider.allPricesBetween(this.cryptocurrency, startDateValue, endDateValue));
247+
graphsResponse.subscribe(result => {
248+
refreshChartCallback(refreshChart, chart, result.data, this.getFormatValue(period), this.getMaxTicksValue(period));
248249

249250
loadingOverlay.dismiss();
250251
}, error => {
@@ -308,20 +309,20 @@ export class ChartPage {
308309
}
309310
}
310311

311-
private refreshUsdChart(refreshChart: Function, chart: Chart, coinMarketCapGraphsResponse: CoinMarketCapGraphsResponse, labelFormat: string, maxTicksValue: number): void {
312-
refreshChart(chart, coinMarketCapGraphsResponse.price_usd, labelFormat, maxTicksValue);
312+
private refreshUsdChart(refreshChart: Function, chart: Chart, graphs: Graphs, labelFormat: string, maxTicksValue: number): void {
313+
refreshChart(chart, graphs.priceUsd, labelFormat, maxTicksValue);
313314
}
314315

315-
private refreshBtcChart(refreshChart: Function, chart: Chart, coinMarketCapGraphsResponse: CoinMarketCapGraphsResponse, labelFormat: string, maxTicksValue: number): void {
316-
refreshChart(chart, coinMarketCapGraphsResponse.price_btc, labelFormat, maxTicksValue);
316+
private refreshBtcChart(refreshChart: Function, chart: Chart, graphs: Graphs, labelFormat: string, maxTicksValue: number): void {
317+
refreshChart(chart, graphs.priceBtc, labelFormat, maxTicksValue);
317318
}
318319

319-
private refreshMarketCapChart(refreshChart: Function, chart: Chart, coinMarketCapGraphsResponse: CoinMarketCapGraphsResponse, labelFormat: string, maxTicksValue: number): void {
320-
refreshChart(chart, coinMarketCapGraphsResponse.market_cap_by_available_supply, labelFormat, maxTicksValue);
320+
private refreshMarketCapChart(refreshChart: Function, chart: Chart, graphs: Graphs, labelFormat: string, maxTicksValue: number): void {
321+
refreshChart(chart, graphs.marketCapByAvailableSupply, labelFormat, maxTicksValue);
321322
}
322323

323-
private refreshVolumesChart(refreshChart: Function, chart: Chart, coinMarketCapGraphsResponse: CoinMarketCapGraphsResponse, labelFormat: string, maxTicksValue: number): void {
324-
refreshChart(chart, coinMarketCapGraphsResponse.volume_usd, labelFormat, maxTicksValue);
324+
private refreshVolumesChart(refreshChart: Function, chart: Chart, graphs: Graphs, labelFormat: string, maxTicksValue: number): void {
325+
refreshChart(chart, graphs.volumeUsd, labelFormat, maxTicksValue);
325326
}
326327

327328
private refreshChart(chart: Chart, values: Array<Array<number>>, labelFormat: string, maxTicksValue: number): void {

src/providers/coinmarketcap/coinmarketcap.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,28 @@ import { Injectable } from '@angular/core';
33
import { Observable } from 'rxjs/Observable';
44

55
import { Cryptocurrency } from '../../entities/cryptocurrency';
6-
import { CoinMarketCapTickerResponse } from '../../responses/coinmarketcaptickerresponse';
7-
import { CoinMarketCapGraphsResponse } from '../../responses/coinmarketcapgraphsresponse';
6+
import { Ticker } from '../../entities/ticker';
7+
import { Graphs } from '../../entities/graphs';
8+
import { CryptoWalletResponse } from '../../responses/cryptowalletresponse';
89

910
@Injectable()
1011
export class CoinMarketCapProvider {
1112

12-
private readonly getPricePath: string = "coinmarketcapticker/RESOURCE_URL/";
13-
private readonly allPricesPath: string = "coinmarketcapgraphs/RESOURCE_URL/";
14-
private readonly allPricesBetweenPath: string = "coinmarketcapgraphs/RESOURCE_URL/START_DATE/END_DATE/";
13+
private readonly getCurrentPricePath: string = "https://cryptowallet.loic-delorme.fr/api/cryptowallet/coinmarketcap/ticker/RESOURCE_URL";
14+
private readonly allPricesPath: string = "https://cryptowallet.loic-delorme.fr/api/cryptowallet/coinmarketcap/graphs/RESOURCE_URL";
15+
private readonly allPricesBetweenPath: string = "https://cryptowallet.loic-delorme.fr/api/cryptowallet/coinmarketcap/graphs/RESOURCE_URL/START_DATE/END_DATE";
1516

1617
constructor(private http: HttpClient) {}
1718

18-
public getPrice(cryptocurrency: Cryptocurrency): Observable<Array<CoinMarketCapTickerResponse>> {
19-
return this.http.get<Array<CoinMarketCapTickerResponse>>(this.getPricePath.replace("RESOURCE_URL", cryptocurrency.resourceUrl));
19+
public getCurrentPrice(cryptocurrency: Cryptocurrency): Observable<CryptoWalletResponse<Ticker>> {
20+
return this.http.get<CryptoWalletResponse<Ticker>>(this.getCurrentPricePath.replace("RESOURCE_URL", cryptocurrency.resourceUrl));
2021
}
2122

22-
public allPrices(cryptocurrency: Cryptocurrency): Observable<CoinMarketCapGraphsResponse> {
23-
return this.http.get<CoinMarketCapGraphsResponse>(this.allPricesPath.replace("RESOURCE_URL", cryptocurrency.resourceUrl));
23+
public allPrices(cryptocurrency: Cryptocurrency): Observable<CryptoWalletResponse<Graphs>> {
24+
return this.http.get<CryptoWalletResponse<Graphs>>(this.allPricesPath.replace("RESOURCE_URL", cryptocurrency.resourceUrl));
2425
}
2526

26-
public allPricesBetween(cryptocurrency: Cryptocurrency, startDate: string, endDate: string): Observable<CoinMarketCapGraphsResponse> {
27-
return this.http.get<CoinMarketCapGraphsResponse>(this.allPricesBetweenPath.replace("RESOURCE_URL", cryptocurrency.resourceUrl).replace("START_DATE", startDate).replace("END_DATE", endDate));
27+
public allPricesBetween(cryptocurrency: Cryptocurrency, startDate: string, endDate: string): Observable<CryptoWalletResponse<Graphs>> {
28+
return this.http.get<CryptoWalletResponse<Graphs>>(this.allPricesBetweenPath.replace("RESOURCE_URL", cryptocurrency.resourceUrl).replace("START_DATE", startDate).replace("END_DATE", endDate));
2829
}
2930
}

src/responses/coinmarketcapgraphsresponse.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/responses/coinmarketcaptickerresponse.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)