@@ -20,6 +20,7 @@ import 'package:woosignal/models/response/continent.dart';
2020import 'package:woosignal/models/response/currencies.dart' ;
2121import 'package:woosignal/models/response/customer_download.dart' ;
2222import 'package:woosignal/models/response/order_batch.dart' as ob;
23+ import 'package:woosignal/models/response/product_tag.dart' ;
2324import 'package:woosignal/models/response/refund.dart' ;
2425import 'package:woosignal/models/response/order_notes.dart' ;
2526import 'package:woosignal/models/response/coupon.dart' ;
@@ -52,7 +53,7 @@ import 'package:woosignal/models/response/setting_option_batch.dart';
5253import 'package:woosignal/models/response/product_batch.dart' ;
5354
5455/// WooSignal Package version
55- const String wooSignalVersion = "3.0.5 " ;
56+ const String wooSignalVersion = "3.1.0 " ;
5657
5758class WooSignal {
5859 WooSignal ._privateConstructor ();
@@ -85,7 +86,7 @@ class WooSignal {
8586 /// Print to the console a [message]
8687 void _printLog (String message) {
8788 if (_debugMode == true ) {
88- print ("WOOSIGNAL LOG: " + message);
89+ print ("WooSignal LOG: $ message " );
8990 }
9091 }
9192
@@ -99,7 +100,7 @@ class WooSignal {
99100 required String path,
100101 required T Function (dynamic json) jsonResponse,
101102 String postUrl = "/request" }) async {
102- _printLog ("Parameters: " + payload. toString () );
103+ _printLog ("Parameters: $ payload " );
103104 payload = _standardPayload (method, payload, path);
104105
105106 dynamic json = await _apiProvider.post (postUrl, payload);
@@ -1380,4 +1381,89 @@ class WooSignal {
13801381 jsonResponse: (json) => ProductBatch .fromJson (json),
13811382 );
13821383 }
1384+
1385+ /// https://woosignal.com/docs/api/1.0/products#create-product-tags
1386+ Future <ProductTag ?> createProductTag (
1387+ {required String name, String ? slug, String ? description}) async {
1388+ Map <String , dynamic > payload = {'name' : name};
1389+ if (slug != null ) payload['slug' ] = slug;
1390+ if (description != null ) payload['description' ] = description;
1391+
1392+ return await _wooSignalRequest <ProductTag ?>(
1393+ method: "post" ,
1394+ path: "products/tags" ,
1395+ payload: payload,
1396+ jsonResponse: (json) => ProductTag .fromJson (json),
1397+ );
1398+ }
1399+
1400+ /// https://woosignal.com/docs/api/1.0/products#create-product-tag
1401+ Future <ProductTag ?> retrieveProductTag (int id) async {
1402+ return await _wooSignalRequest <ProductTag ?>(
1403+ method: "get" ,
1404+ path: "products/tags/" + id.toString (),
1405+ jsonResponse: (json) => ProductTag .fromJson (json),
1406+ );
1407+ }
1408+
1409+ /// https://woosignal.com/docs/api/1.0/products#create-product-tags
1410+ Future <List <ProductTag >?> getProductTags (
1411+ {String ? context,
1412+ int ? page,
1413+ int ? perPage,
1414+ String ? search,
1415+ List <int >? exclude,
1416+ List <int >? include,
1417+ int ? offset,
1418+ String ? order,
1419+ String ? orderBy,
1420+ bool ? hideEmpty,
1421+ int ? product,
1422+ String ? slug}) async {
1423+ Map <String , dynamic > payload = {};
1424+
1425+ if (context != null ) payload["context" ] = context;
1426+ if (page != null ) payload["page" ] = page;
1427+ if (perPage != null ) payload["per_page" ] = perPage;
1428+ if (search != null ) payload["search" ] = search;
1429+ if (exclude != null ) payload["exclude" ] = exclude;
1430+ if (include != null ) payload["include" ] = include;
1431+ if (offset != null ) payload["offset" ] = offset;
1432+ if (order != null ) payload["order" ] = order;
1433+ if (orderBy != null ) payload["orderby" ] = orderBy;
1434+ if (hideEmpty != null ) payload["hide_empty" ] = hideEmpty;
1435+ if (product != null ) payload["product" ] = product;
1436+ if (slug != null ) payload["slug" ] = slug;
1437+
1438+ return await _wooSignalRequest <List <ProductTag >?>(
1439+ method: "get" ,
1440+ path: "products/tags" ,
1441+ payload: payload,
1442+ jsonResponse: (json) =>
1443+ (json as List ).map ((i) => ProductTag .fromJson (i)).toList (),
1444+ );
1445+ }
1446+
1447+ /// https://woosignal.com/docs/api/1.0/products#create-product-tags
1448+ Future <ProductTag ?> updateProductTag (int productTagId,
1449+ {Map <String , dynamic >? data}) async {
1450+ return await _wooSignalRequest <ProductTag ?>(
1451+ method: "put" ,
1452+ path: "products/tags/" + productTagId.toString (),
1453+ payload: data ?? {},
1454+ jsonResponse: (json) => ProductTag .fromJson (json),
1455+ );
1456+ }
1457+
1458+ /// https://woosignal.com/docs/api/1.0/products#delete-product-tags
1459+ Future <ProductTag ?> deleteProductTag (int productTagId,
1460+ {bool force = false }) async {
1461+ Map <String , dynamic > payload = {"force" : force};
1462+ return await _wooSignalRequest <ProductTag ?>(
1463+ method: "delete" ,
1464+ path: "products/tags/" + productTagId.toString (),
1465+ payload: payload,
1466+ jsonResponse: (json) => ProductTag .fromJson (json),
1467+ );
1468+ }
13831469}
0 commit comments