In this article you will learn how to implement the FiscalClient using nuget.
Requirements
- Knowledge of .net development
- Knowledge in the use of nuget packages
- Download the packages RetailForce.
Fiscalisation - Environment platform that supports .net Standard 2.0
Implementation
Configuration-Provider
To save the configuration, you need a FileConfigurationProvider with the path to the configuration file:
FileConfigurationProvider fileConfigurationProvider = new FileConfigurationProvider(System.IO.Path.Combine(this.FilesDir.ToString(), "fiscalclient.config.json"));
(Android).
Fiscal module management
To create clients or load the configuration from the cloud, you need the FiscalModuleManagement class:
FiscalModuleManagement moduleManagement = new FiscalModuleManagement(_logger, fileConfigurationProvider);
The logger is derived from Microsoft.Extensions.Logging.ILogger.
Load client from the cloud
To load the client from the cloud, you can use the command CreateClientByCloud:
uniqueClientId = moduleManagement.CreateClientByCloud(new CompanyIdentification() { Identification = "ATU1234567", Type = CompanyIdentification.IdentificationType.VatNumber }, "T001", "T001", cloudApiKey, cloudApiSecret);
Create client manually
The client can also be created manually (FiscalClient). Once this class has been created, the client can be created with CreateClient.
Create a fiscal module
A fiscal module can be created with the FiscalModuleCreator class:
CloudService cloudService = new CloudService(_logger, storageBasePath, uniqueClientId.Value, cloudApiKey, cloudApiSecret);
FiscalModulCreator creator = new FiscalModulCreator(fileConfigurationProvider, _logger, cloudService);
This creates the fiscal module. The CloudService is a class that should be kept in the software for the entire runtime. It takes care of the background transfer to the cloud.
If no cloud support is required, then CloudService can also be omitted.
Creating the fiscal module
After the Fiscal Module Creator class has been initialised, the fiscal module can be created.
TrustedFiscalModule fiscalModule = creator.CreateFiscalModuleForClient(uniqueClientId.Value, storageBasePath: this.GetExternalFilesDir(Android.OS.Environment.DirectoryDocuments).AbsolutePath, cloudApiKey: cloudApiKey, cloudApiSecret: cloudApiSecret);
Here too, if cloud support is not required, the cloud service and the cloud securables (cloudApiKey, cloudApiSecret) can be omitted.
IMPORTANT: The client configuration must have been created beforehand. Either by downloading from the cloud or via CreateClient (see above).
Comments
0 comments
Please sign in to leave a comment.