Advertisement
sandhysanjaya

Untitled

Oct 17th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.61 KB | None | 0 0
  1. Future<List<Record>> fetchHistory(DateTime startdate, DateTime enddate, String userId) async {
  2.   var existstartdate = startdate.toLocal();
  3.   var existdate =  enddate.toLocal();
  4.   var newstartdate = new DateTime(existstartdate.year, existstartdate.month, existstartdate.day, 00, 00, 00);
  5.   var newdate = new DateTime(existdate.year, existdate.month, existdate.day, 23, 59, 59);
  6.   print("New Date : ${newdate}");
  7.   print('$schema://$hostMeeberPosUri:3002/v1/transactions/${userId}?startdate=${newstartdate.toLocal().millisecondsSinceEpoch}&enddate=${newdate.toLocal().millisecondsSinceEpoch}&limit=10&page=1');
  8.   var headers = {
  9.     "Content-Type": "application/json",
  10.     "appToken": "hX5+61eJVErg0bYvdijaBil193IjqYVXXDcGs60O7uPjNunMsXc//35X58Y+XNH1r1rBahb3LKmchpD+6FIQEgEmneRBB6ODFzhCg7o0imqFXFktz1AuGbuEvcN/xMdYgHWNlz++wroev3tHXCDonKlmm6fh/bfd52eXpBrTEqj+7SY0qhTSErj0IqPU2R4t68w1o03P5OLb1nAy3+tQQouTZGxJlAGS+HUh4AqVLrvW+VD4ca1m8JZapykqvV6RPfl7uSzYAdNHAeHBDSmz4V6zCGMLHNUM2VbzQjGgppp7se83CZNkjTSRkpXUPVTMcpUavyPJpcVmH9CrLjcSaeKuz26lV1TuX5QFB0SsCX7NLO/fm2kmfCpLQyXTcWLaNYDwz3gZNWtlIJhJuSww6A=="
  11.   };
  12.   try {
  13.     http.Response response = await http.get(
  14.         '$schema://$hostMeeberPosUri:3002/v1/transactions/${userId}?startdate=${newstartdate.toLocal().millisecondsSinceEpoch}&enddate=${newdate.toLocal().millisecondsSinceEpoch}&limit=10&page=1',
  15.         headers: headers
  16.     );
  17.     var responseJson = json.decode(response.body);
  18.     print("JSON History Transaksi ${responseJson}");
  19.     return responseJson.map<Record>((json) => Record.fromJson(json)).toList();
  20.   } catch(err) {
  21.     print(err);
  22.     return null;
  23.   }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement