Created
April 18, 2019 05:49
-
-
Save izznfkhrlislm/53a246670714160e3fb14a884cf0825b to your computer and use it in GitHub Desktop.
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
import 'package:http/http.dart' show Client; | |
import 'package:ScrumBooster/ScrumPhase/ProductBacklog/Model.dart'; | |
import 'dart:convert'; | |
import 'package:ScrumBooster/Utils/utils.dart'; | |
class ProductBacklogApiProvider { | |
static const int PHASE_ID = 1; | |
Client client = Client(); | |
var response; | |
var util = new Util(); | |
ProductBacklogModel model; | |
List<CeremonyItem> ceremonyItemModels; | |
List<ProblemItem> problemItemModels; | |
fetchPosts() async { | |
response = await client.get( | |
util.getConfiguration()['base_url']+"phase/$PHASE_ID/details" | |
); | |
var jsonBody = json.decode(response.body); | |
model = ProductBacklogModel.fromJson(jsonBody); | |
ceremonyItemModels = []; | |
for (Map<String, dynamic> ceremony in model.ceremonies) { | |
ceremonyItemModels.add(CeremonyItem.fromJson(ceremony)); | |
} | |
problemItemModels = []; | |
for (var problem in model.problems) { | |
problemItemModels.add(ProblemItem.fromJson(problem)); | |
} | |
} | |
ProductBacklogModel getModel() { | |
return model; | |
} | |
List<CeremonyItem> getCeremonyItemModel() { | |
return ceremonyItemModels; | |
} | |
List<ProblemItem> getProblemItemModel() { | |
return problemItemModels; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment