예제 #1
0
        public void GenerateAuthHeaderValue()
        {
            var authenticator = new Authenticator(base.Config.Credentials);
            var requestBody   = new GetModifiedProductsRequest(base.Config.Credentials, DateTime.UtcNow.AddMonths(-1));

            var headerValue = authenticator.GetAuthorizationHeaderValue(requestBody.ToJson());

            headerValue.Should().NotBeNullOrEmpty();
        }
예제 #2
0
        private async Task <IEnumerable <MivaProduct> > CollectProductsFromPage(DateTime lastModifiedDateUtc, int pageIndex, int pageSize, CancellationToken token, Mark mark)
        {
            var request = new GetModifiedProductsRequest(base.Config.Credentials, lastModifiedDateUtc);

            request.SetPage(pageIndex, pageSize);

            var response = await base.PostAsync <MivaDataResponse <IEnumerable <Product> > >(request, token, mark).ConfigureAwait(false);

            if (response.Success == 0)
            {
                throw new MivaException(response.ErrorMessage, response.ErrorCode);
            }

            if (response.Data?.Data != null)
            {
                return(response.Data.Data.Select(r => r.ToSVProduct(base.Config.Credentials)));
            }

            return(Array.Empty <MivaProduct>());
        }