Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customer References #250

Open
martenw opened this issue Oct 12, 2022 · 7 comments
Open

Customer References #250

martenw opened this issue Oct 12, 2022 · 7 comments

Comments

@martenw
Copy link

martenw commented Oct 12, 2022

Are Customer References not implemented?

https://apps.fortnox.se/apidocs#tag/CustomerReferencesResource

The requirement I want to implement is to search and find customers based on the list of references on a customer (wildcard search if possible but exact match could possibly also work). Could this otherwise perhaps be implemented somehow with the customer search?

image

@richardrandak
Copy link
Collaborator

richardrandak commented Oct 12, 2022

Hi!
It seems to be new and it is not implemented. I have briefly looked at it, but this endpoint seems buggy and inconsistent, making it pain to implement :-/
I could make some prototype version so you can try it out.
I am not really sure what the customer reference actually represent.. can you tell me when / where is it used?

@martenw
Copy link
Author

martenw commented Oct 14, 2022

Hi,

Ok, in what way is it buggy? Do you think it can still be used? I can definitely try out a prototype version.

You can see the list of references in the image posted above, predefined references are a list of contacts (persons) on a customer (company), typically you have the same couple of people that you work with at a customer, so when creating an invoice or order for a customer you can select from a list of predefined names instead of writing as free text every time.

And the requirement I have is that i have name/email of a person that I need to find the customer for, so basically search all references of all customers to find the right one (if that is possible).

@richardrandak
Copy link
Collaborator

richardrandak commented Oct 15, 2022

Well, not buggy, but confusing.. anyway, I have implemented the connector which tries to hide these inconsistencies.
You can try it out with preview version

As usual, you get the connector by calling var connector = FortnoxClient.CustomerReferenceConnector;

For your requirement, you can call FindAsync to get list of the references.. then you have to go through them yourself to filter according your requirement. The limit/offset/page seems to work, but paging metadata are not returned by the server. From my investigation, only 60 entries are allowed, after that, creating a new one fails.

@martenw
Copy link
Author

martenw commented Oct 15, 2022

Done some tests now and everything seems to work great, some notes (related to the api, not this implementation):

  • Max number of references per customer is 5 (same as possible to set in Fortnox UI)
  • Found in testing that page size ix max 500 when calling CustomerReferenceConnector.FindAsync, I tried with -1 that can be used on other entities to get all but that throws System.NotImplementedException: Unlimited page is not supported due to missing paging metadata.

There is no info about total number of items available in the response of the first page so I had to loop pages until no more values are returned to get all references, but that will work.

Thank you for a really quick implementation of this!!

@richardrandak
Copy link
Collaborator

Aha, so the error with creating the references was not about the total limit of 60 but due to limit of 5 per customer. That make sense :) I did a wrong assumption. Thank you for clearing it out for me.

As you said, unfortunately, the total number of items is not available, so the unlimited page (Limit == -1) can't be implemented. That's why I make it to throw the exception. In theory, it could implemented it as you say, with looping until there are no results). I will consider it, so that it will be (for the SDK consumer) appear consistent with other endpoints.

If you have energy and time, you can ask the Fortnox support regarding the pagination metadata for this endpoint, whether that's something they plan to implement on the server-side :)

@martenw
Copy link
Author

martenw commented Oct 15, 2022

Will do, will also check why there is a limit of only 5 references and if it can be increased.

@martenw
Copy link
Author

martenw commented Oct 20, 2022

Got a reply now from Fortnox:

There are plans for both parts you mention, but I don't have a release date right now unfortunately.

So, we will probably get both additional references and better endpoint in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants