From d85e946c475af8ee112806d65d63809948235fd2 Mon Sep 17 00:00:00 2001 From: Ivan Kamkin <234-Ivan.Kamkin@users.noreply.git.saltov.dynabic.com> Date: Fri, 21 Jun 2024 06:02:30 +0500 Subject: [PATCH 1/3] Version of SDK updated --- CHANGELOG.md | 4 ++++ README.md | 4 ++-- lib/src/api_client.dart | 2 +- pubspec.yaml | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fe5391..e732a75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 1.24.6 + +* June 2024 Release + ## 1.24.5 * May 2024 Release diff --git a/README.md b/README.md index aa84d63..e24be1b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Dart test](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dart/actions/workflows/dart.yml/badge.svg?branch=main)](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dart/actions/workflows/dart.yml) - API version: 3.0 -- SDK version: 1.24.5 +- SDK version: 1.24.6 This SDK allows you to work with Aspose.BarCode for Cloud REST APIs in your Dart or Flutter applications quickly and easily @@ -34,7 +34,7 @@ Add this dependency to your *pubspec.yaml*: ```yaml dependencies: - aspose_barcode_cloud: 1.24.5 + aspose_barcode_cloud: 1.24.6 ``` ## Sample usage diff --git a/lib/src/api_client.dart b/lib/src/api_client.dart index 404224e..3219fcf 100644 --- a/lib/src/api_client.dart +++ b/lib/src/api_client.dart @@ -10,7 +10,7 @@ import 'api_helper.dart'; import 'auth/authentication.dart'; /// Current SDK Version -const SDK_VERSION = "1.24.5"; +const SDK_VERSION = "1.24.6"; /// ApiClient is responsible for making HTTP requests to the API. class ApiClient { diff --git a/pubspec.yaml b/pubspec.yaml index 1533d6e..650f082 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: aspose_barcode_cloud description: This SDK allows you to work with Aspose.BarCode for Cloud REST APIs in your Dart or Flutter applications quickly and easily -version: 1.24.5 +version: 1.24.6 homepage: https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dart platforms: From 207ac290432202e7786b6599831e9ebcad0050dc Mon Sep 17 00:00:00 2001 From: Denis Averin Date: Thu, 27 Jun 2024 11:23:30 +0700 Subject: [PATCH 2/3] Update package lints --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 650f082..5ff8cc6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,5 +17,5 @@ dependencies: http: '>=0.13.0 <2.0.0' dev_dependencies: - lints: ^3.0.0 + lints: ^4.0.0 test: ^1.25.1 From 5520611f09f8270bc8252fe3be42966d37de39cc Mon Sep 17 00:00:00 2001 From: Denis Averin Date: Thu, 27 Jun 2024 12:41:08 +0700 Subject: [PATCH 3/3] Insert example into README.md --- Makefile | 6 ++++- README.md | 45 +++++++++++++++++++++++-------------- scripts/insert-example.bash | 8 +++++++ scripts/insert-example.dart | 41 +++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 18 deletions(-) create mode 100755 scripts/insert-example.bash create mode 100644 scripts/insert-example.dart diff --git a/Makefile b/Makefile index 7b6a4b9..b751adb 100644 --- a/Makefile +++ b/Makefile @@ -23,10 +23,14 @@ fix: init dart fix --apply .PHONY: after-gen -after-gen: fix +after-gen: fix insert-example ./scripts/annotate-deprecated.bash @dart format . +.PHONY: insert-example +insert-example: + ./scripts/insert-example.bash + .PHONY: update update: dart pub upgrade diff --git a/README.md b/README.md index e24be1b..3721344 100644 --- a/README.md +++ b/README.md @@ -44,44 +44,55 @@ dependencies: The examples below show how you can generate QR barcode and save it into a local file and then recognize using **aspose_barcode_cloud**: ```dart -import 'package:aspose_barcode_cloud/aspose_barcode_cloud.dart' as barcode; - -import 'dart:typed_data'; import 'dart:io'; +import 'dart:typed_data'; -import 'package:http/http.dart'; +import 'package:aspose_barcode_cloud/aspose_barcode_cloud.dart'; +import 'package:http/http.dart' show MultipartFile; Future main() async { const fileName = "qr.png"; - // Setup - final apiClient = barcode.ApiClient( + + final api = BarcodeApi(ApiClient(Configuration( clientId: "Client Id from https://dashboard.aspose.cloud/applications", clientSecret: "Client Secret from https://dashboard.aspose.cloud/applications", - ); - final api = barcode.BarcodeApi(apiClient); + // For testing only + accessToken: Platform.environment["TEST_CONFIGURATION_ACCESS_TOKEN"], + ))); // Generate image with barcode - Uint8List? generated = - await api.getBarcodeGenerate("QR", "text", textLocation: "None"); + final Uint8List generated = await api.getBarcodeGenerate( + EncodeBarcodeType.QR.toString(), + "text", + textLocation: CodeLocation.None.toString(), + ); + // Save generated image to file - await File(fileName).writeAsBytes(generated!); - print("Generated image saved to " + fileName); + File(fileName).writeAsBytesSync(generated); + print("Generated image saved to '$fileName'"); // Recognize generated image final formFile = MultipartFile.fromBytes("image", generated.toList(), filename: "barcode.png"); - barcode.BarcodeResponseList? recognized = - await api.postBarcodeRecognizeFromUrlOrContent(image: formFile); + final BarcodeResponseList recognized = await api.scanBarcode( + formFile, + decodeTypes: [DecodeBarcodeType.QR], + ); - print("Recognized Type: " + recognized!.barcodes![0].type!); - print("Recognized Value: " + recognized.barcodes![0].barcodeValue!); + if (recognized.barcodes != null && recognized.barcodes!.isNotEmpty) { + print("Recognized Type: ${recognized.barcodes![0].type!}"); + print("Recognized Value: ${recognized.barcodes![0].barcodeValue!}"); + } else { + print("No barcode found"); + } } + ``` ## Dependencies -- http: '>=0.13.0 <0.14.0' +- http: '>=0.13.0 <2.0.0' ## Licensing diff --git a/scripts/insert-example.bash b/scripts/insert-example.bash new file mode 100755 index 0000000..f7f3e9a --- /dev/null +++ b/scripts/insert-example.bash @@ -0,0 +1,8 @@ +#!/bin/bash +set -euo pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +dart run "${SCRIPT_DIR}/insert-example.dart" + +rm "README.template" diff --git a/scripts/insert-example.dart b/scripts/insert-example.dart new file mode 100644 index 0000000..8a86eec --- /dev/null +++ b/scripts/insert-example.dart @@ -0,0 +1,41 @@ +import 'dart:io'; + +void main() async { + final templateFile = File('README.template'); + final outputFile = File('README.md'); + + // Read the template file + if (!await templateFile.exists()) { + throw Exception('Error: $templateFile does not exist.'); + } + String templateContent = await templateFile.readAsString(); + + // Regex to find the %insert path/to/file.dart% pattern + final regex = RegExp(r'%insert ([^%]+)%'); + + // Function to replace the placeholders + String replacePlaceholders(String content) { + return content.replaceAllMapped(regex, (match) { + final path = match.group(1); + if (path == null || path.isEmpty) { + throw Exception('Incorrect value $path'); + } + + final file = File(path); + if (!file.existsSync()) { + throw Exception('Error: File $path does not exist.'); + } + + final fileContent = file.readAsStringSync(); + return fileContent; + }); + } + + // Replace placeholders in the template content + String modifiedContent = replacePlaceholders(templateContent); + + // Write the modified content to the output file + await outputFile.writeAsString(modifiedContent); + + print('README.md file has been generated.'); +}