bungie_api_dart 1.13.0

Bungie API Dart support #

This project implements Dart definitions and API helpers for the Bungie.net API. It's based on bungie-api-ts that is meant for use in [Destiny Item Manager] (http://destinyitemmanager.com), but should be general enough to use in any project. The code is completely generated from Bungie's documentation - I considered using something like Swagger Codegen, but instead opted for a custom generator so we could make the result as nice as possible.

Install #

add this to your dependencies block in pubspec.yaml

dependencies:
  bungie_api_dart:
    git: https://github.com/marquesinijatinha/bungie-api-dart

Interfaces and Enums #

There are definitions for every type defined in the Bungie.net services. See their documentation for a list - the interface names are the last part of the full name (for example, Destiny.Definitions.DestinyVendorActionDefinition becomes DestinyVendorActionDefinition). There are a few exceptions, like SingleComponentResponseOfDestinyInventoryComponent, which have been mapped into nicer forms like SingleComponentResponse<DestinyInventoryComponent>, and the server responses, which are now ServerResponse<T> instead of something like DestinyCharacterResponse.

API Helpers #

In addition to the types, there are also simple helper functions for each API endpoint. They define the inputs and outputs to that endpoint, and will call a user-provided function with HTTP request info that you can then use to make an HTTP request. This pattern was used so the API helpers could provide full type information. These helpers are not a full API client - they assist in building one. An example:

import 'dart:async';
import 'package:http/http.dart' as http;
import 'package:bungie_api_dart/destiny2.dart';

class BungieApiService{
  Future<ServerResponse<DestinyManifest>> getManifest(){
    return getDestinyManifest(new Client());
  }
}
class Client implements HttpClient{
  static const API_KEY = "your_key";
  @override
    Future<Object> request(HttpClientConfig config) {
      if(config.method == 'GET'){
        return http.get(config.url, headers: {'X-API-Key': API_KEY});
      }
      return http.post(config.url, headers: {'X-API-Key': API_KEY});
    }
}

Build #

./install.sh && ./build.sh

Use this package as a library

1. Depend on it

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


dependencies:
  bungie_api_dart: ^1.13.0

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:bungie_api_dart/app.dart';
import 'package:bungie_api_dart/app/api.dart';
import 'package:bungie_api_dart/app/interfaces.dart';
import 'package:bungie_api_dart/common.dart';
import 'package:bungie_api_dart/communitycontent.dart';
import 'package:bungie_api_dart/communitycontent/api.dart';
import 'package:bungie_api_dart/communitycontent/interfaces.dart';
import 'package:bungie_api_dart/content.dart';
import 'package:bungie_api_dart/content/api.dart';
import 'package:bungie_api_dart/content/interfaces.dart';
import 'package:bungie_api_dart/destiny2.dart';
import 'package:bungie_api_dart/destiny2/api.dart';
import 'package:bungie_api_dart/destiny2/interfaces.dart';
import 'package:bungie_api_dart/fireteam.dart';
import 'package:bungie_api_dart/fireteam/api.dart';
import 'package:bungie_api_dart/fireteam/interfaces.dart';
import 'package:bungie_api_dart/forum.dart';
import 'package:bungie_api_dart/forum/api.dart';
import 'package:bungie_api_dart/forum/interfaces.dart';
import 'package:bungie_api_dart/groupv2.dart';
import 'package:bungie_api_dart/groupv2/api.dart';
import 'package:bungie_api_dart/groupv2/interfaces.dart';
import 'package:bungie_api_dart/http.dart';
import 'package:bungie_api_dart/platform.dart';
import 'package:bungie_api_dart/trending.dart';
import 'package:bungie_api_dart/trending/api.dart';
import 'package:bungie_api_dart/trending/interfaces.dart';
import 'package:bungie_api_dart/user.dart';
import 'package:bungie_api_dart/user/api.dart';
import 'package:bungie_api_dart/user/interfaces.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
19
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
50
Overall:
Weighted score of the above. [more]
19
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in libraries.

Health suggestions

Fix lib/destiny2/interfaces.dart. (-99.97 points)

Analysis of lib/destiny2/interfaces.dart reported 1637 hints, including:

line 26 col 1: Prefer using /// for doc comments.

line 33 col 3: Prefer using /// for doc comments.

line 40 col 3: Prefer using /// for doc comments.

line 42 col 3: Prefer using /// for doc comments.

line 44 col 3: Prefer using /// for doc comments.

Fix lib/destiny2/api.dart. (-43.53 points)

Analysis of lib/destiny2/api.dart reported 114 hints, including:

line 20 col 1: Prefer using /// for doc comments.

line 31 col 3: Prefer using /// for doc comments.

line 39 col 3: Prefer using /// for doc comments.

line 43 col 1: Prefer using /// for doc comments.

line 62 col 3: Prefer using /// for doc comments.

Fix lib/groupv2/api.dart. (-40.33 points)

Analysis of lib/groupv2/api.dart reported 103 hints, including:

line 19 col 1: Prefer using /// for doc comments.

line 29 col 1: Prefer using /// for doc comments.

line 40 col 3: Prefer using /// for doc comments.

line 44 col 1: Prefer using /// for doc comments.

line 58 col 3: Prefer using /// for doc comments.

Fix additional 18 files with analysis or formatting issues. (-107.15 points)

Additional issues in the following files:

  • lib/forum/api.dart (38 hints)
  • lib/fireteam/api.dart (28 hints)
  • lib/communitycontent/api.dart (27 hints)
  • lib/app/interfaces.dart (26 hints)
  • lib/groupv2/interfaces.dart (25 hints)
  • lib/content/api.dart (16 hints)
  • lib/trending/interfaces.dart (14 hints)
  • lib/user/interfaces.dart (13 hints)
  • lib/user/api.dart (11 hints)
  • lib/trending/api.dart (7 hints)
  • lib/app/api.dart (5 hints)
  • lib/http.dart (5 hints)
  • lib/common.dart (4 hints)
  • lib/content/interfaces.dart (2 hints)
  • lib/fireteam/interfaces.dart (2 hints)
  • lib/communitycontent/interfaces.dart (1 hint)
  • lib/forum/interfaces.dart (1 hint)
  • lib/platform.dart (1 hint)

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and bungie_api_dart.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.58.0 <3.0.0