public GatewayAutomation(HttpClient httpClient, LogicTokenProviderFactory tokenProviderFactory, GatewayOptions options)
        {
            if (httpClient == null)
            {
                throw new ArgumentNullException(nameof(httpClient));
            }

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

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

            if (!options.ProviderId.HasValue || options.ProviderId.Value == Guid.Empty)
            {
                using var client = new GatewayClientFactory(tokenProviderFactory, httpClient, options).CreateClient();
                var provider = client.GetGatewayProviders(options.SubscriptionId.ToString())?.SingleOrDefault(x => x.SubscriptionId == options.SubscriptionId);
                if (provider == null)
                {
                    throw new ArgumentException("providerId not found");
                }

                options.ProviderId = provider.Id;
            }

            this.validatePublishing = new ValidatePublishing(httpClient, tokenProviderFactory, options);
            this.publish            = new Publish(httpClient, tokenProviderFactory, options);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Publish"/> class.
        /// </summary>
        /// <param name="httpClient">The HTTP client to use. The caller is expected to manage this resource and it will not be disposed.</param>
        /// <param name="tokenProviderFactory">The Logic access token provider factory.</param>
        /// <param name="options">The required configuration options.</param>
        public Publish(HttpClient httpClient, LogicTokenProviderFactory tokenProviderFactory, GatewayOptions options)
        {
            this.options = options ?? throw new ArgumentNullException(nameof(options));
            if (tokenProviderFactory == null)
            {
                throw new ArgumentNullException(nameof(tokenProviderFactory));
            }

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

            this.gatewayClientFactory = new GatewayClientFactory(tokenProviderFactory, httpClient, options);
            this.validatePublishing   = new ValidatePublishing(httpClient, tokenProviderFactory, options);

            this.publishResults = new List <GatewayAutomationResult>();
        }
        public GatewayAutomation(HttpClient httpClient, LogicTokenProviderFactory tokenProviderFactory, GatewayOptions options)
        {
            if (httpClient == null)
            {
                throw new ArgumentNullException(nameof(httpClient));
            }

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

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

            this.validatePublishing = new ValidatePublishing(httpClient, tokenProviderFactory, options);
            this.publish            = new Publish(httpClient, tokenProviderFactory, options);
        }