Skip to content

Commit

Permalink
Update Dart SDK (#88)
Browse files Browse the repository at this point in the history
* Update Dart SDK
  • Loading branch information
Denis-Averin committed Jan 29, 2024
1 parent 6e52d39 commit c5ca227
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 13 deletions.
1 change: 0 additions & 1 deletion codegen/Templates/dart/api_client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:http/http.dart' as Http show Client, MultipartRequest, Response;
import '../aspose_barcode_cloud.dart';
import 'api_helper.dart';
import 'auth/authentication.dart';
import 'auth/oauth.dart';

const String SDK_VERSION = "{{pubVersion}}";

Expand Down
1 change: 1 addition & 0 deletions codegen/Templates/dart/apilib.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ library {{pubName}}.api;
export 'src/configuration.dart' show Configuration;
export 'src/api_client.dart' show ApiClient, SDK_VERSION;
export 'src/api_exception.dart' show ApiException;
export 'src/auth/oauth.dart' show OAuth;

{{#apiInfo}}{{#apis}}export 'src/api/{{classFilename}}.dart' show {{classname}};
{{/apis}}{{/apiInfo}}
Expand Down
10 changes: 5 additions & 5 deletions codegen/Templates/dart/auth/oauth.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class OAuth implements Authentication {
List<QueryParam> queryParams, Map<String, String> headerParams) async {
if (accessToken == null && tokenExpiration == null) {
if (clientId != null && clientSecret != null) {
await fetchToken(clientId!, clientSecret!);
accessToken = await fetchToken();
} else {
throw ApiException(0, "clientId or clientSecret not defined");
}
Expand All @@ -41,11 +41,11 @@ class OAuth implements Authentication {
headerParams["Authorization"] = "Bearer " + accessToken!;
}

Future fetchToken(String clientId, String clientSecret) async {
Future<String> fetchToken() async {
final request = MultipartRequest('POST', Uri.parse(tokenUrl))
..fields['grant_type'] = 'client_credentials'
..fields['client_id'] = clientId
..fields['client_secret'] = clientSecret;
..fields['client_id'] = this.clientId!
..fields['client_secret'] = this.clientSecret!;
final response = await request.send();
final responseText = await response.stream.bytesToString();
Expand All @@ -56,7 +56,7 @@ class OAuth implements Authentication {
final data = jsonDecode(responseText);
final int expiresIn = data['expires_in'];

accessToken = data['access_token'];
tokenExpiration = DateTime.now().add(Duration(seconds: expiresIn));
return data['access_token'];
}
}
2 changes: 1 addition & 1 deletion codegen/Templates/dart/pubspec.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ dependencies:
http: '>=0.13.0 <2.0.0'
dev_dependencies:
lints: ^3.0.0
test: ^1.19.2
test: ^1.25.1
44 changes: 39 additions & 5 deletions spec/aspose-barcode-cloud.json
Original file line number Diff line number Diff line change
Expand Up @@ -1163,9 +1163,21 @@
"GS1HanXin",
"GS1Aztec",
"GS1CompositeBar",
"GS1MicroPdf417"
"GS1MicroPdf417",
"mostCommonlyUsed"
]
},
{
"type": "array",
"name": "Types",
"in": "query",
"description": "Multiple barcode types to read.",
"collectionFormat": "multi",
"x-nullable": true,
"items": {
"$ref": "#/definitions/DecodeBarcodeType"
}
},
{
"type": "string",
"name": "ChecksumValidation",
Expand Down Expand Up @@ -1591,7 +1603,8 @@
"GS1HanXin",
"GS1Aztec",
"GS1CompositeBar",
"GS1MicroPdf417"
"GS1MicroPdf417",
"mostCommonlyUsed"
]
},
{
Expand Down Expand Up @@ -1731,9 +1744,21 @@
"GS1HanXin",
"GS1Aztec",
"GS1CompositeBar",
"GS1MicroPdf417"
"GS1MicroPdf417",
"mostCommonlyUsed"
]
},
{
"type": "array",
"name": "Types",
"in": "query",
"description": "Multiple barcode types to read.",
"collectionFormat": "multi",
"x-nullable": true,
"items": {
"$ref": "#/definitions/DecodeBarcodeType"
}
},
{
"type": "string",
"name": "ChecksumValidation",
Expand Down Expand Up @@ -4964,7 +4989,8 @@
"GS1HanXin",
"GS1Aztec",
"GS1CompositeBar",
"GS1MicroPdf417"
"GS1MicroPdf417",
"mostCommonlyUsed"
],
"enum": [
"all",
Expand Down Expand Up @@ -5050,7 +5076,8 @@
"GS1HanXin",
"GS1Aztec",
"GS1CompositeBar",
"GS1MicroPdf417"
"GS1MicroPdf417",
"mostCommonlyUsed"
]
},
"ChecksumValidation": {
Expand Down Expand Up @@ -5096,6 +5123,13 @@
"description": "The type of barcode to read.",
"$ref": "#/definitions/DecodeBarcodeType"
},
"Types": {
"type": "array",
"description": "Multiple barcode types to read.",
"items": {
"$ref": "#/definitions/DecodeBarcodeType"
}
},
"ChecksumValidation": {
"description": "Enable checksum validation during recognition for 1D barcodes.\nDefault is treated as Yes for symbologies which must contain checksum, as No where checksum only possible.\nChecksum never used: Codabar\nChecksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN\nChecksum always used: Rest symbologies",
"$ref": "#/definitions/ChecksumValidation"
Expand Down

0 comments on commit c5ca227

Please sign in to comment.