IApi api = new ApiFactory();
var artist = await api.Create<Artist>()
.WithArtistId(artistId)
.Please();
var artistTopTracks = await api.Create<ArtistTopTracks>()
.WithArtistId(artistId)
.Please();
The advantage is that api is an instance of type IApi so it is injectable, and you can make multiple independent request of the same or varying types off it using IFluentApi<T> request = api.Create<T>() multiple times. If you follow this pattern, you should have no more concurrency issues.
A Customised usage is for the api user to make their own implementation of IApi supplying creds etc. This is not hard, See here for an example
The static generic Api class with a Create property is retained for compatibility, tests, very simple cases and for consumers who like global singletons :/ but it can now be forwarded to a custom IApiExample as above. I removed the static CreateWithCreds method as the forwarding is the extension point - we don't want to encourage use of this class in more complex cases.
Addressing api creation issues as per https://github.com/7digital/SevenDigital.Api.Wrapper/issues/169. There is an
IApi
interface and a default implementation.The example usage program shows the simple case usage,
ie.
The advantage is that api is an instance of type
IApi
so it is injectable, and you can make multiple independent request of the same or varying types off it usingIFluentApi<T> request = api.Create<T>()
multiple times. If you follow this pattern, you should have no more concurrency issues.A Customised usage is for the api user to make their own implementation of
IApi
supplying creds etc. This is not hard, See here for an exampleThe static generic
Api
class with a Create property is retained for compatibility, tests, very simple cases and for consumers who like global singletons :/ but it can now be forwarded to a customIApi
Example as above. I removed the staticCreateWithCreds
method as the forwarding is the extension point - we don't want to encourage use of this class in more complex cases.