Agility .NET 7 Updates

With .NET 7 we've introduced new typed endpoints for the following methods. The usage is the same as before, so any developers using the dotnet API will be familiar. The only difference is that now you can pass in a type to these generic methods that we will try to serialize for you. Of course if you so choose, you will still be able to use the older methods and handle deserialization yourselves.

Typed Endpoints

public async Task<ContentItemResponse<T>> GetTypedContentItem<T>(GetItemParameters getItemParameters)

           var getParams = new GetItemParameters
            {
                ContentId = 111,
                Locale ="en-us"
            };

            var featuredPostModel = await _fetchApiService.GetTypedContentItem<FeaturedPost_Model>(getParams);

public async Task<ContentListResponse<T>> GetTypedContentList<T>(GetListParameters getListParameters)

  var getParams = new GetListParameters
            {
                ReferenceName = "posts",
                Locale = "en-us"
            };
            var posts = await _fetchApiService.GetTypedContentList<Post>(getParams);

public async Task<PageResponse> GetTypedPage(GetPageParameters getPageParameters)

 var getPageExpandedParameters = new GetPageParameters()
            {
                PageId = 111,
                Locale = "en-us",
                ExpandAllContentLinks = true,
                ContentLinkDepth = 2
            };

            var page = await _fetchApiService.GetTypedPage(getPageExpandedParameters);

public async Task<List<SitemapPage>> GetTypedSitemapFlat(GetSitemapParameters getSitemapParameters)

  var getSitemapParameters = new GetSitemapParameters()
            {
                ChannelName = _appSettings.ChannelName,
                Locale = "en-us"
            };

            var sitemap = await _fetchApiService.GetTypedSitemapFlat(getSitemapParameters);

public async Task<List<SitemapPage>> GetTypedSitemapNested(GetSitemapParameters getSitemapParameters)

   var getSitemapParameters = new GetSitemapParameters()
            {
                ChannelName = "channel",
                Locale = "en-us"
            };

            var sitemap = await _fetchApiService.GetTypedSitemapNested(getSitemapParameters);

GraphQL

In addition we've added a graphQL method as well:

Pass in the graphQL query, the locale and the object namepublic async Task<List<ContentItemResponse<T>>> GetContentByGraphQL<T>(GraphQLRequest query, string locale, string objName)

            var query = new GraphQLRequest
            {
                Query = @"
                {
                    posts(take: 10, skip: 0)
                    {
                        contentID
                        fields {
                            title
                            slug
                            date
                            category {
                               fields {
                                title
                               }
                            }
                            image {
                                label
                                url
                                target
                                pixelHeight
                                pixelWidth
                                fileSize
                                height
                                width
                            }
                            content
                            authorID
                            categoryID
                        }
                    }
                }"
            };

            var rawData = await _fetchApiService.GetContentByGraphQL<PostGQL>(moduleModel.Locale, "posts");

            var posts = new List<PostGQL>();

            foreach (var post in rawData)
            {
                // just return the Fields
                posts.Add(post.Fields);
            }