Hello,
I just released the beta of the .NET Client Library / SDK.
Streamlined developer experience
The goal was to streamline the developer experience. I have removed a lot of old code and made the handling of the app names more consistent. Because a lot of the code was auto generated you had to define the app name in the options and then again in the actual requests. For example:
var clientManager =
new SquidexClientManager(
new SquidexOptions
{
AppName = "...",
ClientId = "...",
ClientSecret = "...",
Url = "https://cloud.squidex.io"
});
var assetsClient = clientManager.CreateAssetsClient();
var assets = await assetsClient .GetAssetsAsync("my-app");
but for contents it was not needed, because the client was coded manually:
var client = clientManager.CreateContentsClient<BlogPost, BlogPostData>("posts");
var content = await client.CreateAsync(...);
I have adjusted the templates of the code generator and the app name is now set automatically.
In addition to that, the client manager has been renamed client and it storing references to the actual clients now. So you don’t have to do that.
This means that the example above looks like this now:
var client =
new SquidexClient(
new SquidexOptions
{
AppName = "...",
ClientId = "...",
ClientSecret = "...",
Url = "https://cloud.squidex.io"
});
// It is a property now.
var assets = await client.Assets.GetAssetsAsync();
Multiple Clients
If you deal with multiple apps you have to work with multiple clients now.
BUT, you can also register multiple clients in the service locator and use a new interface to provide the correct client:
var provider =
new ServiceCollection()
.AddSquidexClient(null)
.Configure<SquidexServiceOptions>(options =>
{
options.AppName = "app";
options.ClientId = "id";
options.ClientSecret = "secret";
options.Url = "https://custom1.squidex.io";
})
.Configure<SquidexServiceOptions>("named", options =>
{
options.AppName = "app";
options.ClientId = "id";
options.ClientSecret = "secret";
options.Url = "https://custom2.squidex.io";
})
.BuildServiceProvider()
.GetRequiredService<ISquidexClientProvider>();
var client1 = provider.Get();
var client2 = provider.Get("named");
The normal client (without the name) is registered as well, so you can resolve ISquidexClient or ISquidexClientProvider.
It is still in beta to get your feedback.
More Clients
I am also working together with the guys from fern (https://www.buildwithfern.com/) to get SDKs out for more programming language. I hope we can release Node (Typescript) and Java versions soon and and have a setup for more programming languages.