Skip to content

Commit

Permalink
*little clean up and can now get list items either parsed for you or …
Browse files Browse the repository at this point in the history
…just the response
  • Loading branch information
mclark4386 committed Sep 11, 2018
1 parent 4aa8370 commit 9c15755
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [0.0.4] - 20180911

* little clean up and can now get list items either parsed for you or just the response (so you can send it into built_value directly if you like)

## [0.0.4] - 20180910

* added get list items api call
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build Status](https://travis-ci.org/mclark4386/flutter_aad.svg?branch=master)](https://travis-ci.org/mclark4386/flutter_aad)
[![codecov](https://codecov.io/gh/mclark4386/flutter_aad/branch/master/graph/badge.svg)](https://codecov.io/gh/mclark4386/flutter_aad)

A Flutter package for interacting with the Azure AD platform.
A Dart package for interacting with the Azure AD platform.

**Warning: this project is very much still in development**

2 changes: 1 addition & 1 deletion android/local.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sdk.dir=/Users/mclark4386/sdk
flutter.sdk=/Users/mclark4386/bin/flutter
flutter.versionName=0.0.3
flutter.versionName=0.0.4
6 changes: 3 additions & 3 deletions coverage/badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions coverage/lcov.info
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,40 @@ DA:114,4
DA:115,2
DA:116,1
DA:119,2
DA:125,1
DA:129,1
DA:130,1
DA:132,2
DA:135,2
DA:136,3
DA:140,2
DA:142,0
DA:145,3
DA:149,2
DA:151,2
DA:153,2
DA:157,1
DA:159,4
DA:162,1
DA:163,1
DA:164,2
DA:165,2
DA:166,2
DA:167,4
DA:168,2
DA:177,1
DA:181,1
DA:182,1
DA:184,2
DA:187,2
DA:188,3
DA:192,2
DA:194,0
DA:197,3
DA:201,2
DA:203,0
DA:205,2
DA:209,1
DA:211,4
DA:214,1
end_of_record
44 changes: 42 additions & 2 deletions lib/flutter_aad.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class FlutterAAD {
}

Future<String> GetTokenWithAuthCodev1(AADConfig config, String authCode,
{void onError(String)}) async {
{void onError(String msg)}) async {
var body = {
"grant_type": "authorization_code",
"client_id": config.ClientID,
Expand Down Expand Up @@ -101,7 +101,7 @@ class FlutterAAD {
}

Future<String> GetTokenWithAuthCodev2(AADConfig config, String authCode,
{void onError(String)}) async {
{void onError(String msg)}) async {
var body = {
"grant_type": "authorization_code",
"client_id": config.ClientID,
Expand Down Expand Up @@ -173,4 +173,44 @@ class FlutterAAD {
return null;
}
}

Future<base_http.Response> GetListItemsResponse(
String site, String title, String token,
{List<String> select, String orderby, List<String> filter}) async {
var url = site;
if (!site.endsWith("/")) {
url += "/";
}
url += "_api/web/lists/getbytitle('$title')/items";

var first = true;
if (select != null && select.length > 0) {
url += "?\$select=" + select.join(",");
first = false;
}

if (filter != null && filter.length > 0) {
if (first) {
url += "?\$filter=" + filter.join(" and ");
first = false;
} else {
url += "&\$filter=" + filter.join(" and ");
}
}

if (orderby != null && orderby.length > 0) {
if (first) {
url += "?\$orderby=$orderby";
} else {
url += "&\$orderby=$orderby";
}
}

print(url);

return await http.get(url, headers: {
"Accept": "application/json;odata=verbose",
"Authorization": "Bearer $token"
});
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_aad
description: A Flutter package for interacting with the Azure AD platform.
version: 0.0.4
version: 0.0.5
author: Matthew Clark <mclark4386@gmail.com>
homepage: https://github.com/mclark4386/flutter_aad

Expand Down
4 changes: 4 additions & 0 deletions test/flutter_aad_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ void main() {
expect((await aad.GetListItems("https://test.site", "Title", "token", select: ["ID","Title","Body","Image","Created","Expires"], orderby: "Created%20desc", filter: ["(StartTime le '01/01/1971')","(EndTime ge '01/01/1971')"]))['access_token'],'good-token-yay');

expect((await aad.GetListItems("https://test.site", "Bad Title", "bad_token")), null);

expect((await aad.GetListItemsResponse("https://test.site", "Title", "token", select: ["ID","Title","Body","Image","Created","Expires"], orderby: "Created%20desc", filter: ["(StartTime le '01/01/1971')","(EndTime ge '01/01/1971')"])).statusCode,200);

expect((await aad.GetListItemsResponse("https://test.site", "Bad Title", "bad_token")).statusCode, 404);
});
// "?\$select=ID,Title,Body,Image,Created,Expires&\$orderby=Created%20desc"
}

0 comments on commit 9c15755

Please sign in to comment.