Class AnalyticsApi
- Namespace
- Cloudflare.NET.Analytics
- Assembly
- Cloudflare.NET.Analytics.dll
Implements a generic client for the Cloudflare Analytics GraphQL endpoint.
public class AnalyticsApi : IAnalyticsApi
- Inheritance
-
AnalyticsApi
- Implements
- Inherited Members
Remarks
Initializes a new instance of the AnalyticsApi class.
Constructors
AnalyticsApi(IGraphQLClient, ILoggerFactory)
Implements a generic client for the Cloudflare Analytics GraphQL endpoint.
public AnalyticsApi(IGraphQLClient graphQlClient, ILoggerFactory loggerFactory)
Parameters
graphQlClientIGraphQLClientThe GraphQL client for making requests.
loggerFactoryILoggerFactoryFactory used to create a type-scoped logger.
Remarks
Initializes a new instance of the AnalyticsApi class.
Methods
SendQueryAsync<TResponse>(GraphQLRequest, CancellationToken)
Sends a GraphQL query to the Cloudflare API.
public Task<TResponse> SendQueryAsync<TResponse>(GraphQLRequest request, CancellationToken cancellationToken = default)
Parameters
requestGraphQLRequestThe GraphQL request object, containing the query and variables.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<TResponse>
A task that represents the asynchronous operation. The task result contains the deserialized data from the API response's "data" field.
Type Parameters
TResponseThe type to deserialize the GraphQL response data into.
Exceptions
- InvalidOperationException
Thrown if the GraphQL API returns errors or if the response data is null.