示例#1
0
        private async Task CreateApaleoIntegrationAsync(ApaleoIntegrationTarget integrationTarget)
        {
            var integrationApi = _apaleoClientsFactory.GetIntegrationApi();

            var integrationUrl = _apaleoIntegrationTargetsUrlDictionary[integrationTarget].ToString();

            var integrationIconUrl =
                _integrationConfig.Value.IntegrationIconUri.Match(
                    v => v.ToString(),
                    () => string.Empty);

            var createUiIntegrationModel = new CreateUiIntegrationModel
            {
                Code       = _integrationConfig.Value.DefaultIntegrationCode,
                Label      = _integrationConfig.Value.IntegrationLabel,
                IconSource = integrationIconUrl,
                SourceType = AppConstants.IntegrationSourceType,
                SourceUrl  = integrationUrl
            };

            using (var responseResult = await integrationApi.IntegrationUiIntegrationsByTargetPostWithHttpMessagesAsync(integrationTarget.ToString("G"), createUiIntegrationModel))
            {
                if (!responseResult.Response.IsSuccessStatusCode && !await IntegrationExistsAsync(integrationTarget))
                {
                    var content = await responseResult.Response.Content.ReadAsStringAsync();

                    throw new BusinessValidationException(
                              $"Failed to create integration with {nameof(integrationApi.IntegrationUiIntegrationsByTargetPostWithHttpMessagesAsync)} with status code: {responseResult.Response.StatusCode} and content: {content}");
                }
            }
        }
示例#2
0
        private async Task <bool> IntegrationExistsAsync(ApaleoIntegrationTarget target)
        {
            var nonExistingIntegrations = await GetMissingIntegrationTargetsAsync();

            return(!nonExistingIntegrations.Contains(target));
        }