softwerkab / fortnox-csharp-api-sdk

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

set Leveranssätt #226

Closed MagnusModig closed 2 years ago

MagnusModig commented 2 years ago

Hi

Just wanted to check... if I want to set an orders "Leveranssätt" found under "Leveransuppgifter" in Fortnox, is it property "WayOfDelivery" I then set? Like this for example...

        var retrievedOrder = orderConnector.Get(1);
        retrievedOrder.WayOfDelivery = "Schenker";
        orderConnector.Update(retrievedOrder);

What if I set something that doesnt exsits in Fortnox, will that just trigger an error or will it insert the new value. Can I get a list of the current "Leveransätt" found in Fortnox?

richardrandak commented 2 years ago

1) You can get the "Leveransätt" by a WayOfDeliveryConnector.

var connector = Client.WayOfDeliveryConnector;
var search = new WayOfDeliverySearch() { ... }
var collection = await connector.FindAsync(search);
var entities = collection.Entities;

2) I believe, the retrievedOrder.WayOfDelivery should be a Codeof an existing WayOfDelivery, so most likely, using an unexistent will throw an error.

MagnusModig commented 2 years ago

Great, thanks!

MagnusModig commented 2 years ago

Hi, I tried to get the current ways of delivery with this filter.. var search = new WayOfDeliverySearch() {Limit = 50, FilterBy = new Filter.WayOfDelivery()};

I must be doing it wrong beacuse I dont get any results at all. Do I need to tweak the filter?

richardrandak commented 2 years ago

try just await connector.FindAsync(null) .. should give you the results, if there are any

MagnusModig commented 2 years ago

Not sure whats going on but when changing to that I get this error "Request failed: Har inte behörighet för scope."

richardrandak commented 2 years ago

If you have access to the app in fortnox developer portal, check if has the Settings permission/scope enabled

MagnusModig commented 2 years ago

Thats it, thanks!