protected async Task ReauthorizeAsync()
        {
            var newToken = await this.IntegrationAdminTokenRepository.GetTokenAsync(MagentoLogin.Create(this.ApiUser), MagentoPass.Create(this.ApiKey)).ConfigureAwait(false);

            var magentoUrl = MagentoUrl.Create(this.Store);

            this.ProductRepository          = new ProductRepository(newToken, magentoUrl);
            this.CatalogStockItemRepository = new CatalogStockItemRepository(newToken, magentoUrl);
            this.SalesOrderRepository       = new SalesOrderRepositoryV1(newToken, magentoUrl);
        }
Beispiel #2
0
 public WebRequestBuilder Url(MagentoUrl url)
 {
     this.WebRequest.Url = url;
     return(this);
 }
        public async Task <bool> InitAsync(bool supressExceptions = false)
        {
            try
            {
                if (this.IntegrationAdminTokenRepository != null)
                {
                    return(true);
                }

                this.IntegrationAdminTokenRepository = new IntegrationAdminTokenRepository(MagentoUrl.Create(this.Store));
                await this.ReauthorizeAsync().ConfigureAwait(false);

                return(true);
            }
            catch (Exception)
            {
                if (supressExceptions)
                {
                    return(false);
                }
                throw;
            }
        }