public async Task <OpenApiResult> CreateNotificationsAsync(
            IOpenApiContext context,
            CreateNotificationsRequest body)
        {
            // We can guarantee tenant Id is available because it's part of the Uri.
            ITenant tenant = await this.marainServicesTenancy.GetRequestingTenantAsync(context.CurrentTenantId !).ConfigureAwait(false);

            string delegatedTenantId = await this.marainServicesTenancy.GetDelegatedTenantIdForRequestingTenantAsync(tenant.Id).ConfigureAwait(false);

            var operationId = Guid.NewGuid();
            CreateOperationHeaders response = await this.operationsControlClient.CreateOperationAsync(
                delegatedTenantId,
                operationId).ConfigureAwait(false);

            // Create a new CreateNotificationForDeliveryChannelsRequest Object which supports the communication types and delivery channels
            var createNotificationForDeliveryChannelsRequestObject = new CreateNotificationForDeliveryChannelsRequest(
                body.NotificationType,
                body.UserIds,
                body.Timestamp,
                body.Properties,
                body.CorrelationIds);

            IDurableOrchestrationClient orchestrationClient = context.AsDurableFunctionsOpenApiContext().OrchestrationClient
                                                              ?? throw new OpenApiServiceMismatchException($"Operation {CreateNotificationsOperationId} has been invoked, but no Durable Orchestration Client is available on the OpenApi context.");

            await orchestrationClient.StartNewAsync(
                nameof(CreateAndDispatchNotificationsOrchestration),
                new TenantedFunctionData <CreateNotificationForDeliveryChannelsRequest>(context.CurrentTenantId !, createNotificationForDeliveryChannelsRequestObject, operationId)).ConfigureAwait(false);

            return(this.AcceptedResult(response.Location));
        }
        /// <inheritdoc />
        public Task <ApiResponse> CreateNotificationForDeliveryChannelsAsync(
            string tenantId,
            CreateNotificationForDeliveryChannelsRequest body,
            CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrEmpty(tenantId))
            {
                throw new ArgumentNullException(nameof(tenantId));
            }

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

            return(this.CallLongRunningOperationEndpointAsync(requestUri, HttpMethod.Put, body, cancellationToken));
        }
        public async Task WhenIUseTheClientToSendAManagementAPIRequestToCreateANewNotificationViaThirdPartyDeliveryChannels(Table table)
        {
            IJsonSerializerSettingsProvider jsonSerializerSettingsProvider = this.serviceProvider.GetRequiredService <IJsonSerializerSettingsProvider>();
            CreateNotificationForDeliveryChannelsRequest data = BuildCreateNotificationForDeliveryChannelsRequestFrom(table.Rows[0], jsonSerializerSettingsProvider.Instance);

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

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

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