Skip to content

Release 25.1 V4 #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/net-framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: |
$ErrorActionPreference = "Stop"
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
if( ([xml](Get-Content Tests\Results\test.log)).TestRun.ResultSummary.Counters.total -ne 29 ){ throw "Not all tests were explored or added new tests" }
if( ([xml](Get-Content Tests\Results\test.log)).TestRun.ResultSummary.Counters.total -ne 25 ){ throw "Not all tests were explored or added new tests" }

env:
TEST_CONFIGURATION_JWT_TOKEN: ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build examples
name: Build examples and run snippets

on:
push:
Expand All @@ -15,6 +15,14 @@ jobs:
- name: Setup latest version of dotnet
uses: actions/setup-dotnet@v4
- name: Build nuget with latest version
run: ./scripts/pack-nuget.bash "examples/nuget-packages"
run: |
./scripts/pack-nuget.bash
cp *.nupkg examples/nuget-packages
- name: Build examples with new nuget
run: dotnet build --warnaserror "examples/examples.sln"
- name: Run documentation code snippets
run: |
chmod +x scripts/*
./scripts/run_snippets.sh
env:
TEST_CONFIGURATION_ACCESS_TOKEN: ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ obj
Tests/Configuration*.json
*.DotSettings
*.binlog
snippets_test/
*.nupkg
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ init:
format:
dotnet restore ./Aspose.BarCode.Cloud.Sdk.sln
dotnet format ./Aspose.BarCode.Cloud.Sdk.sln --no-restore
dotnet format --include ./snippets/
# Trim white space in comments
find . -iname "*.cs" -exec sed -i -e 's_[[:space:]]*$$__' {} \;


.PHONY: format-doc
format-doc:
# Remove trailing white space
Expand All @@ -22,6 +24,7 @@ format-doc:
.PHONY: test
test:
dotnet test -v normal --framework=net$(LATEST_SDK_VERSION)
./scripts/run_snippests.sh

.PHONY: build
build:
Expand Down
160 changes: 46 additions & 114 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
[![.NET Framework Windows](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dotnet/actions/workflows/net-framework.yml/badge.svg?branch=main)](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dotnet/actions/workflows/net-framework.yml)
[![Nuget](https://img.shields.io/nuget/v/Aspose.BarCode-Cloud)](https://www.nuget.org/packages/Aspose.BarCode-Cloud/)

- API version: 3.0
- SDK version: 24.12.0
- API version: 4.0
- SDK version: 25.1.0

## SDK and API Version Compatibility:

- SDK Version 25.1 and Later: Starting from SDK version 25.1, all subsequent versions are compatible with API Version v4.0.
- SDK Version 24.12 and Earlier: These versions are compatible with API Version v3.0.

## Demo applications

Expand Down Expand Up @@ -67,7 +72,7 @@ The examples below show how you can recognize QR code from image:
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using Aspose.BarCode.Cloud.Sdk.Model.Requests;

using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -96,13 +101,16 @@ internal static class Program
return config;
}

private static async Task<string> ReadQR(IBarcodeApi api, string fileName)
private static async Task<string> ReadQR(IRecognizeApi api, string fileName)
{
await using FileStream imageStream = File.OpenRead(fileName);
BarcodeResponseList recognized = await api.ScanBarcodeAsync(
new ScanBarcodeRequest(imageStream)
byte[] imageBytes = await File.ReadAllBytesAsync(fileName);
string imageBase64 = Convert.ToBase64String(imageBytes);

BarcodeResponseList recognized = await api.RecognizeBase64Async(
new RecognizeBase64Request()
{
decodeTypes = new List<DecodeBarcodeType> { DecodeBarcodeType.QR }
BarcodeTypes = new List<DecodeBarcodeType> { DecodeBarcodeType.QR },
FileBase64 = imageBase64
}
);

Expand All @@ -117,7 +125,7 @@ internal static class Program
"qr.png"
));

var api = new BarcodeApi(MakeConfiguration());
var api = new RecognizeApi(MakeConfiguration());

string result = await ReadQR(api, fileName);
Console.WriteLine($"File '{fileName}' recognized, result: '{result}'");
Expand All @@ -134,7 +142,7 @@ The examples below show how you can generate QR code and save it into local file
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using Aspose.BarCode.Cloud.Sdk.Model.Requests;

using System;
using System.IO;
using System.Reflection;
Expand Down Expand Up @@ -162,16 +170,14 @@ internal static class Program
return config;
}

private static async Task GenerateQR(IBarcodeApi api, string fileName)
private static async Task GenerateQR(IGenerateApi api, string fileName)
{
await using Stream generated = await api.GetBarcodeGenerateAsync(
new GetBarcodeGenerateRequest(
EncodeBarcodeType.QR.ToString(),
"QR code text")
{
TextLocation = CodeLocation.None.ToString(),
format = "png"
});
await using Stream generated = await api.GenerateAsync(
EncodeBarcodeType.QR,
"QR code text",
textLocation: CodeLocation.None,
imageFormat: BarcodeImageFormat.Png
);
await using FileStream stream = File.Create(fileName);
await generated.CopyToAsync(stream);
}
Expand All @@ -184,7 +190,7 @@ internal static class Program
"qr.png"
));

BarcodeApi api = new BarcodeApi(MakeConfiguration());
GenerateApi api = new GenerateApi(MakeConfiguration());

await GenerateQR(api, fileName);
Console.WriteLine($"File '{fileName}' generated.");
Expand Down Expand Up @@ -212,112 +218,38 @@ All Aspose.BarCode for Cloud SDKs, helper scripts and templates are licensed und

## Documentation for API Endpoints

All URIs are relative to *<https://api.aspose.cloud/v3.0>*
All URIs are relative to *<https://api.aspose.cloud/v4.0>*

Class | Method | HTTP request | Description
----- | ------ | ------------ | -----------
*BarcodeApi* | [**GetBarcodeGenerate**](docs/BarcodeApi.md#getbarcodegenerate) | **GET** /barcode/generate | Generate barcode.
*BarcodeApi* | [**GetBarcodeRecognize**](docs/BarcodeApi.md#getbarcoderecognize) | **GET** /barcode/{name}/recognize | Recognize barcode from a file on server.
*BarcodeApi* | [**PostBarcodeRecognizeFromUrlOrContent**](docs/BarcodeApi.md#postbarcoderecognizefromurlorcontent) | **POST** /barcode/recognize | Recognize barcode from an url or from request body. Request body can contain raw data bytes of the image with content-type \"application/octet-stream\". An image can also be passed as a form field.
*BarcodeApi* | [**PostGenerateMultiple**](docs/BarcodeApi.md#postgeneratemultiple) | **POST** /barcode/generateMultiple | Generate multiple barcodes and return in response stream
*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)
*BarcodeApi* | [**PutBarcodeRecognizeFromBody**](docs/BarcodeApi.md#putbarcoderecognizefrombody) | **PUT** /barcode/{name}/recognize | Recognition of a barcode from file on server with parameters in body.
*BarcodeApi* | [**PutGenerateMultiple**](docs/BarcodeApi.md#putgeneratemultiple) | **PUT** /barcode/{name}/generateMultiple | Generate image with multiple barcodes and put new file on server
*BarcodeApi* | [**ScanBarcode**](docs/BarcodeApi.md#scanbarcode) | **POST** /barcode/scan | Quickly scan a barcode from an image.
*FileApi* | [**CopyFile**](docs/FileApi.md#copyfile) | **PUT** /barcode/storage/file/copy/{srcPath} | Copy file
*FileApi* | [**DeleteFile**](docs/FileApi.md#deletefile) | **DELETE** /barcode/storage/file/{path} | Delete file
*FileApi* | [**DownloadFile**](docs/FileApi.md#downloadfile) | **GET** /barcode/storage/file/{path} | Download file
*FileApi* | [**MoveFile**](docs/FileApi.md#movefile) | **PUT** /barcode/storage/file/move/{srcPath} | Move file
*FileApi* | [**UploadFile**](docs/FileApi.md#uploadfile) | **PUT** /barcode/storage/file/{path} | Upload file
*FolderApi* | [**CopyFolder**](docs/FolderApi.md#copyfolder) | **PUT** /barcode/storage/folder/copy/{srcPath} | Copy folder
*FolderApi* | [**CreateFolder**](docs/FolderApi.md#createfolder) | **PUT** /barcode/storage/folder/{path} | Create the folder
*FolderApi* | [**DeleteFolder**](docs/FolderApi.md#deletefolder) | **DELETE** /barcode/storage/folder/{path} | Delete folder
*FolderApi* | [**GetFilesList**](docs/FolderApi.md#getfileslist) | **GET** /barcode/storage/folder/{path} | Get all files and folders within a folder
*FolderApi* | [**MoveFolder**](docs/FolderApi.md#movefolder) | **PUT** /barcode/storage/folder/move/{srcPath} | Move folder
*StorageApi* | [**GetDiscUsage**](docs/StorageApi.md#getdiscusage) | **GET** /barcode/storage/disc | Get disc usage
*StorageApi* | [**GetFileVersions**](docs/StorageApi.md#getfileversions) | **GET** /barcode/storage/version/{path} | Get file versions
*StorageApi* | [**ObjectExists**](docs/StorageApi.md#objectexists) | **GET** /barcode/storage/exist/{path} | Check if file or folder exists
*StorageApi* | [**StorageExists**](docs/StorageApi.md#storageexists) | **GET** /barcode/storage/{storageName}/exist | Check if storage exists
*GenerateApi* | [**Generate**](docs/GenerateApi.md#generate) | **GET** /barcode/generate/{barcodeType} | Generate barcode using GET request with parameters in route and query string.
*GenerateApi* | [**GenerateBody**](docs/GenerateApi.md#generatebody) | **POST** /barcode/generate-body | Generate barcode using POST request with parameters in body in json or xml format.
*GenerateApi* | [**GenerateMultipart**](docs/GenerateApi.md#generatemultipart) | **POST** /barcode/generate-multipart | Generate barcode using POST request with parameters in multipart form.
*RecognizeApi* | [**Recognize**](docs/RecognizeApi.md#recognize) | **GET** /barcode/recognize | Recognize barcode from file on server using GET requests with parameters in route and query string.
*RecognizeApi* | [**RecognizeBase64**](docs/RecognizeApi.md#recognizebase64) | **POST** /barcode/recognize-body | Recognize barcode from file in request body using POST requests with parameters in body in json or xml format.
*RecognizeApi* | [**RecognizeMultipart**](docs/RecognizeApi.md#recognizemultipart) | **POST** /barcode/recognize-multipart | Recognize barcode from file in request body using POST requests with parameters in multipart form.
*ScanApi* | [**Scan**](docs/ScanApi.md#scan) | **GET** /barcode/scan | Scan barcode from file on server using GET requests with parameter in query string.
*ScanApi* | [**ScanBase64**](docs/ScanApi.md#scanbase64) | **POST** /barcode/scan-body | Scan barcode from file in request body using POST requests with parameter in body in json or xml format.
*ScanApi* | [**ScanMultipart**](docs/ScanApi.md#scanmultipart) | **POST** /barcode/scan-multipart | Scan barcode from file in request body using POST requests with parameter in multipart form.

## Documentation for Models

- [Model.ApiError](docs/ApiError.md)
- [Model.ApiErrorResponse](docs/ApiErrorResponse.md)
- [Model.AustralianPostParams](docs/AustralianPostParams.md)
- [Model.AutoSizeMode](docs/AutoSizeMode.md)
- [Model.AvailableGraphicsUnit](docs/AvailableGraphicsUnit.md)
- [Model.AztecEncodeMode](docs/AztecEncodeMode.md)
- [Model.AztecParams](docs/AztecParams.md)
- [Model.AztecSymbolMode](docs/AztecSymbolMode.md)
- [Model.BarcodeImageFormat](docs/BarcodeImageFormat.md)
- [Model.BarcodeImageParams](docs/BarcodeImageParams.md)
- [Model.BarcodeResponse](docs/BarcodeResponse.md)
- [Model.BarcodeResponseList](docs/BarcodeResponseList.md)
- [Model.BorderDashStyle](docs/BorderDashStyle.md)
- [Model.CaptionParams](docs/CaptionParams.md)
- [Model.ChecksumValidation](docs/ChecksumValidation.md)
- [Model.CodabarChecksumMode](docs/CodabarChecksumMode.md)
- [Model.CodabarParams](docs/CodabarParams.md)
- [Model.CodabarSymbol](docs/CodabarSymbol.md)
- [Model.CodablockParams](docs/CodablockParams.md)
- [Model.Code128Emulation](docs/Code128Emulation.md)
- [Model.Code128EncodeMode](docs/Code128EncodeMode.md)
- [Model.Code128Params](docs/Code128Params.md)
- [Model.Code16KParams](docs/Code16KParams.md)
- [Model.CodeLocation](docs/CodeLocation.md)
- [Model.CouponParams](docs/CouponParams.md)
- [Model.CustomerInformationInterpretingType](docs/CustomerInformationInterpretingType.md)
- [Model.DataBarParams](docs/DataBarParams.md)
- [Model.DataMatrixEccType](docs/DataMatrixEccType.md)
- [Model.DataMatrixEncodeMode](docs/DataMatrixEncodeMode.md)
- [Model.DataMatrixParams](docs/DataMatrixParams.md)
- [Model.DataMatrixVersion](docs/DataMatrixVersion.md)
- [Model.DecodeBarcodeType](docs/DecodeBarcodeType.md)
- [Model.DiscUsage](docs/DiscUsage.md)
- [Model.DotCodeEncodeMode](docs/DotCodeEncodeMode.md)
- [Model.DotCodeParams](docs/DotCodeParams.md)
- [Model.ECIEncodings](docs/ECIEncodings.md)
- [Model.EnableChecksum](docs/EnableChecksum.md)
- [Model.EncodeBarcodeType](docs/EncodeBarcodeType.md)
- [Model.Error](docs/Error.md)
- [Model.ErrorDetails](docs/ErrorDetails.md)
- [Model.FileVersions](docs/FileVersions.md)
- [Model.FilesList](docs/FilesList.md)
- [Model.FilesUploadResult](docs/FilesUploadResult.md)
- [Model.FontMode](docs/FontMode.md)
- [Model.FontParams](docs/FontParams.md)
- [Model.FontStyle](docs/FontStyle.md)
- [Model.GeneratorParams](docs/GeneratorParams.md)
- [Model.GeneratorParamsList](docs/GeneratorParamsList.md)
- [Model.HanXinEncodeMode](docs/HanXinEncodeMode.md)
- [Model.HanXinErrorLevel](docs/HanXinErrorLevel.md)
- [Model.HanXinParams](docs/HanXinParams.md)
- [Model.HanXinVersion](docs/HanXinVersion.md)
- [Model.ITF14BorderType](docs/ITF14BorderType.md)
- [Model.ITFParams](docs/ITFParams.md)
- [Model.MacroCharacter](docs/MacroCharacter.md)
- [Model.MaxiCodeEncodeMode](docs/MaxiCodeEncodeMode.md)
- [Model.MaxiCodeMode](docs/MaxiCodeMode.md)
- [Model.MaxiCodeParams](docs/MaxiCodeParams.md)
- [Model.ObjectExist](docs/ObjectExist.md)
- [Model.Padding](docs/Padding.md)
- [Model.PatchCodeParams](docs/PatchCodeParams.md)
- [Model.PatchFormat](docs/PatchFormat.md)
- [Model.Pdf417CompactionMode](docs/Pdf417CompactionMode.md)
- [Model.Pdf417ErrorLevel](docs/Pdf417ErrorLevel.md)
- [Model.Pdf417MacroTerminator](docs/Pdf417MacroTerminator.md)
- [Model.Pdf417Params](docs/Pdf417Params.md)
- [Model.PostalParams](docs/PostalParams.md)
- [Model.PresetType](docs/PresetType.md)
- [Model.QREncodeMode](docs/QREncodeMode.md)
- [Model.QREncodeType](docs/QREncodeType.md)
- [Model.QRErrorLevel](docs/QRErrorLevel.md)
- [Model.QRVersion](docs/QRVersion.md)
- [Model.QrParams](docs/QrParams.md)
- [Model.ReaderParams](docs/ReaderParams.md)
- [Model.EncodeData](docs/EncodeData.md)
- [Model.EncodeDataType](docs/EncodeDataType.md)
- [Model.GenerateParams](docs/GenerateParams.md)
- [Model.GraphicsUnit](docs/GraphicsUnit.md)
- [Model.RecognitionImageKind](docs/RecognitionImageKind.md)
- [Model.RecognitionMode](docs/RecognitionMode.md)
- [Model.RecognizeBase64Request](docs/RecognizeBase64Request.md)
- [Model.RegionPoint](docs/RegionPoint.md)
- [Model.ResultImageInfo](docs/ResultImageInfo.md)
- [Model.StorageExist](docs/StorageExist.md)
- [Model.StorageFile](docs/StorageFile.md)
- [Model.StructuredAppend](docs/StructuredAppend.md)
- [Model.TextAlignment](docs/TextAlignment.md)
- [Model.FileVersion](docs/FileVersion.md)
- [Model.ScanBase64Request](docs/ScanBase64Request.md)

21 changes: 9 additions & 12 deletions Tests/ApiExceptionTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Model;
using Aspose.BarCode.Cloud.Sdk.Model.Requests;

using NUnit.Framework;

namespace Aspose.BarCode.Cloud.Sdk.Tests
Expand All @@ -14,21 +14,18 @@ public class ApiExceptionTests : TestsBase
public void GetBarcodeGenerateAsyncTestThrows()
{
// Arrange
var api = new BarcodeApi(clientId: "client id", clientSecret: "client secret");
var request = new GetBarcodeGenerateRequest(
text: "Very sample text",
type: EncodeBarcodeType.Code128.ToString()
)
{
format = "png"
};
GenerateApi api = new GenerateApi(clientId: "client id", clientSecret: "client secret");

// Acts
var ex = Assert.ThrowsAsync<ApiException>(
async () => { await api.GetBarcodeGenerateAsync(request); });
ApiException ex = Assert.ThrowsAsync<ApiException>(
async () =>
{
await api.GenerateAsync(data: "Very sample text",
barcodeType: EncodeBarcodeType.Code128, imageFormat: BarcodeImageFormat.Png);
});

Assert.AreEqual(400, ex!.ErrorCode);
Assert.AreEqual("Bad Request", ex.Message);
Assert.AreEqual("{\"error\":\"invalid_client\"}: ", ex.Message);
}
}
}
Loading
Loading