zenta-ab / fortnox.NET

Dotnet SDK for Fortnox API
MIT License
17 stars 7 forks source link

Model types & documentation #33

Closed brokenprogrammer closed 3 years ago

brokenprogrammer commented 3 years ago

In PR #28 we introduced a set of breaking changes to the library and I want to address all related issues that were fixed in that PR before we make a new major release of the library.

In response to that I want to make a more coordinated effort to fixing the problems we've talked about which mainly is that some data types are of the wrong type according to the API. In #31 we are still having a discussion about decimal vs float but there are still parts of the SDK that have for example dates and integers set as strings which shouldn't be. In addition to this we have also been using strings instead of enum data types on a lot of places where an enum would be a better fit. This is something we can also look over while working on this.

In order for the enum types to be serialized correctly you have to add the following annotation to the enum property in your model:

/// <summary>
/// Cause code
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public CauseCode CauseCode { get; set; }

Within the CauseCode enum we use the EnumMember annotation to specify the string value according to Fortnox API documentation:

public enum CauseCode
{
    /// <summary>
    /// Arbetsskada
    /// </summary>
    [EnumMember(Value = "ASK")]
    ASK,

    /// <summary>
    /// Arbetstidsförkortning
    /// </summary>
    [EnumMember(Value = "ATF")]
    ATF,

    /// <summary>
    /// Föräldraledig
    /// </summary>
    [EnumMember(Value = "FPE")]
    FPE,

...

While fixing this I also had the idea that we can add documentation to the models. This is a very easy task as it can be copied from the API documentation while looking over the types for each model.

Right now lets focus on just adding the documentation and fixing the types. I know that in order to prove that this is actually working we need additional tests to be added. And probably also make changes to the services but this can wait for now and lets focus on the models in order to make a new coordinated effort later on.

Here is a list of the remaining Models that needs to be looked over and have documentation added to them (Ones that are checked are finished):

If you are interested in helping with this task please comment which Models you'd like to look over so that others know not the work on the same one!

brokenprogrammer commented 3 years ago

This has been resolves as of #34