json_api 0.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new59

JSON:API v1.0 HTTP Client

This is a super simple implementation of JSON:API Client.

Usage example

import 'package:json_api/json_api.dart';
import 'package:json_api_document/json_api_document.dart';

void main() async {
  final client = JsonApiClient(baseUrl: 'http://localhost:8888');
  final response = await client.fetchResource('/example');
  print((response.document as DataDocument).data.resources.first.attributes); // Attributes{message: Hello world!}
}

Supported methods

  • addToMany Adds the identifiers to the to-many relationship via POST request to the url.
  • createResource Creates a new resource sending a POST request to the url.
  • deleteResource Deletes the resource sending a DELETE request to the url.
  • deleteToMany Deletes the identifiers from the to-many relationship via DELETE request to the url.
  • deleteToOne Removes a to-one relationship sending PATCH request with "null" data to the url.
  • fetchRelationship Fetches a Document containing identifier(s) from the given url.
  • fetchResource Fetches a Document containing resource(s) from the given url.
  • setToMany Updates (replaces!) a to-many relationship sending the identifiers via PATCH request to the url.
  • setToOne Creates or updates a to-one relationship sending a corresponding identifier via PATCH request to the url.
  • updateResource Updates the resource sending a PATCH request to the url.

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Unreleased

0.0.1 - 2019-01-08

Added

  • Initial client implementation

example/example.dart

import 'package:json_api/json_api.dart';
import 'package:json_api_document/json_api_document.dart';

/// This is a simple example of JsonApiClient.
///
/// Don't forget to start server.dart first!
void main() async {
  final client = JsonApiClient(baseUrl: 'http://localhost:8888');
  final response = await client.fetchResource('/example');
  print((response.document as DataDocument).data.resources.first.attributes);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  json_api: ^0.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:json_api/json_api.dart';
  
Version Uploaded Documentation Archive
0.0.1 Jan 9, 2019 Go to the documentation of json_api 0.0.1 Download json_api 0.0.1 archive
0.0.1-dev6 Jan 9, 2019 Go to the documentation of json_api 0.0.1-dev6 Download json_api 0.0.1-dev6 archive
0.0.1-dev5 Jan 9, 2019 Go to the documentation of json_api 0.0.1-dev5 Download json_api 0.0.1-dev5 archive
0.0.1-dev4 Jan 9, 2019 Go to the documentation of json_api 0.0.1-dev4 Download json_api 0.0.1-dev4 archive
0.0.1-dev3 Jan 8, 2019 Go to the documentation of json_api 0.0.1-dev3 Download json_api 0.0.1-dev3 archive
0.0.1-dev2 Jan 8, 2019 Go to the documentation of json_api 0.0.1-dev2 Download json_api 0.0.1-dev2 archive
0.0.1-dev1 Jan 8, 2019 Go to the documentation of json_api 0.0.1-dev1 Download json_api 0.0.1-dev1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
23
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
59
Learn more about scoring.

We analyzed this package on Jan 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.10

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:json_api/json_api.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http ^0.12.0 0.12.0+1
json_api_document ^0.3.9 0.3.9 0.4.0-dev.02
Transitive dependencies
async 2.0.8
charcode 1.1.2
collection 1.14.11
http_parser 3.1.3
meta 1.1.7
path 1.6.2
source_span 1.5.1
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
pubspec_version ^0.1.0
test ^1.3.0