Beispiel #1
0
        public MagentoServiceLowLevelSoap_v_2_0_2_0_ce(string apiUser, string apiKey, string baseMagentoUrl, string store)
        {
            this.ApiUser        = apiUser;
            this.ApiKey         = apiKey;
            this.Store          = store;
            this.BaseMagentoUrl = baseMagentoUrl;

            this._customBinding = CustomBinding(baseMagentoUrl, MessageVersion.Soap11);
            this.PullSessionId  = async() =>
            {
                var privateClient = this.CreateMagentoServiceAdminClient(this.BaseMagentoUrl);
                var integrationAdminTokenServiceV1CreateAdminAccessTokenRequest = new IntegrationAdminTokenServiceV1CreateAdminAccessTokenRequest()
                {
                    username = this.ApiUser, password = this.ApiKey
                };
                var loginResponse = await privateClient.integrationAdminTokenServiceV1CreateAdminAccessTokenAsync(integrationAdminTokenServiceV1CreateAdminAccessTokenRequest).ConfigureAwait(false);

                this._sessionIdCreatedAt = DateTime.UtcNow;
                this._sessionId          = loginResponse.integrationAdminTokenServiceV1CreateAdminAccessTokenResponse.result;

                return(Tuple.Create(this._sessionId, DateTime.UtcNow));
            };

            this.getSessionIdSemaphore = new SemaphoreSlim(1, 1);
        }
Beispiel #2
0
        public MagentoServiceLowLevelSoap_v_2_0_2_0_ce(string apiUser, string apiKey, string baseMagentoUrl, bool logRawMessages, string store)
        {
            this.ApiUser        = apiUser;
            this.ApiKey         = apiKey;
            this.Store          = store;
            this.BaseMagentoUrl = baseMagentoUrl;
            this.LogRawMessages = logRawMessages;

            this._clientFactory = new MagentoServiceSoapClientFactory(baseMagentoUrl, logRawMessages, this.ApiKey);
            this.PullSessionId  = async() =>
            {
                if (!string.IsNullOrWhiteSpace(this.ApiUser) && string.Compare(this.ApiUser, "bearer", StringComparison.InvariantCultureIgnoreCase) != 0)
                {
                    var privateClient = this._clientFactory.CreateMagentoServiceAdminClient();
                    var integrationAdminTokenServiceV1CreateAdminAccessTokenRequest = new IntegrationAdminTokenServiceV1CreateAdminAccessTokenRequest()
                    {
                        username = this.ApiUser, password = this.ApiKey
                    };
                    var loginResponse = await privateClient.integrationAdminTokenServiceV1CreateAdminAccessTokenAsync(integrationAdminTokenServiceV1CreateAdminAccessTokenRequest).ConfigureAwait(false);

                    this._sessionIdCreatedAt = DateTime.UtcNow;
                    this._sessionId          = loginResponse.integrationAdminTokenServiceV1CreateAdminAccessTokenResponse.result;
                }
                else
                {
                    this._sessionId = this.ApiKey;
                }
                if (this._clientFactory != null)
                {
                    this._clientFactory.Session = this._sessionId;
                }
                return(Tuple.Create(this._sessionId, DateTime.UtcNow));
            };

            this.getSessionIdSemaphore = new SemaphoreSlim(1, 1);
        }