djustin 0.2.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

Djustin #

Dart CI CodeFactor License Pub

Djustin is a library for Dart programming language that helps to interact with Justin Delivery Service using its OpenAPI. It works fine with Dart and Flutter applications, but it is assumed that the other platforms (such as web and server) will also haven't problems with Djustin.

Features #

  • Fast and simple
  • Only one dependency (package:http)
  • Supports Flutter
  • Provides all the functionality of the Justin OpenAPI

Supported requests #

Library provides an ability to receive the following information from the Justin Service:

  • Branches
    • Info about all branches
    • Info about branch by number
    • Info about branches by urban area
    • Info about the nearest branches
  • Tracking
    • Tracking info by the tracking number
    • Tracking history by the tracking number
  • Info about branch types
  • Info about all urban areas in Justin network
  • Info about available services

Getting started #

First, add the following dependency to your pubspec.yaml:

dependencies:
  djustin: ^0.2.1

Then import the library:

import 'package:djustin/djustin.dart';

and just use it.

The example of simple usage.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

0.0.1 #

  • Initial early version, created by Maksym Omelchenko.

0.1.0 #

  • Added models for all types of requests.
  • Added services for requesting data thorough network connecting.
  • Added converters for models to convert data from JSON.
  • Added tests.

0.1.1 #

  • Removed dart:mirrors dependency.
  • Updated justin services.

0.2.0 #

  • Updated justin services. For now you can request directly response result as well as response itself.
  • Added ability to provide error handlers for justin and http errors.

0.2.1 #

  • Refactored code according to default dart code conversions.

example/djustin_example.dart

import 'package:djustin/djustin.dart';

Future<void> main() async {
  // Initiate Service for Justin OpenAPI
  var service = JustinService();

  await printTracking(service, '201810165');
  // Will print:
  // Tracking {
  // orderNumber: 201810165,
  // orderDescription: Замовлення клієнта 201810165 від 7/25/2018,
  // dateTime: 2019-02-27 10:20:51.000,
  // status: Одержано,
  // departmentNumber: ,
  // departmentAddress:
  // }

  await printBranch(service, 2);
  // Will print info about branch number 2

  await printBranch(service, 999);
  // Will print:
  // Branch with the specified number not found

  await printAllBranches(service);
  // Will print info about all branches

  service.close();
}

/// Simple example that prints tracking info using response form Justin OpenAPI
/// for a given `trackingNumber`
void printBranch(JustinService service, int branchNumber) async {
  // Request info about branch with a `branchNumber` number
  var branchResponse = await service.getBranchResponse(branchNumber);
  if (branchResponse.status != Response.statusOk) {
    // If error occurs (ex. if there is no branch info for provided `branchNumber`
    print(branchResponse.message.text[Language.EN]);
  } else {
    // Take a tracking info from the response
    var tracking = branchResponse.results.first;
    print(tracking);
  }
}

/// Simple example that prints tracking info using response form Justin OpenAPI
/// for a given `trackingNumber`
void printTracking(JustinService service, String trackingNumber) async {
  // Make a request for a tracking info
  var trackingResponse = await service.getTrackingResponse(trackingNumber);
  if (trackingResponse.status != Response.statusOk) {
    // If error occurs (ex. if there is no tracking info for provided `trackingNumber`
    print(trackingResponse.message.text[Language.EN]);
  } else {
    // Take a tracking info from the response
    var tracking = trackingResponse.results.first;
    print(tracking);
  }
}

/// Simple example that prints all branches from Justin OpenAPI
void printAllBranches(JustinService service) async {
  // Make a request for all Justin branches
  var allBranchesResponse = await service.getBranchesAllResponse();
  // Take a result list from the response
  var allBranches = allBranchesResponse.results;
  print(allBranches);
}

Use this package as a library

1. Depend on it

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


dependencies:
  djustin: ^0.2.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:djustin/djustin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Jul 10, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Analysis suggestions

Package not compatible with runtime flutter-web on web

Because of the import of dart:io via the import chain package:djustin/djustin.dartpackage:djustin/src/djustin_base.dartpackage:djustin/src/service/service.dartdart:io

Package not compatible with runtime web

Because of the import of dart:io via the import chain package:djustin/djustin.dartpackage:djustin/src/djustin_base.dartpackage:djustin/src/service/service.dartdart:io

Health issues and suggestions

Document public APIs. (-0.61 points)

150 out of 152 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
http ^0.12.0+4 0.12.1
Transitive dependencies
charcode 1.1.3
collection 1.14.13 1.15.0-nullsafety
http_parser 3.1.4
meta 1.2.2 1.3.0-nullsafety
path 1.7.0
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0 1.3.0-nullsafety
Dev dependencies
pedantic ^1.8.0 1.9.2
test ^1.6.0