Skip to content

Commit f3663e2

Browse files
authored
Release 24.4 (#86)
* Add ScanBarcode endpoint * Version 24.4.0 * Drop outdated 'netcoreapp3.1' support * Update examples
1 parent 9aed71f commit f3663e2

File tree

132 files changed

+429
-2518
lines changed

Some content is hidden

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

132 files changed

+429
-2518
lines changed

.github/workflows/dotnet-core.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ jobs:
1616
# and https://github.com/dotnet/core/blob/main/releases.md
1717
# for versions
1818
include:
19-
- dotnet-version: 3.1.x
20-
framework: netcoreapp3.1
2119
- dotnet-version: 6.0.x
2220
framework: net6.0
2321
- dotnet-version: 7.0.x

.github/workflows/net-framework.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
run: |
4242
$ErrorActionPreference = "Stop"
4343
VSTest.Console.exe /Framework:".NETFramework,Version=${{ matrix.net-version }}" /ResultsDirectory:Tests\Results /Logger:"trx;LogFileName=test.log" Tests\bin\Release\${{ matrix.framework }}\Aspose.BarCode.Cloud.Sdk.Tests.dll
44-
if( ([xml](Get-Content Tests\Results\test.log)).TestRun.ResultSummary.Counters.total -ne 26 ){ throw "Not all tests were explored or added new tests" }
44+
if( ([xml](Get-Content Tests\Results\test.log)).TestRun.ResultSummary.Counters.total -ne 28 ){ throw "Not all tests were explored or added new tests" }
4545
4646
env:
4747
TEST_CONFIGURATION_JWT_TOKEN: ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }}

README.md

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Nuget](https://img.shields.io/nuget/v/Aspose.BarCode-Cloud)](https://www.nuget.org/packages/Aspose.BarCode-Cloud/)
77

88
- API version: 3.0
9-
- SDK version: 24.3.0
9+
- SDK version: 24.4.0
1010

1111
## Demo applications
1212

@@ -69,6 +69,7 @@ using Aspose.BarCode.Cloud.Sdk.Interfaces;
6969
using Aspose.BarCode.Cloud.Sdk.Model;
7070
using Aspose.BarCode.Cloud.Sdk.Model.Requests;
7171
using System;
72+
using System.Collections.Generic;
7273
using System.IO;
7374
using System.Reflection;
7475
using System.Threading.Tasks;
@@ -79,7 +80,7 @@ internal static class Program
7980
{
8081
private static Configuration MakeConfiguration()
8182
{
82-
Configuration config = new Configuration();
83+
var config = new Configuration();
8384

8485
string? envToken = Environment.GetEnvironmentVariable("TEST_CONFIGURATION_JWT_TOKEN");
8586
if (string.IsNullOrEmpty(envToken))
@@ -97,18 +98,15 @@ internal static class Program
9798

9899
private static async Task<string> ReadQR(IBarcodeApi api, string fileName)
99100
{
100-
await using (FileStream imageStream = File.OpenRead(fileName))
101-
{
102-
BarcodeResponseList recognized = await api.PostBarcodeRecognizeFromUrlOrContentAsync(
103-
new PostBarcodeRecognizeFromUrlOrContentRequest(image: imageStream)
104-
{
105-
Type = DecodeBarcodeType.QR.ToString(),
106-
Preset = PresetType.HighPerformance.ToString(),
107-
}
108-
);
109-
110-
return recognized.Barcodes[0].BarcodeValue;
111-
}
101+
await using FileStream imageStream = File.OpenRead(fileName);
102+
BarcodeResponseList recognized = await api.ScanBarcodeAsync(
103+
new ScanBarcodeRequest(imageStream)
104+
{
105+
decodeTypes = new List<DecodeBarcodeType> { DecodeBarcodeType.QR }
106+
}
107+
);
108+
109+
return recognized.Barcodes[0].BarcodeValue;
112110
}
113111

114112
public static async Task Main(string[] args)
@@ -119,7 +117,7 @@ internal static class Program
119117
"qr.png"
120118
));
121119

122-
BarcodeApi api = new BarcodeApi(MakeConfiguration());
120+
var api = new BarcodeApi(MakeConfiguration());
123121

124122
string result = await ReadQR(api, fileName);
125123
Console.WriteLine($"File '{fileName}' recognized, result: '{result}'");
@@ -148,7 +146,7 @@ internal static class Program
148146
{
149147
private static Configuration MakeConfiguration()
150148
{
151-
Configuration config = new Configuration();
149+
var config = new Configuration();
152150

153151
string? envToken = Environment.GetEnvironmentVariable("TEST_CONFIGURATION_JWT_TOKEN");
154152
if (string.IsNullOrEmpty(envToken))
@@ -166,21 +164,16 @@ internal static class Program
166164

167165
private static async Task GenerateQR(IBarcodeApi api, string fileName)
168166
{
169-
await using (Stream generated = await api.GetBarcodeGenerateAsync(
170-
new GetBarcodeGenerateRequest(
171-
EncodeBarcodeType.QR.ToString(),
172-
"QR code text")
173-
{
174-
TextLocation = "None",
175-
format = "png"
176-
})
177-
)
178-
{
179-
await using (FileStream stream = File.Create(fileName))
167+
await using Stream generated = await api.GetBarcodeGenerateAsync(
168+
new GetBarcodeGenerateRequest(
169+
EncodeBarcodeType.QR.ToString(),
170+
"QR code text")
180171
{
181-
await generated.CopyToAsync(stream);
182-
}
183-
}
172+
TextLocation = CodeLocation.None.ToString(),
173+
format = "png"
174+
});
175+
await using FileStream stream = File.Create(fileName);
176+
await generated.CopyToAsync(stream);
184177
}
185178

186179
public static async Task Main(string[] args)
@@ -230,6 +223,7 @@ Class | Method | HTTP request | Description
230223
*BarcodeApi* | [**PutBarcodeGenerateFile**](docs/BarcodeApi.md#putbarcodegeneratefile) | **PUT** /barcode/{name}/generate | Generate barcode and save on server (from query params or from file with json or xml content)
231224
*BarcodeApi* | [**PutBarcodeRecognizeFromBody**](docs/BarcodeApi.md#putbarcoderecognizefrombody) | **PUT** /barcode/{name}/recognize | Recognition of a barcode from file on server with parameters in body.
232225
*BarcodeApi* | [**PutGenerateMultiple**](docs/BarcodeApi.md#putgeneratemultiple) | **PUT** /barcode/{name}/generateMultiple | Generate image with multiple barcodes and put new file on server
226+
*BarcodeApi* | [**ScanBarcode**](docs/BarcodeApi.md#scanbarcode) | **POST** /barcode/scan | Quickly scan a barcode from an image.
233227
*FileApi* | [**CopyFile**](docs/FileApi.md#copyfile) | **PUT** /barcode/storage/file/copy/{srcPath} | Copy file
234228
*FileApi* | [**DeleteFile**](docs/FileApi.md#deletefile) | **DELETE** /barcode/storage/file/{path} | Delete file
235229
*FileApi* | [**DownloadFile**](docs/FileApi.md#downloadfile) | **GET** /barcode/storage/file/{path} | Download file

Tests/ApiExceptionTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using Aspose.BarCode.Cloud.Sdk.Model;
33
using Aspose.BarCode.Cloud.Sdk.Model.Requests;
44
using NUnit.Framework;
5-
using System;
6-
using System.Threading.Tasks;
75

86
namespace Aspose.BarCode.Cloud.Sdk.Tests
97
{
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
3-
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;net462;net480;net481;net6.0;net7.0;net8.0</TargetFrameworks>
5-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
6-
<IsTestProject>true</IsTestProject>
7-
<LangVersion>8.0</LangVersion>
8-
</PropertyGroup>
9-
<ItemGroup>
10-
<Compile Remove="TestResults\**" />
11-
<EmbeddedResource Remove="TestResults\**" />
12-
<None Remove="TestResults\**" />
13-
</ItemGroup>
14-
<ItemGroup>
15-
<PackageReference Include="Moq" Version="4.20.70" />
16-
<PackageReference Include="NUnit" Version="3.14.0" />
17-
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
18-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
19-
<PackageReference Include="System.Net.Http" Version="4.3.4" />
20-
</ItemGroup>
21-
<ItemGroup>
22-
<ProjectReference Include="..\src\Aspose.BarCode.Cloud.Sdk.csproj" />
23-
</ItemGroup>
3+
<PropertyGroup>
4+
<TargetFrameworks>net462;net480;net481;net6.0;net7.0;net8.0</TargetFrameworks>
5+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
6+
<IsTestProject>true</IsTestProject>
7+
<LangVersion>8.0</LangVersion>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<Compile Remove="TestResults\**"/>
11+
<EmbeddedResource Remove="TestResults\**"/>
12+
<None Remove="TestResults\**"/>
13+
</ItemGroup>
14+
<ItemGroup>
15+
<PackageReference Include="Moq" Version="4.20.70"/>
16+
<PackageReference Include="NUnit" Version="3.14.0"/>
17+
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
18+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0"/>
19+
<PackageReference Include="System.Net.Http" Version="4.3.4"/>
20+
</ItemGroup>
21+
<ItemGroup>
22+
<ProjectReference Include="..\src\Aspose.BarCode.Cloud.Sdk.csproj"/>
23+
</ItemGroup>
2424
</Project>

Tests/BarcodeApiTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public async Task PostBarcodeRecognizeFromUrlOrContentAsyncTest()
157157
{
158158
ChecksumValidation = ChecksumValidation.Off.ToString(),
159159
Preset = PresetType.HighPerformance.ToString(),
160-
Types = new List<DecodeBarcodeType> { DecodeBarcodeType.Code11 },
160+
Types = new List<DecodeBarcodeType> { DecodeBarcodeType.Code11 }
161161
}
162162
);
163163

Tests/Configuration.template.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"ClientId": "Client Id from https://dashboard.aspose.cloud/applications",
3-
"ClientSecret": "Client Secret from https://dashboard.aspose.cloud/applications",
4-
"ApiBaseUrl": "https://api.aspose.cloud",
5-
"TokenUrl":"https://api.aspose.cloud/connect/token"
2+
"ClientId": "Client Id from https://dashboard.aspose.cloud/applications",
3+
"ClientSecret": "Client Secret from https://dashboard.aspose.cloud/applications",
4+
"ApiBaseUrl": "https://api.aspose.cloud",
5+
"TokenUrl": "https://api.aspose.cloud/connect/token"
66
}

Tests/JWTRequestHandlerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public void TestTokenFetched()
4949

5050
// assert
5151
Assert.Contains("Authorization", request.Headers.Keys);
52-
var auth = request.Headers["Authorization"];
52+
string auth = request.Headers["Authorization"];
5353
Assert.Greater(auth.Length, "Bearer ".Length);
54-
var token = auth.Substring("Bearer ".Length);
54+
string token = auth.Substring("Bearer ".Length);
5555
AssertTokenIsValid(token);
5656
}
5757

Tests/JwtAuthTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public async Task CanUseExternalTokenWithAsync()
5050
var api = new BarcodeApi(configWithToken);
5151
using Stream generated = await api.GetBarcodeGenerateAsync(
5252
new GetBarcodeGenerateRequest(
53-
EncodeBarcodeType.QR.ToString(), "Test")
54-
);
53+
EncodeBarcodeType.QR.ToString(), "Test")
54+
);
5555
Assert.Greater(generated.Length, 0);
5656
}
5757
}

Tests/RecognizeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public async Task RecognizeQrAsyncTest()
3636
new PostBarcodeRecognizeFromUrlOrContentRequest(image)
3737
{
3838
Preset = PresetType.HighPerformance.ToString(),
39-
Types = new List<DecodeBarcodeType> { DecodeBarcodeType.QR },
39+
Types = new List<DecodeBarcodeType> { DecodeBarcodeType.QR }
4040
}
4141
);
4242

Tests/ScanTests.cs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using System.Collections.Generic;
2+
using System.IO;
3+
using System.Threading.Tasks;
4+
using Aspose.BarCode.Cloud.Sdk.Api;
5+
using Aspose.BarCode.Cloud.Sdk.Interfaces;
6+
using Aspose.BarCode.Cloud.Sdk.Model;
7+
using Aspose.BarCode.Cloud.Sdk.Model.Requests;
8+
using NUnit.Framework;
9+
10+
namespace Aspose.BarCode.Cloud.Sdk.Tests
11+
{
12+
[TestFixture]
13+
public class ScanTests : TestsBase
14+
{
15+
private IBarcodeApi _api;
16+
17+
[SetUp]
18+
public void Init()
19+
{
20+
_api = new BarcodeApi(TestConfiguration);
21+
}
22+
23+
24+
[Test]
25+
public async Task ScanBarcodeAsyncTest()
26+
{
27+
// Arrange
28+
using Stream image = GetTestImage("Test_PostGenerateMultiple.png");
29+
30+
// Act
31+
BarcodeResponseList response = await _api.ScanBarcodeAsync(
32+
new ScanBarcodeRequest(image)
33+
{
34+
decodeTypes = new List<DecodeBarcodeType> { DecodeBarcodeType.Code128, DecodeBarcodeType.QR }
35+
}
36+
);
37+
38+
// Assert
39+
Assert.AreEqual(2, response.Barcodes.Count);
40+
Assert.AreEqual(DecodeBarcodeType.QR.ToString(), response.Barcodes[0].Type);
41+
Assert.AreEqual("Hello world!", response.Barcodes[0].BarcodeValue);
42+
}
43+
44+
45+
[Test]
46+
public void ScanBarcodeAsyncTimeoutTest()
47+
{
48+
// Arrange
49+
using Stream image = GetTestImage("Test_PostGenerateMultiple.png");
50+
51+
// Act
52+
var apiException = Assert.ThrowsAsync<ApiException>(async () =>
53+
{
54+
await _api.ScanBarcodeAsync(
55+
new ScanBarcodeRequest(image)
56+
{
57+
timeout = 1
58+
}
59+
);
60+
});
61+
62+
// Assert
63+
Assert.IsNotNull(apiException);
64+
Assert.AreEqual(408, apiException.ErrorCode);
65+
}
66+
}
67+
}

Tests/TestsBase.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ private static Configuration LoadTestConfiguration()
4949

5050
private static Configuration LoadFromEnv()
5151
{
52-
5352
string jsonStr = JsonConvert.SerializeObject(new Configuration());
5453
JObject obj = JObject.Parse(jsonStr);
5554
foreach (KeyValuePair<string, JToken> i in obj)

docs/AustralianPostParams.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ AustralianPost barcode parameters.
66

77
Name | Type | Description | Notes
88
---- | ---- | ----------- | -----
9-
**EncodingTable** | **CustomerInformationInterpretingType** | Interpreting type for the Customer Information of AustralianPost, default to CustomerInformationInterpretingType.Other\&quot; | [optional]
9+
**EncodingTable** | **CustomerInformationInterpretingType** | Interpreting type for the Customer Information of AustralianPost, default to CustomerInformationInterpretingType.Other | [optional]
1010
**ShortBarHeight** | **double?** | Short bar&#39;s height of AustralianPost barcode. | [optional]

docs/BarcodeApi.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Method | HTTP request | Description
1111
[**PutBarcodeGenerateFile**](BarcodeApi.md#putbarcodegeneratefile) | **PUT** /barcode/{name}/generate | Generate barcode and save on server (from query params or from file with json or xml content)
1212
[**PutBarcodeRecognizeFromBody**](BarcodeApi.md#putbarcoderecognizefrombody) | **PUT** /barcode/{name}/recognize | Recognition of a barcode from file on server with parameters in body.
1313
[**PutGenerateMultiple**](BarcodeApi.md#putgeneratemultiple) | **PUT** /barcode/{name}/generateMultiple | Generate image with multiple barcodes and put new file on server
14+
[**ScanBarcode**](BarcodeApi.md#scanbarcode) | **POST** /barcode/scan | Quickly scan a barcode from an image.
1415

1516

1617
## **GetBarcodeGenerate**
@@ -116,7 +117,7 @@ Name | Type | Description | Notes
116117
**allowAdditionalRestorations** | **bool?**| Allows engine using additional image restorations to recognize corrupted barcodes. At this time, it is used only in MicroPdf417 barcode type. Default value: False. | [optional]
117118
**regionLikelihoodThresholdPercent** | **double?**| Sets threshold for detected regions that may contain barcodes. Value 0.7 means that bottom 70% of possible regions are filtered out and not processed further. Region likelihood threshold must be between [0.05, 0.9] Use high values for clear images with few barcodes. Use low values for images with many barcodes or for noisy images. Low value may lead to a bigger recognition time. | [optional]
118119
**scanWindowSizes** | [**List&lt;int?&gt;**](int?.md)| Scan window sizes in pixels. Allowed sizes are 10, 15, 20, 25, 30. Scanning with small window size takes more time and provides more accuracy but may fail in detecting very big barcodes. Combining of several window sizes can improve detection quality. | [optional]
119-
**similarity** | **double?**| Similarity coefficient depends on how homogeneous barcodes are. Use high value for for clear barcodes. Use low values to detect barcodes that ara partly damaged or not lighten evenly. Similarity coefficient must be between [0.5, 0.9] | [optional]
120+
**similarity** | **double?**| Similarity coefficient depends on how homogeneous barcodes are. Use high value for clear barcodes. Use low values to detect barcodes that ara partly damaged or not lighten evenly. Similarity coefficient must be between [0.5, 0.9] | [optional]
120121
**skipDiagonalSearch** | **bool?**| Allows detector to skip search for diagonal barcodes. Setting it to false will increase detection time but allow to find diagonal barcodes that can be missed otherwise. Enabling of diagonal search leads to a bigger detection time. | [optional]
121122
**readTinyBarcodes** | **bool?**| Allows engine to recognize tiny barcodes on large images. Ignored if AllowIncorrectBarcodes is set to True. Default value: False. | [optional]
122123
**australianPostEncodingTable** | **string**| Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.Other. | [optional]
@@ -177,7 +178,7 @@ Name | Type | Description | Notes
177178
**allowAdditionalRestorations** | **bool?**| Allows engine using additional image restorations to recognize corrupted barcodes. At this time, it is used only in MicroPdf417 barcode type. Default value: False. | [optional]
178179
**regionLikelihoodThresholdPercent** | **double?**| Sets threshold for detected regions that may contain barcodes. Value 0.7 means that bottom 70% of possible regions are filtered out and not processed further. Region likelihood threshold must be between [0.05, 0.9] Use high values for clear images with few barcodes. Use low values for images with many barcodes or for noisy images. Low value may lead to a bigger recognition time. | [optional]
179180
**scanWindowSizes** | [**List&lt;int?&gt;**](int?.md)| Scan window sizes in pixels. Allowed sizes are 10, 15, 20, 25, 30. Scanning with small window size takes more time and provides more accuracy but may fail in detecting very big barcodes. Combining of several window sizes can improve detection quality. | [optional]
180-
**similarity** | **double?**| Similarity coefficient depends on how homogeneous barcodes are. Use high value for for clear barcodes. Use low values to detect barcodes that ara partly damaged or not lighten evenly. Similarity coefficient must be between [0.5, 0.9] | [optional]
181+
**similarity** | **double?**| Similarity coefficient depends on how homogeneous barcodes are. Use high value for clear barcodes. Use low values to detect barcodes that ara partly damaged or not lighten evenly. Similarity coefficient must be between [0.5, 0.9] | [optional]
181182
**skipDiagonalSearch** | **bool?**| Allows detector to skip search for diagonal barcodes. Setting it to false will increase detection time but allow to find diagonal barcodes that can be missed otherwise. Enabling of diagonal search leads to a bigger detection time. | [optional]
182183
**readTinyBarcodes** | **bool?**| Allows engine to recognize tiny barcodes on large images. Ignored if AllowIncorrectBarcodes is set to True. Default value: False. | [optional]
183184
**australianPostEncodingTable** | **string**| Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.Other. | [optional]
@@ -337,3 +338,29 @@ Name | Type | Description | Notes
337338
- **Content-Type**: application/json, application/xml
338339
- **Accept**: application/json
339340

341+
342+
## **ScanBarcode**
343+
344+
```csharp
345+
BarcodeResponseList ScanBarcode (System.IO.Stream imageFile, List<DecodeBarcodeType> decodeTypes = null, int? timeout = null)
346+
```
347+
348+
Quickly scan a barcode from an image.
349+
350+
### Parameters
351+
352+
Name | Type | Description | Notes
353+
---- | ---- | ------------ | -----
354+
**imageFile** | **System.IO.Stream**| Image as file |
355+
**decodeTypes** | [**List&lt;DecodeBarcodeType&gt;**](DecodeBarcodeType.md)| Types of barcode to recognize | [optional]
356+
**timeout** | **int?**| Timeout of recognition process in milliseconds. Default value is 15_000 (15 seconds). Maximum value is 30_000 (1/2 minute). In case of a timeout RequestTimeout (408) status will be returned. Try reducing the image size to avoid timeout. | [optional]
357+
358+
### Return type
359+
360+
[**BarcodeResponseList**](BarcodeResponseList.md)
361+
362+
### HTTP request headers
363+
364+
- **Content-Type**: multipart/form-data
365+
- **Accept**: application/json
366+

0 commit comments

Comments
 (0)