Skip to content

Commit 99153d1

Browse files
Merge remote-tracking branch 'origin/master' into release
2 parents 4f44a5e + 7f93d70 commit 99153d1

File tree

201 files changed

+2447
-740
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+2447
-740
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [22.3.0] - Aspose Words Cloud for Dart 22.3 Release Notes
2+
3+
- Online methods returns the dictionary of files with included original filename as key instead of single file content in responses.
4+
- Parameters contained sensitive data should be passed in encrypted form. Names of the parameters have 'encrypted' prefix.
5+
- Added Encrypt method to encrypt data on the API public key. Use it to prepare values for parameters required encrypted data.
6+
- GetPublicKey method is not billable.
7+
- Changed type of enumerations for members of SaveOptionsData and other inherited classes from string to enum.
8+
9+
110
## [22.2.0] - Aspose Words Cloud for Dart 22.2 Release Notes
211

312
- Made 'SaveOprionsData.SaveFormat' property readonly with default value.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Add this dependency to your *pubspec.yaml*:
2727

2828
```yaml
2929
dependencies:
30-
aspose_words_cloud: 22.2.0
30+
aspose_words_cloud: 22.3.0
3131
```
3232
3333
## Getting Started

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ analyzer:
66
prefer_adjacent_string_concatenation: ignore
77
unnecessary_getters_setters: ignore
88
prefer_final_fields: ignore
9+
constant_identifier_names: ignore
910
exclude:
1011
- examples/**
1112
linter:

examples/AcceptAllRevisionsOnline.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ final requestDocument = (await File(fileName).readAsBytes()).buffer.asByteData()
99
final request = AcceptAllRevisionsOnlineRequest(requestDocument);
1010
final acceptAllRevisionsOnlineResult = await wordsApi.acceptAllRevisionsOnline(request);
1111
await File('test_result.docx').writeAsBytes(
12-
acceptAllRevisionsOnlineResult.document.buffer.asUint8List(acceptAllRevisionsOnlineResult.document.offsetInBytes, acceptAllRevisionsOnlineResult.document.lengthInBytes)
12+
acceptAllRevisionsOnlineResult.document.values.first.buffer.asUint8List(acceptAllRevisionsOnlineResult.document.values.first.offsetInBytes, acceptAllRevisionsOnlineResult.document.values.first.lengthInBytes)
1313
);

lib/aspose_words_cloud.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ export 'src/models/paragraph_response.dart';
196196
export 'src/models/pcl_save_options_data.dart';
197197
export 'src/models/pdf_digital_signature_details_data.dart';
198198
export 'src/models/pdf_encryption_details_data.dart';
199+
export 'src/models/pdf_permissions.dart';
199200
export 'src/models/pdf_save_options_data.dart';
200201
export 'src/models/png_save_options_data.dart';
201202
export 'src/models/preferred_width.dart';

lib/src/api_client.dart

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import 'package:uuid/uuid.dart';
3737

3838
import './api_request_data.dart';
3939
import './api_request_part.dart';
40+
import './body_part_data.dart';
4041
import './byte_data_extensions.dart';
4142
import './requests/batch_request.dart';
4243
import '../aspose_words_cloud.dart';
@@ -62,13 +63,21 @@ class ApiClient {
6263

6364
_encryptorInitialized = true;
6465
try {
65-
final rsaPublicKey = await _publicKeyRequester(GetPublicKeyRequest());
66-
if (rsaPublicKey == null || rsaPublicKey.modulus == null || rsaPublicKey.exponent == null) {
67-
throw ApiException(400, 'Invalid public key response.');
66+
var exponentString = configuration.rsaExponent;
67+
var modulusString = configuration.rsaModulus;
68+
69+
if (exponentString == null || exponentString.isEmpty || modulusString == null || modulusString.isEmpty)
70+
{
71+
final rsaPublicKey = await _publicKeyRequester(GetPublicKeyRequest());
72+
if (rsaPublicKey == null || rsaPublicKey.modulus == null || rsaPublicKey.exponent == null) {
73+
throw ApiException(400, 'Invalid public key response.');
74+
}
75+
exponentString = rsaPublicKey.modulus as String;
76+
modulusString = rsaPublicKey.exponent as String;
6877
}
6978

70-
final modulus = BigInt.parse(hex.encode(base64Decode(rsaPublicKey.modulus as String)), radix: 16);
71-
final exponent = BigInt.parse(hex.encode(base64Decode(rsaPublicKey.exponent as String)), radix: 16);
79+
final modulus = BigInt.parse(hex.encode(base64Decode(modulusString)), radix: 16);
80+
final exponent = BigInt.parse(hex.encode(base64Decode(exponentString)), radix: 16);
7281
var pubKey = RSAPublicKey(modulus, exponent);
7382

7483
_encrypter.init(true, PublicKeyParameter<RSAPublicKey>(pubKey));
@@ -333,29 +342,54 @@ class ApiClient {
333342
return result;
334343
}
335344

336-
Map<String, ByteData> deserializeMultipartMap(final ByteData data) {
337-
var result = <String, ByteData>{};
345+
Map<String, BodyPartData> deserializeMultipartMap(final ByteData data) {
346+
var result = <String, BodyPartData>{};
338347
for (final part in _deserializeMultipartBase(data)) {
339348
var headersEndIndex = part.indexOf(_newline2x);
340349
if (headersEndIndex == null) {
341350
throw ApiException(400, 'Failed to parse multipart response.');
342351
}
343352

353+
const contentDispositionStr = 'Content-Disposition:';
354+
const contentTypeStr = 'Content-Disposition:';
344355
var headersData = ByteData.sublistView(part, 0, headersEndIndex);
345356
var headersStr = utf8.decoder.convert(headersData.buffer.asUint8List(headersData.offsetInBytes, headersData.lengthInBytes));
346-
var contentDisposition = headersStr.split('\r\n').firstWhere((x) => x.trim().startsWith('Content-Disposition:'));
357+
var headersRaw = headersStr.split('\r\n');
358+
var contentDisposition = headersRaw.firstWhere((x) => x.trim().startsWith(contentDispositionStr)).replaceFirst(contentDispositionStr, '').trim();
359+
var contentType = headersRaw.firstWhere((x) => x.trim().startsWith(contentTypeStr))?.replaceFirst(contentTypeStr, '')?.trim();
347360
var nameHeaderPart = contentDisposition.split(';').map((x) => x.trim()).firstWhere((x) => x.toLowerCase().startsWith('name'));
361+
var filenameHeaderPart = contentDisposition.split(';').map((x) => x.trim()).firstWhere((x) => x.toLowerCase().startsWith('name'));
348362
var nameValueParts = nameHeaderPart.split('=');
363+
var filenameValueParts = filenameHeaderPart?.split('=');
349364
if (nameValueParts.length != 2) {
350365
throw ApiException(400, 'Failed to parse multipart response.');
351366
}
352367

353-
var nameValue = nameValueParts.elementAt(1).trim().toLowerCase();
354-
result[nameValue] = ByteData.sublistView(part, headersEndIndex + _newline2x.lengthInBytes, part.lengthInBytes - _newline.lengthInBytes);
368+
var nameValue = nameValueParts.elementAt(1).trim().replaceAll('"', '').toLowerCase();
369+
var filenameValue = filenameValueParts?.elementAt(1)?.trim()?.replaceAll('"', '');
370+
var content = ByteData.sublistView(part, headersEndIndex + _newline2x.lengthInBytes, part.lengthInBytes - _newline.lengthInBytes);
371+
result[nameValue] = BodyPartData(contentType, filenameValue, content);
355372
}
356373
return result;
357374
}
358375

376+
Map<String, ByteData> deserializeFilesCollection(final BodyPartData bodyPartData) {
377+
var result = <String, ByteData>{};
378+
if (bodyPartData.contentType != null && bodyPartData.contentType.startsWith('multipart/mixed'))
379+
{
380+
var subParts = deserializeMultipartMap(bodyPartData.content);
381+
subParts.forEach((key, value) {
382+
result[value.filename] = value.content;
383+
});
384+
}
385+
else
386+
{
387+
result[bodyPartData.filename ?? ''] = bodyPartData.content;
388+
}
389+
390+
return result;
391+
}
392+
359393
dynamic deserializeBatchPart(final RequestBase request, final ByteData partData) {
360394
var statusDataEndIndex = partData.indexOf(_newline);
361395
if (statusDataEndIndex == null) {
@@ -471,7 +505,7 @@ class ApiClient {
471505

472506
var httpRequest = http.Request(requestData.method, Uri.parse(requestData.url));
473507
httpRequest.headers['x-aspose-client'] = 'dart sdk';
474-
httpRequest.headers['x-aspose-client-version'] = '22.2';
508+
httpRequest.headers['x-aspose-client-version'] = '22.3';
475509
httpRequest.headers['Authorization'] = await _getAuthToken();
476510
if (requestData.headers != null) {
477511
httpRequest.headers.addAll(requestData.headers);

lib/src/body_part_data.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* --------------------------------------------------------------------------------
3+
* <copyright company="Aspose" file="body_part_data.dart">
4+
* Copyright (c) 2022 Aspose.Words for Cloud
5+
* </copyright>
6+
* <summary>
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
* </summary>
25+
* --------------------------------------------------------------------------------
26+
*/
27+
28+
library aspose_words_cloud;
29+
30+
import 'dart:typed_data';
31+
32+
class BodyPartData {
33+
final String contentType;
34+
final String filename;
35+
final ByteData content;
36+
BodyPartData(final this.contentType, final this.filename, final this.content);
37+
}

lib/src/configuration.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,19 @@ class Configuration {
3333
final String baseUrl;
3434
final bool debugMode;
3535
final Duration timeout;
36+
final String rsaExponent;
37+
final String rsaModulus;
3638

37-
Configuration(final this.clientId, final this.clientSecret, {final this.baseUrl = 'https://api.aspose.cloud', final this.debugMode = false, final this.timeout = const Duration(seconds: 300)});
39+
Configuration(final this.clientId, final this.clientSecret, {final this.baseUrl = 'https://api.aspose.cloud', final this.debugMode = false, final this.timeout = const Duration(seconds: 300), final this.rsaExponent = '', final this.rsaModulus = ''});
3840

3941
Configuration.fromJson(final Map<String, dynamic> json)
4042
: clientId = json['ClientId'] as String,
4143
clientSecret = json['ClientSecret'] as String,
4244
baseUrl = json['BaseUrl'] as String ?? 'https://api.aspose.cloud',
4345
debugMode = json['DebugMode'] as bool,
44-
timeout = Duration(seconds: json['Timeout'] as int ?? 300);
46+
timeout = Duration(seconds: json['Timeout'] as int ?? 300),
47+
rsaExponent = json['RsaExponent'] as String,
48+
rsaModulus = json['RsaModulus'] as String;
4549

4650
String getApiRootUrl()
4751
{

lib/src/models/bmp_save_options_data.dart

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,22 @@ class BmpSaveOptionsData extends ImageSaveOptionsData {
6969
}
7070

7171
if (json.containsKey('DmlEffectsRenderingMode')) {
72-
dmlEffectsRenderingMode = json['DmlEffectsRenderingMode'] as String;
72+
switch (json['DmlEffectsRenderingMode'] as String) {
73+
case 'Simplified': dmlEffectsRenderingMode = SaveOptionsData_DmlEffectsRenderingModeEnum.simplified; break;
74+
case 'None': dmlEffectsRenderingMode = SaveOptionsData_DmlEffectsRenderingModeEnum.none; break;
75+
case 'Fine': dmlEffectsRenderingMode = SaveOptionsData_DmlEffectsRenderingModeEnum.fine; break;
76+
default: dmlEffectsRenderingMode = null; break;
77+
}
7378
} else {
7479
dmlEffectsRenderingMode = null;
7580
}
7681

7782
if (json.containsKey('DmlRenderingMode')) {
78-
dmlRenderingMode = json['DmlRenderingMode'] as String;
83+
switch (json['DmlRenderingMode'] as String) {
84+
case 'Fallback': dmlRenderingMode = SaveOptionsData_DmlRenderingModeEnum.fallback; break;
85+
case 'DrawingML': dmlRenderingMode = SaveOptionsData_DmlRenderingModeEnum.drawingML; break;
86+
default: dmlRenderingMode = null; break;
87+
}
7988
} else {
8089
dmlRenderingMode = null;
8190
}
@@ -93,7 +102,11 @@ class BmpSaveOptionsData extends ImageSaveOptionsData {
93102
}
94103

95104
if (json.containsKey('ImlRenderingMode')) {
96-
imlRenderingMode = json['ImlRenderingMode'] as String;
105+
switch (json['ImlRenderingMode'] as String) {
106+
case 'Fallback': imlRenderingMode = SaveOptionsData_ImlRenderingModeEnum.fallback; break;
107+
case 'InkML': imlRenderingMode = SaveOptionsData_ImlRenderingModeEnum.inkML; break;
108+
default: imlRenderingMode = null; break;
109+
}
97110
} else {
98111
imlRenderingMode = null;
99112
}
@@ -135,7 +148,11 @@ class BmpSaveOptionsData extends ImageSaveOptionsData {
135148
}
136149

137150
if (json.containsKey('ColorMode')) {
138-
colorMode = json['ColorMode'] as String;
151+
switch (json['ColorMode'] as String) {
152+
case 'Normal': colorMode = FixedPageSaveOptionsData_ColorModeEnum.normal; break;
153+
case 'Grayscale': colorMode = FixedPageSaveOptionsData_ColorModeEnum.grayscale; break;
154+
default: colorMode = null; break;
155+
}
139156
} else {
140157
colorMode = null;
141158
}
@@ -154,7 +171,14 @@ class BmpSaveOptionsData extends ImageSaveOptionsData {
154171
}
155172

156173
if (json.containsKey('NumeralFormat')) {
157-
numeralFormat = json['NumeralFormat'] as String;
174+
switch (json['NumeralFormat'] as String) {
175+
case 'European': numeralFormat = FixedPageSaveOptionsData_NumeralFormatEnum.european; break;
176+
case 'ArabicIndic': numeralFormat = FixedPageSaveOptionsData_NumeralFormatEnum.arabicIndic; break;
177+
case 'EasternArabicIndic': numeralFormat = FixedPageSaveOptionsData_NumeralFormatEnum.easternArabicIndic; break;
178+
case 'Context': numeralFormat = FixedPageSaveOptionsData_NumeralFormatEnum.context; break;
179+
case 'System': numeralFormat = FixedPageSaveOptionsData_NumeralFormatEnum.system; break;
180+
default: numeralFormat = null; break;
181+
}
158182
} else {
159183
numeralFormat = null;
160184
}
@@ -190,7 +214,12 @@ class BmpSaveOptionsData extends ImageSaveOptionsData {
190214
}
191215

192216
if (json.containsKey('ImageColorMode')) {
193-
imageColorMode = json['ImageColorMode'] as String;
217+
switch (json['ImageColorMode'] as String) {
218+
case 'None': imageColorMode = ImageSaveOptionsData_ImageColorModeEnum.none; break;
219+
case 'Grayscale': imageColorMode = ImageSaveOptionsData_ImageColorModeEnum.grayscale; break;
220+
case 'BlackAndWhite': imageColorMode = ImageSaveOptionsData_ImageColorModeEnum.blackAndWhite; break;
221+
default: imageColorMode = null; break;
222+
}
194223
} else {
195224
imageColorMode = null;
196225
}
@@ -208,7 +237,20 @@ class BmpSaveOptionsData extends ImageSaveOptionsData {
208237
}
209238

210239
if (json.containsKey('PixelFormat')) {
211-
pixelFormat = json['PixelFormat'] as String;
240+
switch (json['PixelFormat'] as String) {
241+
case 'Format16BppRgb555': pixelFormat = ImageSaveOptionsData_PixelFormatEnum.format16BppRgb555; break;
242+
case 'Format16BppRgb565': pixelFormat = ImageSaveOptionsData_PixelFormatEnum.format16BppRgb565; break;
243+
case 'Format16BppArgb1555': pixelFormat = ImageSaveOptionsData_PixelFormatEnum.format16BppArgb1555; break;
244+
case 'Format24BppRgb': pixelFormat = ImageSaveOptionsData_PixelFormatEnum.format24BppRgb; break;
245+
case 'Format32BppRgb': pixelFormat = ImageSaveOptionsData_PixelFormatEnum.format32BppRgb; break;
246+
case 'Format32BppArgb': pixelFormat = ImageSaveOptionsData_PixelFormatEnum.format32BppArgb; break;
247+
case 'Format32BppPArgb': pixelFormat = ImageSaveOptionsData_PixelFormatEnum.format32BppPArgb; break;
248+
case 'Format48BppRgb': pixelFormat = ImageSaveOptionsData_PixelFormatEnum.format48BppRgb; break;
249+
case 'Format64BppArgb': pixelFormat = ImageSaveOptionsData_PixelFormatEnum.format64BppArgb; break;
250+
case 'Format64BppPArgb': pixelFormat = ImageSaveOptionsData_PixelFormatEnum.format64BppPArgb; break;
251+
case 'Format1bppIndexed': pixelFormat = ImageSaveOptionsData_PixelFormatEnum.format1bppIndexed; break;
252+
default: pixelFormat = null; break;
253+
}
212254
} else {
213255
pixelFormat = null;
214256
}

lib/src/models/doc_save_options_data.dart

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,22 @@ class DocSaveOptionsData extends SaveOptionsData {
9999
}
100100

101101
if (json.containsKey('DmlEffectsRenderingMode')) {
102-
dmlEffectsRenderingMode = json['DmlEffectsRenderingMode'] as String;
102+
switch (json['DmlEffectsRenderingMode'] as String) {
103+
case 'Simplified': dmlEffectsRenderingMode = SaveOptionsData_DmlEffectsRenderingModeEnum.simplified; break;
104+
case 'None': dmlEffectsRenderingMode = SaveOptionsData_DmlEffectsRenderingModeEnum.none; break;
105+
case 'Fine': dmlEffectsRenderingMode = SaveOptionsData_DmlEffectsRenderingModeEnum.fine; break;
106+
default: dmlEffectsRenderingMode = null; break;
107+
}
103108
} else {
104109
dmlEffectsRenderingMode = null;
105110
}
106111

107112
if (json.containsKey('DmlRenderingMode')) {
108-
dmlRenderingMode = json['DmlRenderingMode'] as String;
113+
switch (json['DmlRenderingMode'] as String) {
114+
case 'Fallback': dmlRenderingMode = SaveOptionsData_DmlRenderingModeEnum.fallback; break;
115+
case 'DrawingML': dmlRenderingMode = SaveOptionsData_DmlRenderingModeEnum.drawingML; break;
116+
default: dmlRenderingMode = null; break;
117+
}
109118
} else {
110119
dmlRenderingMode = null;
111120
}
@@ -123,7 +132,11 @@ class DocSaveOptionsData extends SaveOptionsData {
123132
}
124133

125134
if (json.containsKey('ImlRenderingMode')) {
126-
imlRenderingMode = json['ImlRenderingMode'] as String;
135+
switch (json['ImlRenderingMode'] as String) {
136+
case 'Fallback': imlRenderingMode = SaveOptionsData_ImlRenderingModeEnum.fallback; break;
137+
case 'InkML': imlRenderingMode = SaveOptionsData_ImlRenderingModeEnum.inkML; break;
138+
default: imlRenderingMode = null; break;
139+
}
127140
} else {
128141
imlRenderingMode = null;
129142
}

0 commit comments

Comments
 (0)