1.0.0
This commit is contained in:
parent
f73b802392
commit
38eb394078
6 changed files with 23 additions and 19 deletions
|
@ -1,2 +1 @@
|
|||
language: dart
|
||||
with_content_shell: true
|
|
@ -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
|
||||
|
|
|
@ -18,11 +18,11 @@ const Map<String, String> _writeHeaders = const {
|
|||
};
|
||||
|
||||
_buildQuery(Map params) {
|
||||
if (params == null || params.isEmpty) return "";
|
||||
if (params == null || params.isEmpty || params['query'] is! Map) return "";
|
||||
|
||||
List<String> 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) {
|
||||
|
|
|
@ -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 <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/angel_client
|
||||
|
|
|
@ -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!"};
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue