Also available on nuget.org.
Our recommendation is to have a look to the other samples to see how it works, but here is a short introduction.
The client library uses the following namespace: Squidex.ClientLibrary
For each schema you have to create two classes.
- The data object:
public sealed class BlogPostData
{
// Squidex delivers hash maps for each field, but the
// InvariantConverter helps to simplify the model.
[JsonConverter(typeof(InvariantConverter))]
public string Title { get; set; }
[JsonConverter(typeof(InvariantConverter))]
public string Slug { get; set; }
// For localizable fields you can use dictionaries.
public Dictionary<string, string> Text { get; set; }
}
- The entity object
public sealed class BlogPost : Content<BlogPostData>
{
}
var clientManager =
new SquidexClientManager(
new SquidexOptions
{
AppName = "...",
ClientId = "...",
ClientSecret = "...",
Url = "https://cloud.squidex.io"
});
var client = clientManager.CreateContentsClient<BlogPost, BlogPostData>("posts");
// Read posts pages
var posts = await client.GetAsync(page * pageSize, pageSize);
// Read post by id.
var post = client.GetAsync(id);
// Read posts by slug.
var posts = await client.GetAsync(filter: $"data/slug/iv eq '{slug}'");