Skip to content

Commit

Permalink
history data models
Browse files Browse the repository at this point in the history
  • Loading branch information
KarimElghamry committed Jul 22, 2019
1 parent c34ffc5 commit 6d823cd
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/src/models/graph_data.dart
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"],
);
}
}
28 changes: 28 additions & 0 deletions lib/src/models/history.dart
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"],
);
}
}

0 comments on commit 6d823cd

Please sign in to comment.