Task: Add sample client sdk

This commit is contained in:
Sambo Chea 2021-09-04 19:07:29 +07:00
commit 82de95b4b7
13 changed files with 135 additions and 0 deletions

6
.gitignore vendored Normal file
View 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
View File

@ -0,0 +1,3 @@
## 1.0.0
- Initial version.

1
README.md Normal file
View File

@ -0,0 +1 @@
A simple command-line application.

16
analysis_options.yaml Normal file
View 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/**

View File

@ -0,0 +1,3 @@
void main(List<String> arguments) {
print('Hello world!');
}

20
lib/sdk/ClientSDK.dart Normal file
View 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();
}

View File

@ -0,0 +1,6 @@
class Category {
int id;
String name;
Category(this.id, this.name);
}

View 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);
}

View File

@ -0,0 +1,7 @@
import 'package:sample_dart_dsdk/sdk/models/CategoryModel.dart';
class CategoryService {
List<Category> getAll() {
return List.empty();
}
}

View 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
View 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
View 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
View 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