Add example code
This commit is contained in:
parent
d0f3debf2e
commit
ad17b46cc9
44
README.md
44
README.md
@ -1 +1,43 @@
|
|||||||
A simple command-line application.
|
# Sample Dart SDK
|
||||||
|
|
||||||
|
- Test Example Code
|
||||||
|
|
||||||
|
```dart
|
||||||
|
import 'package:sample_sdk/sdk.dart';
|
||||||
|
import 'package:sample_sdk/sdk/models/category.dart';
|
||||||
|
import 'package:sample_sdk/sdk/models/product.dart';
|
||||||
|
|
||||||
|
void main() async {
|
||||||
|
final sdk = ClientSDK();
|
||||||
|
|
||||||
|
final category = Category(
|
||||||
|
id: 4,
|
||||||
|
name: 'Category 4',
|
||||||
|
parent: Category(
|
||||||
|
id: 1,
|
||||||
|
name: 'Category 1',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await sdk.categoryService.create(category);
|
||||||
|
final categories = await sdk.categoryService.findAll();
|
||||||
|
print(categories);
|
||||||
|
|
||||||
|
final product = Product(
|
||||||
|
id: 4,
|
||||||
|
name: 'Product 4',
|
||||||
|
price: 100.0,
|
||||||
|
category: category,
|
||||||
|
);
|
||||||
|
|
||||||
|
await sdk.productService.create(product);
|
||||||
|
final products = await sdk.productService.findAll();
|
||||||
|
print(products);
|
||||||
|
|
||||||
|
sdk.dispose();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Contributors
|
||||||
|
|
||||||
|
- Sambo Chea <sombochea@cubetiqs.com>
|
||||||
|
Loading…
Reference in New Issue
Block a user