trbngr / infusio

Functional Infusionsoft API DSL for .NET
MIT License
4 stars 6 forks source link

"Field" enum is not correctly serialized #21

Open poliez opened 6 years ago

poliez commented 6 years ago

When creating a new contact, if it does include an email, which has a "Field" attribute, it gets serialized like

{
    "email_addresses" : [
        {
            "email" : "email@gmail.com",
            "field": 3
        }
    ]
}

Instead of

{
    "email_addresses" : [
        {
            "email" : "email@gmail.com",
            "field": "EMAIL1"
        }
    ]
}

I've already solved this issue and will provide a pull request in a few minutes!

dan-i-am commented 6 years ago

This is related to issues discussed here: https://github.com/trbngr/infusio/issues/17

Unfortunately, the real source of the enum problems are in the code generation that creates the API client, dsl and dto classes. However, what you're doing in the pull request does address the number vs value expression/parsing problem and could probably be moved to the code generator templates.

poliez commented 6 years ago

I just went through Dto.liquid and definitely think that you are right. I didn't pay attention to the .liquid files today at work. I was in a rush and just wanted it to work 😃

10 minutes ago i didn't know anything at all about the Liquid project itself 😅

I also looked at infusionsoft.json and all his enum attributes. As you said, updating Dto.liquid with [JsonConverter(typeof(StringEnumConverter))] in the right place could fix the problem. I'm going to try this now!

In no more than two days i'm going to test it and submit a pull request if all goes as expected! (If I'm misbehaveing about how to write commits or how to submit pull-requests and when just let me know, please! It could be really valuable information 😄)

trbngr commented 6 years ago

Thanks @Poliez !

I'm sorry for being out of touch lately, guys. Just busy busy.