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]
94
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.5

Health suggestions

Fix lib/src/entities/category.dart. (-3.45 points)

Analysis of lib/src/entities/category.dart reported 7 hints, including:

line 84 col 9: Unnecessary new keyword.

line 113 col 17: Unnecessary new keyword.

line 118 col 17: Unnecessary new keyword.

line 150 col 21: Unnecessary new keyword.

line 152 col 27: Unnecessary new keyword.

Fix lib/src/entities/article.dart. (-1.49 points)

Analysis of lib/src/entities/article.dart reported 3 hints:

line 70 col 58: Unnecessary new keyword.

line 197 col 9: Unnecessary new keyword.

line 402 col 60: Unnecessary new keyword.

Fix lib/src/entities/api_response_entity.dart. (-1 points)

Analysis of lib/src/entities/api_response_entity.dart reported 2 hints:

line 37 col 16: Unnecessary new keyword.

line 57 col 12: Unnecessary new keyword.

Fix lib/src/services/shopware_client.dart. (-0.50 points)

Analysis of lib/src/services/shopware_client.dart reported 1 hint:

line 20 col 34: Unnecessary new keyword.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
http ^0.12.0+2 0.12.0+4
Transitive dependencies
async 2.4.0
charcode 1.1.3
collection 1.14.12
http_parser 3.1.3
meta 1.1.8
path 1.6.4
pedantic 1.9.0
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6