Ejemplo n.º 1
0
        public List <KCAPIIdSkuJuxtaposion> GetAllIdSkuJuxtaposions()
        {
            List <KCAPIIdSkuJuxtaposion>           juxs      = new List <KCAPIIdSkuJuxtaposion>();
            KCODataWrapper <KCAPIIdSkuJuxtaposion> oDataJuxs = new KCODataWrapper <KCAPIIdSkuJuxtaposion>();

            do
            {
                IRestRequest jRequest = request.GetIdSkuJuxtaposions(oDataJuxs.NextLink?.Replace(KCARestClient.BASE_URL, ""));
                oDataJuxs = client.Get <KCODataWrapper <KCAPIIdSkuJuxtaposion> >(jRequest);
                juxs.AddRange(oDataJuxs.Value);
            }while (!string.IsNullOrEmpty(oDataJuxs.NextLink));

            return(juxs);
        }
        public List <KCAPIFulfillment> GetFulfillments(int orderID)
        {
            List <KCAPIFulfillment>           items      = new List <KCAPIFulfillment>();
            KCODataWrapper <KCAPIFulfillment> oDataItems = new KCODataWrapper <KCAPIFulfillment>();

            do
            {
                IRestRequest dcRequest = request.GetFulfillments(orderID, oDataItems.NextLink?.Replace(KCARestClient.BASE_URL, ""));
                oDataItems = client.Get <KCODataWrapper <KCAPIFulfillment> >(dcRequest);
                items.AddRange(oDataItems.Value);
            }while (!string.IsNullOrEmpty(oDataItems.NextLink));

            return(items);
        }
Ejemplo n.º 3
0
        public List <KCAPIInventoryItem> GetProducts()
        {
            List <KCAPIInventoryItem>           items      = new List <KCAPIInventoryItem>();
            KCODataWrapper <KCAPIInventoryItem> oDataItems = new KCODataWrapper <KCAPIInventoryItem>();

            do
            {
                IRestRequest dcRequest = request.GetProductsRequest(oDataItems.NextLink?.Replace(KCARestClient.BASE_URL, ""));
                oDataItems = client.Get <KCODataWrapper <KCAPIInventoryItem> >(dcRequest);
                items.AddRange(oDataItems.Value);
            }while (!string.IsNullOrEmpty(oDataItems.NextLink));

            return(items);
        }
Ejemplo n.º 4
0
        public List <KCAPIProfile> GetProfiles()
        {
            List <KCAPIProfile>           profiles     = new List <KCAPIProfile>();
            KCODataWrapper <KCAPIProfile> oDataWrapper = new KCODataWrapper <KCAPIProfile>();

            do
            {
                IRestRequest dcRequest = request.GetProfiles(oDataWrapper.NextLink?.Replace(KCARestClient.BASE_URL, ""));
                oDataWrapper = client.Get <KCODataWrapper <KCAPIProfile> >(dcRequest);
                profiles.AddRange(oDataWrapper.Value);
            }while (!string.IsNullOrEmpty(oDataWrapper.NextLink));

            return(profiles);
        }
        public List <KCAPIOrder> GetOrders(DateTime?dateFrom, DateTime?dateTo)
        {
            List <KCAPIOrder>           items      = new List <KCAPIOrder>();
            KCODataWrapper <KCAPIOrder> oDataItems = new KCODataWrapper <KCAPIOrder>();

            do
            {
                IRestRequest dcRequest = request.GetFilteredOrdersRequest(client._xSiteMaster.ProfileId, dateFrom, dateTo,
                                                                          oDataItems.NextLink?.Replace(KCARestClient.BASE_URL, ""));
                oDataItems = client.Get <KCODataWrapper <KCAPIOrder> >(dcRequest);
                items.AddRange(oDataItems.Value);
            }while (!string.IsNullOrEmpty(oDataItems.NextLink));

            return(items);
        }
Ejemplo n.º 6
0
        public List <KCAPIDistributionCenter> GetDistributionCenters()
        {
            List <KCAPIDistributionCenter>           distributionCenters     = new List <KCAPIDistributionCenter>();
            KCODataWrapper <KCAPIDistributionCenter> oDataDistributionCenter = new KCODataWrapper <KCAPIDistributionCenter>();

            do
            {
                IRestRequest dcRequest = request.GetDistributionCenters(oDataDistributionCenter.NextLink?.Replace(KCARestClient.BASE_URL, ""));
                oDataDistributionCenter = client.Get <KCODataWrapper <KCAPIDistributionCenter> >(dcRequest);
                if (oDataDistributionCenter.Value != null)
                {
                    distributionCenters.AddRange(oDataDistributionCenter.Value);
                }
            }while (!string.IsNullOrEmpty(oDataDistributionCenter.NextLink));

            return(distributionCenters);
        }
        public virtual void updateAttributes()
        {
            KCClassificationsMappingMaint classificationsGraph = PXGraph.CreateInstance <KCClassificationsMappingMaint>();
            PXResultset <KCAttribute>     existingAttributes   = Attributes.Select();
            List <string> existingNames = new List <string>();

            existingAttributes.RowCast <KCAttribute>().ForEach(x => existingNames.Add(x.AttributeName.Trim().ToUpper()));

            KCSiteMaster             connection = Connection.SelectSingle();
            KCARestClient            client     = new KCARestClient(connection);
            KCInventoryItemAPIHelper helper     = new KCInventoryItemAPIHelper(client);

            List <string> classificationAttributes = classificationsGraph.GetClassificationAttributes(helper);

            SaveAttributes(existingNames, classificationAttributes);
            List <string> skuAttributes = new List <string>();


            List <KNSIKCClassificationsMapping> SKUs = GetSKUs();
            List <int?> CAIDs = new List <int?>();

            foreach (KNSIKCClassificationsMapping classificationsMapping in SKUs)
            {
                CAIDs.Add(KCGeneralDataHelper.GetExistingCAProductByInventoryItemCd(helper, classificationsMapping.ChannelAdvisorSKU)?.ID);
            }

            foreach (int?CAID in CAIDs)
            {
                KCODataWrapper <KCAPIAttribute> CAAttributes = helper.GetAttributes(CAID);
                if (CAAttributes != null && CAAttributes.Value != null && CAAttributes.Value.Count > 0)
                {
                    List <string> attributeNames = new List <string>();
                    CAAttributes.Value.ForEach(x => attributeNames.Add(x.Name));
                    SaveAttributes(existingNames, attributeNames);
                    CAAttributes.Value.ForEach(x => skuAttributes.Add(x.Name));
                }
            }
            DeleteExtraAttributes(existingAttributes, classificationAttributes, skuAttributes);
            Actions.PressSave();
        }
        protected List <KCAPIAttribute> HandleAttributes(InventoryItem product)
        {
            List <KCAPIAttribute> attributes = new List <KCAPIAttribute>();
            KNSIKCInventoryItem   kcProduct  = Graph.KCInventoryItem.SelectSingle(product.InventoryID);

            HandleProductAttributes(product, ref attributes);
            HandleCrossReferences(product, ref attributes);

            KCODataWrapper <KCAPIAttribute> CAAttributes = ApiHelper.GetAttributes(kcProduct.UsrKCCAID);

            if (CAAttributes?.Value != null)
            {
                foreach (KCAPIAttribute attribute in CAAttributes.Value)
                {
                    if (!attributes.Select(x => x.Name.Trim().ToUpper()).Contains(attribute.Name.Trim().ToUpper()))
                    {
                        // 04/22/19 AT: When deleting attribute's value through FTP, ChannelAdvisor requires to pass DeleteMarker (currently "_Delete_")
                        // to indicate that its value should be deleted
                        attributes.Add(new KCAPIAttribute {
                            Name = attribute.Name, Value = KCConstants.DeleteMarker
                        });
                    }
                }
            }

            bool existProductType = Graph.RequiredChannelAdvisorAttribute.Select(KCConstants.ProductTypeAttributeName).Count > 0;

            if (existProductType && attributes.All(x => x.Name != KCConstants.ProductTypeAttributeName))
            {
                attributes.Add(new KCAPIAttribute {
                    Name = KCConstants.ProductTypeAttributeName, Value = GetProductType(product)
                });
            }

            return(attributes);
        }
Ejemplo n.º 9
0
        public IEnumerable <KCAPIProductLabel> GetProductLabels(int?productId)
        {
            KCODataWrapper <KCAPIProductLabel> result = client.Get <KCODataWrapper <KCAPIProductLabel> >(request.GetProductLabelsRequest(productId));

            return(result?.Value ?? new List <KCAPIProductLabel>());
        }