示例#1
0
        /// <summary>
        /// Updates Data Distributor provider configuration.
        /// </summary>
        /// <param name="cprClient">Cpr client.</param>
        /// <param name="configurationId">Id of the configuration to update.</param>
        /// <param name="name">Name of the configuration.</param>
        /// <param name="environment">Environment to use.</param>
        /// <param name="certificate">Stream with certificate.</param>
        /// <param name="password">Password to the certificate.</param>
        /// <returns>Updated configuration.</returns>
        public static async Task <CprProviderConfiguration> UpdateDataDistributorConfiguration(
            this CprClient cprClient,
            Guid configurationId,
            string name,
            ProviderEnvironment environment,
            Stream certificate,
            string password = null)
        {
            if (cprClient == null)
            {
                throw new ArgumentException("Client cannot be null", nameof(cprClient));
            }

            var client = cprClient.CreateClient();

            using var response = await client.UpdateDataDistributorConfigurationWithHttpMessagesAsync(
                      cprClient.GetOptions ().SubscriptionId,
                      configurationId,
                      name,
                      environment.ToString(),
                      certificate,
                      password).ConfigureAwait(false);

            switch (response.Response.StatusCode)
            {
            case System.Net.HttpStatusCode.OK:
                return(response.Body);

            case System.Net.HttpStatusCode.NotFound:
                throw new CprConfigurationException("Configuration not found");

            default:
                throw new CprConfigurationException(response.Response?.ReasonPhrase ?? "Provider configuration update failed");
            }
        }
示例#2
0
        /// <summary>
        /// Updates experian provider configuration.
        /// </summary>
        /// <param name="cprClient">Cpr client.</param>
        /// <param name="configurationId">Id of the configuration.</param>
        /// <param name="name">Name of the configuration.</param>
        /// <param name="environment">Experian environment.</param>
        /// <param name="callbackUrl">Url to endpoint to send events.</param>
        /// <returns>Updated configuration.</returns>
        public static async Task <ExperianProviderConfigurationResponse> UpdateExperianConfiguration(
            this CprClient cprClient,
            Guid configurationId,
            string name,
            ProviderEnvironment environment,
            Uri callbackUrl = default)
        {
            if (cprClient == null)
            {
                throw new ArgumentException("Client cannot be null", nameof(cprClient));
            }

            var client = cprClient.CreateClient();

            using var response = await client.UpdateExperianConfigurationWithHttpMessagesAsync(
                      cprClient.GetOptions ().SubscriptionId,
                      configurationId,
                      new ExperianConfigurationRequest (
                          name,
                          environment.ToString(),
                          callbackUrl?.ToString())).ConfigureAwait(false);

            switch (response.Response.StatusCode)
            {
            case System.Net.HttpStatusCode.OK:
                return(response.Body);

            case System.Net.HttpStatusCode.NotFound:
                throw new CprConfigurationException("Configuration not found");

            default:
                throw new CprConfigurationException(response.Response?.ReasonPhrase ?? "Provider configuration update failed");
            }
        }
        /// <summary>
        /// Updates fake provider configuration.
        /// </summary>
        /// <param name="cprClient">Cpr client.</param>
        /// <param name="configurationId">Id of the configuration.</param>
        /// <param name="name">Name of the configuration.</param>
        /// <returns>Updated configuration.</returns>
        public static async Task <FakeProviderConfigurationModel> UpdateFakeProviderConfiguration(
            this CprClient cprClient,
            Guid configurationId,
            string name)
        {
            if (cprClient == null)
            {
                throw new ArgumentException("Client cannot be null", nameof(cprClient));
            }

            var client = cprClient.CreateClient();

            using var response = await client.UpdateFakeProviderConfigurationWithHttpMessagesAsync(
                      cprClient.GetOptions ().SubscriptionId,
                      configurationId,
                      name).ConfigureAwait(false);

            switch (response.Response.StatusCode)
            {
            case System.Net.HttpStatusCode.OK:
                return(response.Body);

            case System.Net.HttpStatusCode.NotFound:
                throw new CprConfigurationException("Configuration not found");

            default:
                throw new CprConfigurationException(response.Response?.ReasonPhrase ?? "Provider configuration update failed");
            }
        }
        /// <summary>
        /// Create Service Platform provider configuration.
        /// </summary>
        /// <param name="cprClient">Cpr client.</param>
        /// <param name="name">Name of the configuration.</param>
        /// <param name="environment">Environment to use.</param>
        /// <param name="certificate">Stream with certificate.</param>
        /// <param name="certificatePassword">Password to the certificate.</param>
        /// <param name="serviceAgreementUuid">Id of the service agreement.</param>
        /// <param name="userSystemUuid">Id of the user system.</param>
        /// <param name="userUuid">Id of the user.</param>
        /// <returns>Created configuration.</returns>
        public static async Task <ServicePlatformProviderConfiguration> CreateServicePlatformConfiguration(
            this CprClient cprClient,
            string name,
            ProviderEnvironment environment,
            Stream certificate,
            string certificatePassword  = default,
            string serviceAgreementUuid = default,
            string userSystemUuid       = default,
            string userUuid             = default)
        {
            if (cprClient == null)
            {
                throw new ArgumentException("Client cannot be null", nameof(cprClient));
            }

            var client = cprClient.CreateClient();

            using var response = await client.CreateServicePlatformConfigurationWithHttpMessagesAsync(
                      cprClient.GetOptions ().SubscriptionId,
                      name,
                      environment.ToString(),
                      certificate,
                      certificatePassword,
                      serviceAgreementUuid,
                      userSystemUuid,
                      userUuid).ConfigureAwait(false);

            switch (response.Response.StatusCode)
            {
            case System.Net.HttpStatusCode.OK:
                return(response.Body);

            default:
                throw new CprConfigurationException(response.Response?.ReasonPhrase ?? "Provider configuration creation failed");
            }
        }