Now, how does that intermediate format look? Do we use plain objects, auth instances or something else? Something like basic auth can be used directly in the user stage, but other methods can't be used without the authentication step to retrieve a token.
The downside of this approach is that if the data is being stored in a database they may not want to store an identical type with every entry. Also, strings are pretty meaningless and easy to get wrong. So the alternative may be the instance example:
github.options.user = new GithubApi.OAuth2('abc', 'def');
github.options.user = new GithubApi.BasicAuth('abc', 'def');
Somewhat more meaningful. I'll do a bit of tweaking this I imagine to get the most semantic flow. Maybe I'll look at what other libraries follow too and see if there are any other approaches. Personally, the instance approach seems the least error prone and easiest to encapsulate.
How do we properly support the number of authentication and user methods. I would suppose that API instances can belong to a single user:
Also, every API request could override this:
Now, how does that intermediate format look? Do we use plain objects, auth instances or something else? Something like basic auth can be used directly in the user stage, but other methods can't be used without the authentication step to retrieve a token.
Object example:
The downside of this approach is that if the data is being stored in a database they may not want to store an identical type with every entry. Also, strings are pretty meaningless and easy to get wrong. So the alternative may be the instance example:
Somewhat more meaningful. I'll do a bit of tweaking this I imagine to get the most semantic flow. Maybe I'll look at what other libraries follow too and see if there are any other approaches. Personally, the instance approach seems the least error prone and easiest to encapsulate.