softwerkab / fortnox-csharp-api-sdk

.NET SDK for Fortnox API.
MIT License
52 stars 64 forks source link

Action with nullable parameter #215

Open bpaolo71 opened 2 years ago

bpaolo71 commented 2 years ago

I'm a bit confused about why action has a nullable parameter. I was trying to use SupplierInvoiceConnector.Cancel that has long? as parameter. But if I use null as parameter i get back 'Request failed: Värdet måste vara numeriskt (cancel)' so i suppose that the parameter should be a long istead ! Or I am wrong ?

richardrandak commented 2 years ago

The reason is the same as why Get methods have null-able parameter. Honestly, I think I made it nullable just to match the type with the primary ID of the entity, which is nullable for other reason.

If it was "long", you would have to always add .Value when used. e.g. connector.Cancel(invoice.GivenNumber.Value);

Is there any downside of this, apart from that a user may try "null" and realize it won't work? :) Maybe it make sense to think of converting all primary ids to not-null, even in entities.