-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentfulClientBuilder.cs
More file actions
35 lines (31 loc) · 922 Bytes
/
Copy pathContentfulClientBuilder.cs
File metadata and controls
35 lines (31 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Net.Http;
using Contentful.Core;
using Contentful.Core.Configuration;
using Contentful.Implementation.Models;
namespace Contentful.Example.Implementation;
internal interface IContentfulClientBuilder
{
IContentfulClient BuildClient();
}
internal class ContentfulClientBuilder
(
IHttpClientFactory factory,
ContentfulSettings settings
) : IContentfulClientBuilder
{
public IContentfulClient BuildClient()
{
var options = new ContentfulOptions
{
DeliveryApiKey = settings.ApiKey,
SpaceId = settings.SpaceId,
Environment = settings.Environment,
UsePreviewApi = false,
ResolveEntriesSelectively = true,
};
return new ContentfulClient(factory.CreateClient(nameof(ContentfulClientBuilder)), options)
{
ContentTypeResolver = new GeneratedContentTypeResolver()
};
}
}