QbModels 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package QbModels --version 1.2.0                
NuGet\Install-Package QbModels -Version 1.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="QbModels" Version="1.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add QbModels --version 1.2.0                
#r "nuget: QbModels, 1.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install QbModels as a Cake Addin
#addin nuget:?package=QbModels&version=1.2.0

// Install QbModels as a Cake Tool
#tool nuget:?package=QbModels&version=1.2.0                

QbModels

Quickbooks C# strongly typed object models to generate QBXML without writing XML code and read QBXML responses back to strongly typed object models.

This is part of a personal pet project I've been working on to help update and improve my C# coding skills and experience. This dll allows me to generate the QBXML to call Quickbooks Desktop API without having to write XML code using the QbModels and QbModels.ENUM namespace. This is done using 100% .netstandard2.1 calls. There are no custom DLLs or other libraries used to generate the QBXML and/or process the results. If you want to create QBXML and read responses using class objects instead of worrying about XML structures, I've created this tool to do so.

Note: I've skipped the version number to v1.2.0 to be in sync with my internal NuGet repository.

For example, the following C# code:

using QbModels;

#region Create customer query request with a maximum of 50 responses
CustomerQueryRq customerRq = new() { MaxReturned = 50, Iterator = "Start" };
Console.WriteLine(customerRq.ToString());
#endregion

Produces the following output:

<?xml version="1.0" encoding="utf-16"?>
<?qbxml version="13.0"?>
<QBXML>
  <QBXMLMsgsRq onError="stopOnError">
    <CustomerQueryRq iterator="Start">
      <MaxReturned>50</MaxReturned>
    </CustomerQueryRq>
  </QBXMLMsgsRq>
</QBXML>

As of v1.2.0, I've refactored all the views to convert the response QBXML into a C# class object through the constructor (no more need to call the ToView extension) with the added benefit of reducing the dll size. The class object can then be accessed and manipulated with LINQ or standard C# code. The dll includes over 55 object views (ie AccountRs, InvoiceRs, CustomerRs, VendorRs, etc) that will convert the QBXML response into a C# object that can be accessed via C#.

AccountQueryRq accountsRq = new();
string qbRs = QB.ExecuteQbRequest(accountsRq); // QB.ExecuteQbRequest is from my personal class library and returns the QBXML from the RP Processor
AccountRs accounts = new(qbRs);
if(accounts.StatusCode == "0" && accounts.Accounts.Count > 0)
{
  AccountRetDto account = accounts.Accounts.FirstOrDefault(a => a.AccountType == "AccountsPayable");
  AccountRetDto bank = accounts.Accounts.FirstOrDefault(a => a.AccountType == "Bank");
}

I've also added a couple of validation extensions using DataAnnotations and custom ValidationAttributes to be able to call IsEntityValid() and/or GetErrorsList() on the object. This will help to notify you if your data is not valid. This is not 100% but will warn you of a lot of different potential errors in your requests. Also; these methods are optional and regardless of the results of the IsEntityValid, the .ToString() method will output the QBXML. Personally, I use them during development to see where I may have added bad or incomplete data.

if(customerRq.IsEntityValid())
{
  ...Your code here
}
else
{
  foreach(string s in customerRq.GetErrorsList())
  {
    ...Your code here
  }
}

I have objects for the majority of QBXML calls but have only used and tested a few since that's all I need. Have completed the majority of the Unit Tests for generating the QBXML as well as sending the QBXML to the request processor. The UnitTests folder contains the unit tests project I created to test the QbModel library project. I also uploaded my personal request processor that I use to send/receive QBXML to/from the Quickbooks request processor. This QbProcessor library is very limited but runs within a WPF/WinForm desktop application. It will only work with a currently opened Quickbooks data file.

I have covered the majority of QBXML requests in my unit testing but there are still bugs to be found. If you do use this, please report these bugs so that I can look into why it's not working. Look at the included unit test code I uploaded for testing the InvoiceQueryRq/InvoiceAddRq/InvoiceModRq QBXML calls to see how I use the dll to generate the QBXML and then convert the QBXML result string back into a C# object (in this case InvoiceRs).

Another note, I changed the target framework to netstandard2.0. This should make it more compatible with any projects you incorporate this into that based on .Net Framework 4.6 and 4.7. Theoretically; since this is straight dotNet code and objects, this should also be compatible with VB but I haven't programmed in VB in many years so I haven't tested.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.13 324 2/20/2024
1.2.13-beta01 103 2/20/2024
1.2.12 131 2/19/2024
1.2.11 152 2/16/2024
1.2.11-beta01 102 2/16/2024
1.2.10 120 1/30/2024
1.2.9 106 1/30/2024
1.2.9-beta-01 92 1/29/2024
1.2.7 171 12/29/2023
1.2.6 124 12/22/2023
1.2.5 126 12/21/2023
1.2.1 1,454 5/19/2022
1.2.0 453 4/18/2022
1.0.5 413 4/12/2022
1.0.4 412 4/10/2022
1.0.3 435 4/7/2022
1.0.2 444 4/3/2022
1.0.1 411 3/31/2022
1.0.0 416 3/30/2022

Made major changes to the serialization process.  As such, am changing the version number to 1.2.x to synchronize between NuGet and GitHub.

Completely rewrote the serialization process to use IXmlSerializable instead of relying solely on XmlSerializer.  This allows me to have greater control over the serialization process.  Because of this, have eliminated all the Overload and Specified properties that were required to make the XmlSerializer work properly resulting in fewer and cleaner properties.  Also used ENUM properties where appropriate.  This would have been done from the onset but the XmlSerializer was having issues with this.

On another note, decided to deprecate all Qb{request type}View model views.  Decided instead to start naming the views {request type}Rs.  The Qb...View is still there but will be removed some time in the future.  This also makes for cleaner coding (IMO).  For example, for Invoice request types, the intellisense should list:
InvoiceAddRq
InvoiceModRq
InvoiceQueryRq
InvoiceRetDto
InvoiceRs