diff --git a/.travis.yml b/.travis.yml index c233d8a0..de2210c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1 @@ -language: dart -with_content_shell: true \ No newline at end of file +language: dart \ No newline at end of file diff --git a/README.md b/README.md index 2a9624ee..711e159a 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,14 @@ # angel_client -[![pub 1.0.0-dev+23](https://img.shields.io/badge/pub-1.0.0--dev+23-red.svg)](https://pub.dartlang.org/packages/angel_client) +[![pub 1.0.0](https://img.shields.io/badge/pub-1.0.0-brightgreen.svg)](https://pub.dartlang.org/packages/angel_client) ![build status](https://travis-ci.org/angel-dart/client.svg) Client library for the Angel framework. - -# Isomorphic -The REST client can run in the browser or on the command-line. +This library provides virtually the same API as an Angel server. +The client can run in the browser or on the command-line. +In addition, the client supports `angel_auth` authentication. # Usage -This library provides the same API as an Angel server. ```dart // Choose one or the other, depending on platform diff --git a/lib/base_angel_client.dart b/lib/base_angel_client.dart index 831177ea..728df035 100644 --- a/lib/base_angel_client.dart +++ b/lib/base_angel_client.dart @@ -18,11 +18,11 @@ const Map _writeHeaders = const { }; _buildQuery(Map params) { - if (params == null || params.isEmpty) return ""; + if (params == null || params.isEmpty || params['query'] is! Map) return ""; List query = []; - params.forEach((k, v) { + params['query'].forEach((k, v) { query.add('$k=${Uri.encodeQueryComponent(v.toString())}'); }); @@ -231,7 +231,7 @@ class BaseAngelService extends Service { @override Future index([Map params]) async { final response = await app.sendUnstreamed( - 'GET', '$basePath/${_buildQuery(params)}', _readHeaders); + 'GET', '$basePath${_buildQuery(params)}', _readHeaders); try { if (response.statusCode != 200) { diff --git a/pubspec.yaml b/pubspec.yaml index 52d5a01a..e7f88483 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_client -version: 1.0.0-dev+23 +version: 1.0.0 description: Client library for the Angel framework. author: Tobe O homepage: https://github.com/angel-dart/angel_client diff --git a/test/io_test.dart b/test/io_test.dart index b379ae4e..fc7056a7 100644 --- a/test/io_test.dart +++ b/test/io_test.dart @@ -37,8 +37,10 @@ main() { }); test("index", () async { - Postcard niagaraFalls = await serverPostcards.create( + Map niagara = await clientPostcards.create( new Postcard(location: "Niagara Falls", message: "Missing you!")); + Postcard niagaraFalls = new Postcard.fromJson(niagara); + print('Niagara Falls: ${niagaraFalls.toJson()}'); List indexed = await clientPostcards.index(); @@ -50,15 +52,14 @@ main() { expect(indexed[0]['location'], equals(niagaraFalls.location)); expect(indexed[0]['message'], equals(niagaraFalls.message)); - Postcard louvre = await serverPostcards.create(new Postcard( + Map l = await clientPostcards.create(new Postcard( location: "The Louvre", message: "The Mona Lisa was watching me!")); + Postcard louvre = new Postcard.fromJson(l); print(god.serialize(louvre)); List typedIndexed = await clientTypedPostcards.index(); expect(typedIndexed.length, equals(2)); expect(typedIndexed[1], equals(louvre)); - }, - skip: - 'Index tests fails for some unknown reason, although it works in production.'); + }); test("create/read", () async { Map opry = {"location": "Grand Ole Opry", "message": "Yeehaw!"}; diff --git a/test/shared.dart b/test/shared.dart index 59031362..6d139b4e 100644 --- a/test/shared.dart +++ b/test/shared.dart @@ -1,10 +1,15 @@ -import "package:angel_framework/src/defs.dart"; +import "package:angel_framework/common.dart"; -class Postcard extends MemoryModel { +class Postcard extends Model { String location; String message; - Postcard({String this.location, String this.message}); + Postcard({String id, this.location, this.message}) { + this.id = id; + } + + factory Postcard.fromJson(Map data) => new Postcard( + id: data['id'], location: data['location'], message: data['message']); @override bool operator ==(other) {