/// <inheritdoc />
        public async Task <ApiResponse <NotificationTemplate> > GenerateNotificationTemplate(
            string tenantId,
            CreateNotificationsRequest createNotificationsRequest,
            CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrEmpty(tenantId))
            {
                throw new ArgumentNullException(nameof(tenantId));
            }

            if (createNotificationsRequest == null)
            {
                throw new ArgumentNullException(nameof(createNotificationsRequest));
            }

            Uri requestUri = this.ConstructUri($"{tenantId}/marain/usernotifications/templates/generate");

            HttpRequestMessage request = this.BuildRequest(HttpMethod.Put, requestUri, createNotificationsRequest);

            HttpResponseMessage response = await this.SendRequestAndThrowOnFailure(request, cancellationToken).ConfigureAwait(false);

            using Stream contentStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);

            NotificationTemplate result = await JsonSerializer.DeserializeAsync <NotificationTemplate>(contentStream, this.SerializerOptions).ConfigureAwait(false);

            return(new ApiResponse <NotificationTemplate>(
                       response.StatusCode,
                       result));
        }
        /// <inheritdoc />
        public Task <ApiResponse> CreateNotificationsAsync(
            string tenantId,
            CreateNotificationsRequest body,
            CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrEmpty(tenantId))
            {
                throw new ArgumentNullException(nameof(tenantId));
            }

            var requestUri = new Uri($"/{tenantId}/marain/usernotifications", UriKind.Relative);

            return(this.CallLongRunningOperationEndpointAsync(requestUri, HttpMethod.Put, body, cancellationToken));
        }
        public Task CreateSingleNotificationInitialResponse()
        {
            var properties = new Dictionary <string, object>
            {
                { "thing1", "value 1" },
                { "thing2", 2 },
            };

            var body = new CreateNotificationsRequest
            {
                NotificationType = "marain.notifications.test.v1",
                CorrelationIds   = new[] { "cid1", "cid2" },
                Properties       = properties,
                Timestamp        = DateTime.UtcNow,
                UserIds          = new[] { Guid.NewGuid().ToString() },
            };

            return(this.ManagementClient.CreateNotificationsAsync(this.BenchmarkClientTenantId, body));
        }
        public async Task WhenIUseTheClientToSendAManagementAPIRequestToCreateANewNotification(Table table)
        {
            IJsonSerializerSettingsProvider jsonSerializerSettingsProvider = this.serviceProvider.GetRequiredService <IJsonSerializerSettingsProvider>();
            CreateNotificationsRequest      data = BuildCreateNotificationsRequestFrom(table.Rows[0], jsonSerializerSettingsProvider.Instance);

            string transientTenantId = this.featureContext.GetTransientTenantId();
            IUserNotificationsManagementClient client = this.serviceProvider.GetRequiredService <IUserNotificationsManagementClient>();

            try
            {
                ApiResponse result = await client.CreateNotificationsAsync(transientTenantId, data, CancellationToken.None).ConfigureAwait(false);

                this.StoreApiResponseDetails(result.StatusCode, result.Headers);
            }
            catch (Exception ex)
            {
                ExceptionSteps.StoreLastExceptionInScenarioContext(ex, this.scenarioContext);
            }
        }