shopware_sdk 0.1.0+11

pub package Build Status

shopware_sdk #

Future-based Dart SDK for the Shopware 5 REST API.

Usage #

   import 'package:shopware_sdk/shopware_sdk.dart';
   
   const String BASE_URL = 'http://shopware.dev/api/';
   const String USERNAME = 'user';
   const String API_TOKEN = 'api_key';
   
   main() async {
     
     // Create a new client
     var client = ShopwareClient(
           baseUrl: BASE_URL,
           username: USERNAME,
           apiToken: API_TOKEN
       );
   
     var categoryResource = new CategoriesResource(client);
   
     // Get category with id 39
     ApiResponse<Category> apiResponse = await categoryResource.findOne(39);
   
     // or use it with then
     categoryResource.findOne(39).then((apiResponse) {
       if (apiResponse.success) {
         print(apiResponse.entity);
       } else {
         print(apiResponse.message);
       }
     });
   
     if (apiResponse.success) {
       // if api response successfully returned
   
       var category = apiResponse.entity;
   
       print("${category.id} - ${category.name}");
   
       // print category entity
       print(category);
   
       // print returned api response
       print(apiResponse.jsonResponse);
     } else {
       // print error message
   
       print(apiResponse.message);
       print(apiResponse.baseResponse.statusCode);
     }
   }

0.1.0 #

  • Initial version.

example/main.dart

import 'package:shopware_sdk/shopware_sdk.dart';


const String BASE_URL = 'http://shopware.dev/api/';
const String USERNAME = 'user';
const String API_TOKEN = 'api_key';

main() async {
  // Create a new client
  var client = ShopwareClient(
      baseUrl: BASE_URL,
      username: USERNAME,
      apiToken: API_TOKEN
  );

  var categoryResource = new CategoriesResource(client);

  // Get category with id 39
  ApiResponse<Category> apiResponse = await categoryResource.findOne(39);

  // or use it with then
//  categoryResource.findOne(39).then((apiResponse) {
//    if (apiResponse.success) {
//      print(apiResponse.entity);
//    } else {
//      print(apiResponse.message);
//    }
//  });

  // if api response successfully returned
  if (apiResponse.success) {

    var category = apiResponse.entity;

    print("${category.id} - ${category.name}");

    // you can direct access to json response returned from shopware api
//    print(apiResponse.jsonResponse);

  } else {
    // print error message
    print(apiResponse.message);
    print(apiResponse.baseResponse.statusCode);
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  shopware_sdk: ^0.1.0+11

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:shopware_sdk/shopware_sdk.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
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 15, 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 primary library package:shopware_sdk/shopware_sdk.dart.

Health issues and suggestions

Document public APIs. (-0.10 points)

218 out of 225 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.1.0 <3.0.0
http ^0.12.0+2 0.12.0+2
Transitive dependencies
async 2.2.0
charcode 1.1.2
collection 1.14.11
http_parser 3.1.3
meta 1.1.7
path 1.6.2
pedantic 1.8.0+1
source_span 1.5.5
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6

Admin