]> git.cworth.org Git - lmno.games/commitdiff
STASHING CHANGES TO GET THEM OFF HANDROID flempires/requests-generalized
authorKevin Worth <kworth082@gmail.com>
Thu, 23 Dec 2021 19:48:38 +0000 (14:48 -0500)
committerKevin Worth <kworth082@gmail.com>
Thu, 23 Dec 2021 19:48:38 +0000 (14:48 -0500)
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');