XeroAPI / xerogolang

Golang SDK for the Xero API
MIT License
24 stars 29 forks source link

Why is this session specific api? #16

Closed vitr closed 6 years ago

vitr commented 6 years ago

I totally understand that this is just an alpha version, but let me share my issue with the general approach you take here. I'm using private api, I don't need sessions, my tokens are valid infinitely and I couldn't find an easy way to use this library for my needs. See this php example https://github.com/calcinai/xero-php/blob/master/examples/private.php hardly 15 lines of code, too easy. Why are you coupling golang api with sessions so passionately? Just look at bigger picture, we don't need sessions to run api (hello tokens)! You can add sessions on top of basic api implementation, but it should be optional. When I see something like this

//FindContacts will get all Contacts. These Contact will not have details like default accounts.
//If you need details then then add a 'page' querystringParameter and get 100 Contacts at a time
//additional querystringParameters such as where, page, order can be added as a map
func FindContacts(provider *xerogolang.Provider, session goth.Session, querystringParameters map[string]string) (*Contacts, error) {
    return FindContactsModifiedSince(provider, session, dayZero, querystringParameters)
}

I don't understand, why is there provider or session? you're the only provider (the Xero) and session is just a storage for tokens. I really appreciate the work you've done, but please, consider simplifying the golang api and making it more generic and logical. Thank you.

TheRegan commented 6 years ago

Thanks for the comments.

There are always multiple ways to approach a problem and it's good to hear about what you want from this SDK.

We focused on getting reliable, working, examples up for this project and have not optimized it for multiple use cases. It is skewed towards public and partner apps rather than private apps as we see more use from those types.

A good way forward for you would be to get in touch with our Developer Evangelists and talk about why you're using private apps rather than a partner app and see how we can help there. A Xero organisation can have a maximum of 2 private apps connected to it at any time and they require extra setup that isn't required with a Partner app so it's well worth exploring.