Skip to content

Commit 0491034

Browse files
committed
logging added
1 parent 5f2b1b1 commit 0491034

File tree

12 files changed

+68
-31
lines changed

12 files changed

+68
-31
lines changed

Auth/AuthService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Fiscalapi.XmlDownloader.Auth.Models;
2020
using Fiscalapi.XmlDownloader.Common;
2121
using Fiscalapi.XmlDownloader.Common.Http;
22+
using Microsoft.Extensions.Logging;
2223

2324
namespace Fiscalapi.XmlDownloader.Auth;
2425

@@ -31,7 +32,7 @@ public class AuthService : SatService, IAuthService
3132
/// Authenticates with SAT using the provided credential and returns the authentication token
3233
/// </summary>
3334
public async Task<AuthResponse> AuthenticateAsync(ICredential credential,
34-
CancellationToken cancellationToken = default)
35+
CancellationToken cancellationToken = default, ILogger? logger = null)
3536
{
3637
// Generate Sat XML security token ID
3738
var uuid = CreateSecurityToken();

Auth/IAuthService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
using Fiscalapi.Credentials.Core;
1818
using Fiscalapi.XmlDownloader.Auth.Models;
19+
using Microsoft.Extensions.Logging;
1920

2021
namespace Fiscalapi.XmlDownloader.Auth;
2122

@@ -29,6 +30,8 @@ public interface IAuthService
2930
/// </summary>
3031
/// <param name="credential"></param>
3132
/// <param name="cancellationToken">CancellationToken</param>
33+
/// <param name="logger">Logger</param>
3234
/// <returns></returns>
33-
Task<AuthResponse> AuthenticateAsync(ICredential credential, CancellationToken cancellationToken = default);
35+
Task<AuthResponse> AuthenticateAsync(ICredential credential, CancellationToken cancellationToken = default,
36+
ILogger? logger = null);
3437
}

Download/DownloadService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Fiscalapi.XmlDownloader.Common;
2121
using Fiscalapi.XmlDownloader.Common.Http;
2222
using Fiscalapi.XmlDownloader.Download.Models;
23+
using Microsoft.Extensions.Logging;
2324

2425
namespace Fiscalapi.XmlDownloader.Download;
2526

@@ -35,9 +36,10 @@ public class DownloadService : SatService, IDownloadService
3536
/// <param name="authToken">Authentication token</param>
3637
/// <param name="packageId">PackageID</param>
3738
/// <param name="cancellationToken">CancellationToken</param>
39+
/// <param name="logger">Logger</param>
3840
/// <returns>DownloadResponse</returns>
3941
public async Task<DownloadResponse> DownloadAsync(ICredential credential, Token authToken, string packageId,
40-
CancellationToken cancellationToken = default)
42+
CancellationToken cancellationToken = default, ILogger? logger = null)
4143
{
4244
var toDigest = CreateDigest(packageId, credential.Certificate.Rfc);
4345
var signature = CreateSignature(credential, toDigest);

Download/IDownloadService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Fiscalapi.Credentials.Core;
1818
using Fiscalapi.XmlDownloader.Auth.Models;
1919
using Fiscalapi.XmlDownloader.Download.Models;
20+
using Microsoft.Extensions.Logging;
2021

2122
namespace Fiscalapi.XmlDownloader.Download;
2223

@@ -32,7 +33,8 @@ public interface IDownloadService
3233
/// <param name="authToken">Authentication token</param>
3334
/// <param name="packageId">PackageID</param>
3435
/// <param name="cancellationToken">CancellationToken</param>
36+
/// <param name="logger">Logger</param>
3537
/// <returns>DownloadResponse</returns>
3638
Task<DownloadResponse> DownloadAsync(ICredential credential, Token authToken, string packageId,
37-
CancellationToken cancellationToken = default);
39+
CancellationToken cancellationToken = default, ILogger? logger = null);
3840
}

FileStorage/FileStorageService.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.IO.Compression;
2+
using Microsoft.Extensions.Logging;
23

34
namespace Fiscalapi.XmlDownloader.FileStorage
45
{
@@ -72,8 +73,9 @@ public bool FileExists(string fullFilePath)
7273
/// <param name="fullFilePath">Full path to the ZIP file</param>
7374
/// <param name="extractToPath">Path to extract files to</param>
7475
/// <param name="cancellationToken">Cancellation token</param>
76+
/// <param name="logger">Logger</param>
7577
public void ExtractZipFile(string fullFilePath, string? extractToPath,
76-
CancellationToken cancellationToken = default)
78+
CancellationToken cancellationToken = default, ILogger? logger = null)
7779
{
7880
if (string.IsNullOrWhiteSpace(fullFilePath))
7981
throw new ArgumentException("ZIP file path cannot be null or empty", nameof(fullFilePath));
@@ -141,8 +143,9 @@ public List<FileDetails> GetFiles(string directoryPath, string? fileExtension =
141143
/// <param name="fullFilePath">Full path to the file</param>
142144
/// <param name="data">Binary data to write</param>
143145
/// <param name="cancellationToken">Cancellation token</param>
146+
/// <param name="logger">Logger</param>
144147
public async Task WriteFileAsync(string fullFilePath, byte[] data,
145-
CancellationToken cancellationToken = default)
148+
CancellationToken cancellationToken = default, ILogger? logger = null)
146149
{
147150
var directory = Path.GetDirectoryName(fullFilePath);
148151
if (string.IsNullOrEmpty(directory) || !Directory.Exists(directory))
@@ -159,8 +162,9 @@ public async Task WriteFileAsync(string fullFilePath, byte[] data,
159162
/// <param name="fullFilePath">Full path to the file</param>
160163
/// <param name="base64Data">Base64 encoded data to write</param>
161164
/// <param name="cancellationToken">Cancellation token</param>
165+
/// <param name="logger">Logger</param>
162166
public async Task WriteFileAsync(string fullFilePath, string base64Data,
163-
CancellationToken cancellationToken = default)
167+
CancellationToken cancellationToken = default, ILogger? logger = null)
164168
{
165169
var data = Convert.FromBase64String(base64Data);
166170
await WriteFileAsync(fullFilePath, data, cancellationToken);
@@ -171,8 +175,10 @@ public async Task WriteFileAsync(string fullFilePath, string base64Data,
171175
/// </summary>
172176
/// <param name="fullFilePath">Full path to the file</param>
173177
/// <param name="cancellationToken">Cancellation token</param>
178+
/// <param name="logger">Logger</param>
174179
/// <returns>File content as byte array</returns>
175-
public async Task<byte[]> ReadFileAsync(string fullFilePath, CancellationToken cancellationToken = default)
180+
public async Task<byte[]> ReadFileAsync(string fullFilePath, CancellationToken cancellationToken = default,
181+
ILogger? logger = null)
176182
{
177183
return await File.ReadAllBytesAsync(fullFilePath, cancellationToken);
178184
}
@@ -182,9 +188,10 @@ public async Task<byte[]> ReadFileAsync(string fullFilePath, CancellationToken c
182188
/// </summary>
183189
/// <param name="fullFilePath">Full path to the file</param>
184190
/// <param name="cancellationToken">Cancellation token</param>
191+
/// <param name="logger">Logger</param>
185192
/// <returns>File content as string</returns>
186193
public async Task<string> ReadFileContentAsync(string fullFilePath,
187-
CancellationToken cancellationToken = default)
194+
CancellationToken cancellationToken = default, ILogger? logger = null)
188195
{
189196
return await File.ReadAllTextAsync(fullFilePath, cancellationToken);
190197
}

FileStorage/IFileStorageService.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* ============================================================================
1515
*/
1616

17+
using Microsoft.Extensions.Logging;
18+
1719
namespace Fiscalapi.XmlDownloader.FileStorage;
1820

1921
/// <summary>
@@ -54,9 +56,10 @@ public interface IFileStorageService
5456
/// <param name="fullFilePath">Full path to the ZIP file</param>
5557
/// <param name="extractToPath">Path to extract files to</param>
5658
/// <param name="cancellationToken">Cancellation token</param>
59+
/// <param name="logger">Logger</param>
5760
/// <returns>Completion Task</returns>
5861
void ExtractZipFile(string fullFilePath, string extractToPath,
59-
CancellationToken cancellationToken = default);
62+
CancellationToken cancellationToken = default, ILogger? logger = null);
6063

6164
/// <summary>
6265
/// Get a list of files from the specified directory with optional file extension filter
@@ -72,31 +75,39 @@ void ExtractZipFile(string fullFilePath, string extractToPath,
7275
/// <param name="fullFilePath">Full path to the file</param>
7376
/// <param name="data">Binary data to write</param>
7477
/// <param name="cancellationToken">Cancellation token</param>
75-
Task WriteFileAsync(string fullFilePath, byte[] data, CancellationToken cancellationToken = default);
78+
/// <param name="logger">Logger</param>
79+
Task WriteFileAsync(string fullFilePath, byte[] data, CancellationToken cancellationToken = default,
80+
ILogger? logger = null);
7681

7782
/// <summary>
7883
/// Write base64 encoded data to a file
7984
/// </summary>
8085
/// <param name="fullFilePath">Full path to the file</param>
8186
/// <param name="base64Data">Base64 encoded data to write</param>
8287
/// <param name="cancellationToken">Cancellation token</param>
83-
Task WriteFileAsync(string fullFilePath, string base64Data, CancellationToken cancellationToken = default);
88+
/// <param name="logger">Logger</param>
89+
Task WriteFileAsync(string fullFilePath, string base64Data, CancellationToken cancellationToken = default,
90+
ILogger? logger = null);
8491

8592
/// <summary>
8693
/// Read file content as byte array
8794
/// </summary>
8895
/// <param name="fullFilePath">Full path to the file</param>
8996
/// <param name="cancellationToken">Cancellation token</param>
97+
/// <param name="logger">Logger</param>
9098
/// <returns>File content as byte array</returns>
91-
Task<byte[]> ReadFileAsync(string fullFilePath, CancellationToken cancellationToken = default);
99+
Task<byte[]> ReadFileAsync(string fullFilePath, CancellationToken cancellationToken = default,
100+
ILogger? logger = null);
92101

93102
/// <summary>
94103
/// Read file content as string
95104
/// </summary>
96105
/// <param name="fullFilePath">Full path to the file</param>
97106
/// <param name="cancellationToken">Cancellation token</param>
107+
/// <param name="logger">Logger</param>
98108
/// <returns>File content as string</returns>
99-
Task<string> ReadFileContentAsync(string fullFilePath, CancellationToken cancellationToken = default);
109+
Task<string> ReadFileContentAsync(string fullFilePath, CancellationToken cancellationToken = default,
110+
ILogger? logger = null);
100111

101112
/// <summary>
102113
/// Delete a file

IXmlDownloaderService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
using Fiscalapi.XmlDownloader.Download.Models;
2121
using Fiscalapi.XmlDownloader.Query.Models;
2222
using Fiscalapi.XmlDownloader.Verify.Models;
23-
using System.Runtime.CompilerServices;
2423

2524
namespace Fiscalapi.XmlDownloader;
2625

Query/IQueryService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Fiscalapi.Credentials.Core;
1818
using Fiscalapi.XmlDownloader.Auth.Models;
1919
using Fiscalapi.XmlDownloader.Query.Models;
20+
using Microsoft.Extensions.Logging;
2021

2122
namespace Fiscalapi.XmlDownloader.Query;
2223

@@ -32,7 +33,8 @@ public interface IQueryService
3233
/// <param name="authToken">Authentication token</param>
3334
/// <param name="parameters">Request parameters</param>
3435
/// <param name="cancellationToken">CancellationToken</param>
36+
/// <param name="logger">Logger</param>
3537
/// <returns>QueryResponse</returns>
3638
Task<QueryResponse> CreateAsync(ICredential credential, Token authToken,
37-
QueryParameters parameters, CancellationToken cancellationToken);
39+
QueryParameters parameters, CancellationToken cancellationToken, ILogger? logger = null);
3840
}

Query/QueryService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Fiscalapi.XmlDownloader.Common;
2121
using Fiscalapi.XmlDownloader.Common.Http;
2222
using Fiscalapi.XmlDownloader.Query.Models;
23+
using Microsoft.Extensions.Logging;
2324

2425
namespace Fiscalapi.XmlDownloader.Query;
2526

@@ -35,9 +36,10 @@ public class QueryService : SatService, IQueryService
3536
/// <param name="authToken">Authentication token</param>
3637
/// <param name="parameters">Request parameters</param>
3738
/// <param name="cancellationToken">CancellationToken</param>
39+
/// <param name="logger">Logger</param>
3840
/// <returns>QueryResponse</returns>
3941
public async Task<QueryResponse> CreateAsync(ICredential credential, Token authToken,
40-
QueryParameters parameters, CancellationToken cancellationToken = default)
42+
QueryParameters parameters, CancellationToken cancellationToken = default, ILogger? logger = null)
4143
{
4244
var operationType = DetermineOperationType(parameters);
4345
var toDigest = CreateDigest(parameters, operationType);

Verify/IVerifyService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Fiscalapi.Credentials.Core;
1818
using Fiscalapi.XmlDownloader.Auth.Models;
1919
using Fiscalapi.XmlDownloader.Verify.Models;
20+
using Microsoft.Extensions.Logging;
2021

2122
namespace Fiscalapi.XmlDownloader.Verify;
2223

@@ -32,7 +33,8 @@ public interface IVerifyService
3233
/// <param name="authToken">Authentication token</param>
3334
/// <param name="requestId">Request ID</param>
3435
/// <param name="cancellationToken">CancellationToken</param>
36+
/// <param name="logger">Logger</param>
3537
/// <returns>VerifyResponse</returns>
3638
Task<VerifyResponse> VerifyAsync(ICredential credential, Token authToken, string requestId,
37-
CancellationToken cancellationToken = default);
39+
CancellationToken cancellationToken = default, ILogger? logger = null);
3840
}

0 commit comments

Comments
 (0)