-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c34ffc5
commit 6d823cd
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class GraphData { | ||
num _time; | ||
num _close; | ||
num _high; | ||
num _low; | ||
num _open; | ||
|
||
num get time => _time; | ||
num get close => _close; | ||
num get high => _high; | ||
num get low => _low; | ||
num get open => _open; | ||
|
||
GraphData._({num time, num close, num high, num low, num open}) | ||
: _time = time, | ||
_close = close, | ||
_high = high, | ||
_low = low, | ||
_open = open; | ||
|
||
factory GraphData.fromJson(Map<String, dynamic> json) { | ||
return GraphData._( | ||
time: json["time"], | ||
close: json["close"], | ||
high: json["high"], | ||
low: json["low"], | ||
open: json["open"], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:cryptoholic/src/models/graph_data.dart'; | ||
|
||
class History { | ||
List<GraphData> _graphData; | ||
num _timeTo; | ||
num _timeFrom; | ||
|
||
List<GraphData> get graphData => _graphData; | ||
num get timeTo => _timeTo; | ||
num get timeFrom => _timeFrom; | ||
|
||
History._({List<GraphData> graphData, num timeTo, num timeFrom}) | ||
: _graphData = graphData, | ||
_timeTo = timeTo, | ||
_timeFrom = timeFrom; | ||
|
||
factory History.fromJson(Map<String, dynamic> json) { | ||
List<GraphData> _graphDataList = []; | ||
for (var item in json["Data"]) { | ||
_graphDataList.add(GraphData.fromJson(item)); | ||
} | ||
return History._( | ||
graphData: _graphDataList, | ||
timeFrom: json["TimeFrom"], | ||
timeTo: json["TimeTo"], | ||
); | ||
} | ||
} |