Task: Add sample client sdk
This commit is contained in:
commit
82de95b4b7
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
# Files and directories created by pub.
|
||||
.dart_tool/
|
||||
.packages
|
||||
|
||||
# Conventional directory for build output.
|
||||
build/
|
3
CHANGELOG.md
Normal file
3
CHANGELOG.md
Normal file
@ -0,0 +1,3 @@
|
||||
## 1.0.0
|
||||
|
||||
- Initial version.
|
16
analysis_options.yaml
Normal file
16
analysis_options.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
# Defines a default set of lint rules enforced for projects at Google. For
|
||||
# details and rationale, see
|
||||
# https://github.com/dart-lang/pedantic#enabled-lints.
|
||||
|
||||
include: package:pedantic/analysis_options.yaml
|
||||
|
||||
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
|
||||
|
||||
# Uncomment to specify additional rules.
|
||||
# linter:
|
||||
# rules:
|
||||
# - camel_case_types
|
||||
|
||||
# analyzer:
|
||||
# exclude:
|
||||
# - path/to/excluded/files/**
|
3
bin/sample_dart_dsdk.dart
Normal file
3
bin/sample_dart_dsdk.dart
Normal file
@ -0,0 +1,3 @@
|
||||
void main(List<String> arguments) {
|
||||
print('Hello world!');
|
||||
}
|
20
lib/sdk/ClientSDK.dart
Normal file
20
lib/sdk/ClientSDK.dart
Normal file
@ -0,0 +1,20 @@
|
||||
import 'package:sample_dart_dsdk/sdk/services/CategoryService.dart';
|
||||
import 'package:sample_dart_dsdk/sdk/services/ProductService.dart';
|
||||
|
||||
class ClientSDK {
|
||||
static var _instance;
|
||||
|
||||
static ClientSDK getInstance() {
|
||||
if (_instance == null) {
|
||||
ClientSDK();
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
||||
ProductService getProductService() {
|
||||
return ProductService();
|
||||
}
|
||||
|
||||
CategoryService getCategoryService() => CategoryService();
|
||||
}
|
6
lib/sdk/models/CategoryModel.dart
Normal file
6
lib/sdk/models/CategoryModel.dart
Normal file
@ -0,0 +1,6 @@
|
||||
class Category {
|
||||
int id;
|
||||
String name;
|
||||
|
||||
Category(this.id, this.name);
|
||||
}
|
20
lib/sdk/models/ProductModel.dart
Normal file
20
lib/sdk/models/ProductModel.dart
Normal file
@ -0,0 +1,20 @@
|
||||
class Product {
|
||||
int id;
|
||||
String name;
|
||||
double price;
|
||||
|
||||
Product(this.id, this.name, this.price);
|
||||
|
||||
static Product fromJson(dynamic json) => Product(
|
||||
json['id'],
|
||||
json['name'],
|
||||
json['price'],
|
||||
);
|
||||
}
|
||||
|
||||
class ProductRequest {
|
||||
String name;
|
||||
double price;
|
||||
|
||||
ProductRequest(this.name, this.price);
|
||||
}
|
7
lib/sdk/services/CategoryService.dart
Normal file
7
lib/sdk/services/CategoryService.dart
Normal file
@ -0,0 +1,7 @@
|
||||
import 'package:sample_dart_dsdk/sdk/models/CategoryModel.dart';
|
||||
|
||||
class CategoryService {
|
||||
List<Category> getAll() {
|
||||
return List.empty();
|
||||
}
|
||||
}
|
15
lib/sdk/services/ProductService.dart
Normal file
15
lib/sdk/services/ProductService.dart
Normal file
@ -0,0 +1,15 @@
|
||||
import 'package:sample_dart_dsdk/sdk/models/ProductModel.dart';
|
||||
|
||||
class ProductService {
|
||||
List<Product> getAll() {
|
||||
return List.empty();
|
||||
}
|
||||
|
||||
Product getOne() {
|
||||
return Product.fromJson(null);
|
||||
}
|
||||
|
||||
Product create() {
|
||||
return Product.fromJson(null);
|
||||
}
|
||||
}
|
13
lib/test.dart
Normal file
13
lib/test.dart
Normal file
@ -0,0 +1,13 @@
|
||||
import 'package:sample_dart_dsdk/sdk/ClientSDK.dart';
|
||||
|
||||
void main(List<String> args) {
|
||||
var client = ClientSDK.getInstance();
|
||||
var productService = client.getProductService();
|
||||
var products = productService.getAll();
|
||||
|
||||
print(products);
|
||||
|
||||
var categoryService = client.getCategoryService();
|
||||
var categories = categoryService.getAll();
|
||||
print(categories);
|
||||
}
|
12
pubspec.lock
Normal file
12
pubspec.lock
Normal file
@ -0,0 +1,12 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
pedantic:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.11.1"
|
||||
sdks:
|
||||
dart: ">=2.12.0 <3.0.0"
|
13
pubspec.yaml
Normal file
13
pubspec.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
name: sample_dart_dsdk
|
||||
description: A simple command-line application.
|
||||
version: 1.0.0
|
||||
# homepage: https://www.example.com
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
|
||||
# dependencies:
|
||||
# path: ^1.8.0
|
||||
|
||||
dev_dependencies:
|
||||
pedantic: ^1.10.0
|
Loading…
Reference in New Issue
Block a user