示例#1
0
        public async Task <ProductResult> GetById(IConnectionCcvShop connection, int id, string lan = null)
        {
            //todo: add counter, max 150 per minute

            var p = new ExecuteParams(connection, lan)
            {
                Uri = $"/api/rest/v1/products/{id}",
            };

            return(await Get <ProductResult>(p));
        }
        public async Task <MultipleWebshopsResult> Get(IConnectionCcvShop connection = null, string lan = null)
        {
            //todo: add counter, max 150 per minute

            var uri = "/api/rest/v1/webshops/";
            var p   = new ExecuteParams(connection, lan);

            p.SetUri(uri);

            return(await Get <MultipleWebshopsResult>(p));
        }
        public async Task <List <MultipleCategoriesResult> > GetAll(IConnectionCcvShop connection = null, string lan = null)
        {
            //todo: add counter, max 150 per minute

            var uri = "/api/rest/v1/categories/";
            var p   = new ExecuteParams(connection, lan);

            p.SetUri(uri);

            return(await GetAll <MultipleCategoriesResult>(p));
        }
 public ExecuteParams(IConnectionCcvShop connection, string lan = null)
 {
     if (connection == null)
     {
         string errorMessage = "Connection should be available when you want to execute an API call.";
         Error.ErrorLogger.ErrorOccurred(errorMessage);
         throw new NotSupportedException(errorMessage);
     }
     Connection     = connection;
     TargetLanguage = lan;
 }
        public async Task <SettingsResult> GetByWebshopId(IConnectionCcvShop connection, int id, string lan = null)
        {
            //todo: add counter, max 150 per minute

            var p = new ExecuteParams(connection, lan)
            {
                Uri = $"/api/rest/v1/webshops/{id}/settings/",
            };

            return(await Get <SettingsResult>(p));
        }
示例#6
0
        public async Task <bool> Verify(IConnectionCcvShop connection = null)
        {
            var p = new ExecuteParams(connection)
            {
                Uri  = $"/api/rest/v1/apps/{AppInformation.Instance.AppId}",
                Data = new { is_installed = true }
            };
            var result = await Patch(p);

            return(result.Success);
        }
示例#7
0
        public async Task <bool> Patch(IConnectionCcvShop connection, int id, ProductResult original, string lan = null)
        {
            //todo: add counter, max 100 per minute

            var p = new ExecuteParams(connection, lan)
            {
                Uri  = $"/api/rest/v1/products/{id}",
                Data = Core.Compare.GetChanges(original)
            };

            return((await Patch(p)).Success);
        }
示例#8
0
        public async Task <List <MultipleProductsResult> > GetAll(IConnectionCcvShop connection = null, Parameters parameters = null, string lan = null)
        {
            //todo: add order by module
            //todo: add counter, max 150 per minute

            var uri = "/api/rest/v1/products/";
            var p   = new ExecuteParams(connection, lan);

            p.SetUri(uri, parameters);

            return(await GetAll <MultipleProductsResult>(p));
        }
        public async Task <SettingsResult> GetByFirstWebshop(IConnectionCcvShop connection, string lan = null)
        {
            var context = new WebshopsContext();
            var result  = await context.Get(connection, lan : lan);

            var firstShop = result?.items.FirstOrDefault();

            if (firstShop == null)
            {
                return(null);
            }

            return(await GetByWebshopId(connection, firstShop.id));
        }
示例#10
0
 public async Task <bool> VerifyInstall(IConnectionCcvShop connection)
 {
     Api.Apps.AppsContext apps = new Api.Apps.AppsContext();
     return(await apps.Verify(connection));
 }