Skip to content

Commit

Permalink
format dart source and update pubspec as suggested by package repo
Browse files Browse the repository at this point in the history
  • Loading branch information
SpiralArm Consulting Ltd committed Sep 7, 2019
1 parent 1916a6d commit 331f2a4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [0.0.1] - 07 Sep 2019
## [0.1.1] - 07 Sep 2019

* Tidy up pubspec and format dart source.

## [0.1.0] - 07 Sep 2019

* Initial release.
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,6 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.0"
version: "0.1.1"
sdks:
dart: ">=2.2.2 <3.0.0"
22 changes: 11 additions & 11 deletions lib/src/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import 'package:http/http.dart' as http;
class GpsCoord {
final double lat;
final double long;
GpsCoord({@required this.lat,@required this.long});
GpsCoord({@required this.lat, @required this.long});
}

/// API to access the WAQI API - A valid [token] is required to use the API.
/// See https://aqicn.org/api/ and https://aqicn.org/json-api/doc/ for more details
/// API to access the WAQI API - A valid [token] is required to use the API.
/// See https://aqicn.org/api/ and https://aqicn.org/json-api/doc/ for more details
class Api {

final String token;
final String _endpoint = "https://api.waqi.info";

Expand All @@ -23,10 +22,11 @@ class Api {
/// Internal call to query our API
_callAPI(String url) async {
var result = await http.get(Uri.encodeFull(url));
if(result.statusCode == 200){
return jsonDecode(result.body);
if (result.statusCode == 200) {
return jsonDecode(result.body);
} else {
throw Exception("WAQIAPI API Error calling $url. Status code: ${result.statusCode}");
throw Exception(
"WAQIAPI API Error calling $url. Status code: ${result.statusCode}");
}
}

Expand All @@ -49,15 +49,15 @@ class Api {
}

/// Get all the stations within a given lat/lng bounds defined by [coords1] and [coords2]
mapQuery( GpsCoord coords1, GpsCoord coords2) async {
String apiUrl = "$_endpoint/map/bounds/?latlng=${coords1.lat},${coords1.long},${coords2.lat},${coords2.long}&token=$token";
return _callAPI(apiUrl);
mapQuery(GpsCoord coords1, GpsCoord coords2) async {
String apiUrl =
"$_endpoint/map/bounds/?latlng=${coords1.lat},${coords1.long},${coords2.lat},${coords2.long}&token=$token";
return _callAPI(apiUrl);
}

/// search stations by [name]
searchByName(String name) async {
String apiUrl = "$_endpoint/search/?keyword=$name&token=$token";
return _callAPI(apiUrl);
}

}
2 changes: 1 addition & 1 deletion lib/waqiapi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ library waqiapi;

/// WAQI is the World Air Quality Index project and this is a Flutter plugin to access their API
/// for more info on WAQI see http://aqicn.org/contact
export 'src/api.dart';
export 'src/api.dart';
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: waqiapi
description: A Flutter API to access the World Air Quality Index API.
version: 0.1.0
description: A Flutter package that enables you to access the World Air Quality Index API to get data on air quality around the world.
version: 0.1.1
author: Steve Rogers <[email protected]>
homepage: https://github.com/magnatronus/waqiapi.git

Expand Down

0 comments on commit 331f2a4

Please sign in to comment.