]> git.cworth.org Git - lmno.games/blobdiff - flempires/lib/player.dart
STASHING CHANGES TO GET THEM OFF HANDROID
[lmno.games] / flempires / lib / player.dart
index aa87c8411d844dba694e015d19bbcd90a72fe2e5..02df4f2d4dd261bdf5d0c14d7e05ab4c26bed74c 100644 (file)
@@ -1,5 +1,6 @@
 import 'dart:convert';
 
+import 'package:flempires/webService.dart';
 import 'package:http/http.dart' as http;
 
 class Player {
@@ -15,6 +16,34 @@ class Player {
     );
   }
 
+//  static Resource<List<NewsArticle>> get all {
+//
+//    return Resource(
+//        url: Constants.HEADLINE_NEWS_URL,
+//        parse: (response) {
+//          final result = json.decode(response.body);
+//          Iterable list = result['articles'];
+//          return list.map((model) => NewsArticle.fromJson(model)).toList();
+//        }
+//    );
+//
+//  }
+
+//  static Request<List<Player>> get all (String code) {
+//
+//  }
+
+  static Request<List<Player>> get all {
+    return Request(
+        url: 'https://families.cworth.org/api/players',
+        type: 'Player',
+        parse: (response) {
+          final result = json.decode(response.body);
+          Iterable list = result['players'];
+          return list.map((model) => Player.fromJson(model)).toList();
+        });
+  }
+
   static Future<Player> fetchFirstPlayer() async {
     final response = await http.get('https://families.cworth.org/api/players');