Dashboard > ChannelAdvisor Developer Network > ... > Inventory Service Examples > SynchInventoryItem Examples
Log In   View a printable version of the current page.
SynchInventoryItem Examples
Added by Andy Berryman, last edited by Andy Berryman on May 11, 2007  (view change)
Labels: 
(None)




Raw Xml 

NOTE: Nodes in RED are "optional" and can be omitted if not needed.

Request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://api.channeladvisor.com/webservices/">
   <soapenv:Header>
      <web:APICredentials>
         <web:DeveloperKey>XXX</web:DeveloperKey>
         <web:Password>XXX</web:Password>
      </web:APICredentials>
   </soapenv:Header>
   <soapenv:Body>
      <web:SynchInventoryItem>
         <web:accountID>XXX</web:accountID>
         <web:item>
            <web:Sku></web:Sku>
            <web:Title></web:Title>
            <web:Subtitle></web:Subtitle>
            <web:ShortDescription></web:ShortDescription>
            <web:Description></web:Description>
            <web:Weight></web:Weight>
            <web:SupplierCode></web:SupplierCode>
            <web:WarehouseLocation></web:WarehouseLocation>
            <web:TaxProductCode></web:TaxProductCode>
            <web:FlagStyle></web:FlagStyle>
            <web:FlagDescription></web:FlagDescription>
            <web:IsBlocked></web:IsBlocked>
            <web:BlockComment></web:BlockComment>
            <web:QuantityInfo>
               <web:UpdateType></web:UpdateType>
               <web:Total></web:Total>
            </web:QuantityInfo>
            <web:PriceInfo>
               <web:Cost></web:Cost>
               <web:RetailPrice></web:RetailPrice>
               <web:StartingPrice></web:StartingPrice>
               <web:ReservePrice></web:ReservePrice>
               <web:TakeItPrice></web:TakeItPrice>
               <web:SecondChanceOfferPrice>?</web:SecondChanceOfferPrice>
               <web:StorePrice></web:StorePrice>
            </web:PriceInfo>
            <web:ClassificationInfo>
               <web:Name></web:Name>
               <web:AttributeList>
                  <web:ClassificationAttributeInfo>
                     <web:Name></web:Name>
                     <web:Value></web:Value>
                  </web:ClassificationAttributeInfo>
                  <web:ClassificationAttributeInfo>
                     <web:Name></web:Name>
                     <web:Value></web:Value>
                  </web:ClassificationAttributeInfo>
               </web:AttributeList>
            </web:ClassificationInfo>
            <web:VariationInfo>
               <web:IsInRelationship></web:IsInRelationship>
               <web:RelationshipName></web:RelationshipName>
               <web:IsParent></web:IsParent>
               <web:ParentSku></web:ParentSku>
            </web:VariationInfo>
            <web:StoreInfo>
               <web:DisplayInStore></web:DisplayInStore>
               <web:Title></web:Title>
               <web:Description></web:Description>
               <web:CategoryID></web:CategoryID>
            </web:StoreInfo>
            <web:ImageList>
               <web:ImageInfoSubmit>
                  <web:PlacementName></web:PlacementName>
                  <web:FolderName></web:FolderName>
                  <web:FilenameOrUrl></web:FilenameOrUrl>
               </web:ImageInfoSubmit>
               <web:ImageInfoSubmit>
                  <web:PlacementName></web:PlacementName>
                  <web:FolderName></web:FolderName>
                  <web:FilenameOrUrl></web:FilenameOrUrl>
               </web:ImageInfoSubmit>
            </web:ImageList>
            <web:ShippingInfo>
               <web:DistributionCenterCode></web:DistributionCenterCode>
               <web:ShippingRateList>
                  <web:ShippingRateInfo>
                     <web:DestinationZoneName></web:DestinationZoneName>
                     <web:CarrierCode></web:CarrierCode>
                     <web:ClassCode></web:ClassCode>
                     <web:FirstItemRate></web:FirstItemRate>
                     <web:AdditionalItemRate></web:AdditionalItemRate>
                     <web:FirstItemHandlingRate></web:FirstItemHandlingRate>
                     <web:AdditionalItemHandlingRate></web:AdditionalItemHandlingRate>
                     <web:FreeShippingIfBuyItNow></web:FreeShippingIfBuyItNow>
                     <web:FirstItemRateAttribute></web:FirstItemRateAttribute>
                     <web:AdditionalItemRateAttribute></web:AdditionalItemRateAttribute>
                  </web:ShippingRateInfo>
                  <web:ShippingRateInfo>
                     <web:DestinationZoneName></web:DestinationZoneName>
                     <web:CarrierCode></web:CarrierCode>
                     <web:ClassCode></web:ClassCode>
                     <web:FirstItemRate></web:FirstItemRate>
                     <web:AdditionalItemRate></web:AdditionalItemRate>
                     <web:FirstItemHandlingRate></web:FirstItemHandlingRate>
                     <web:AdditionalItemHandlingRate></web:AdditionalItemHandlingRate>
                     <web:FreeShippingIfBuyItNow></web:FreeShippingIfBuyItNow>
                     <web:FirstItemRateAttribute></web:FirstItemRateAttribute>
                     <web:AdditionalItemRateAttribute></web:AdditionalItemRateAttribute>
                  </web:ShippingRateInfo>
               </web:ShippingRateList>
            </web:ShippingInfo>
         </web:item>
      </web:SynchInventoryItem>
   </soapenv:Body>
</soapenv:Envelope>

Response

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <SynchInventoryItemResponse xmlns="http://api.channeladvisor.com/webservices/">
         <SynchInventoryItemResult>
            <Status>Success</Status>
            <MessageCode>0</MessageCode>
            <ResultData>true</ResultData>
         </SynchInventoryItemResult>
      </SynchInventoryItemResponse>
   </soap:Body>
</soap:Envelope>


C#

Request

// Create your credentials
CA_API_InventorySvc.APICredentials cred = new CA_API_InventorySvc.APICredentials();
cred.DeveloperKey = "dev-key-guid";
cred.Password = "pwd";

// Create the Web Service and attach the credentials
CA_API_InventorySvc.InventoryService svc = new CA_API_InventorySvc.InventoryService();
svc.APICredentialsValue = cred;

// Create the Item Submit object
CA_API_InventorySvc.InventoryItemSubmit item = new CA_API_InventorySvc.InventoryItemSubmit(); 

// Set the base value properties
item.Sku = "001";
item.Title = "Test Inventory Item";
item.Subtitle = "";
item.ShortDescription = "This is a really cool item!";
item.Description = "This item is the hottest new thing on the market! Buy quick as supplies are limited!";
item.Weight = 1.0;
item.SupplierCode = "Supplier1";
item.WarehouseLocation = "Warehouse1";
item.TaxProductCode = "";
item.FlagStyle = CA_API_InventorySvc.FlagType.NoFlag;
item.FlagDescription = "";
item.IsBlocked = false;
item.BlockComment = "";

// Set the Quantity details
item.QuantityInfo = new CA_API_InventorySvc.QuantityInfoSubmit();
item.QuantityInfo.UpdateType = CA_API_InventorySvc.InventoryQuantityUpdateType.Absolute;
item.QuantityInfo.Total = 100;

// Set the Pricing details
item.PriceInfo = new CA_API_InventorySvc.PriceInfo();
item.PriceInfo.Cost = .99m;
item.PriceInfo.ReservePrice = 2.99m;
item.PriceInfo.RetailPrice = 3.99m;
item.PriceInfo.SecondChanceOfferPrice = 2.99m;
item.PriceInfo.StartingPrice = 1.99m;
item.PriceInfo.StorePrice = 3.99m;
item.PriceInfo.TakeItPrice = 3.99m;

// Set the Classification details
item.ClassificationInfo = new CA_API_InventorySvc.ClassificationInfo();
item.ClassificationInfo.Name = "Cool Stuff";

List<CA_API_InventorySvc.ClassificationAttributeInfo> attrs = new List<CA_API_InventorySvc.ClassificationAttributeInfo>();

CA_API_InventorySvc.ClassificationAttributeInfo attr1 = new CA_API_InventorySvc.ClassificationAttributeInfo();
attr1.Name = "Color";
attr1.Value = "Red";
attrs.Add(attr1);

CA_API_InventorySvc.ClassificationAttributeInfo attr2 = new CA_API_InventorySvc.ClassificationAttributeInfo();
attr2.Name = "Size";
attr2.Value = "Large";
attrs.Add(attr2);

item.ClassificationInfo.AttributeList = attrs.ToArray();

// Set the Variation details
item.VariationInfo = new CA_API_InventorySvc.VariationInfo();
item.VariationInfo.IsInRelationship = false;
item.VariationInfo.RelationshipName = "";
item.VariationInfo.IsParent = false;
item.VariationInfo.ParentSku = "";

// Set the Store details
item.StoreInfo = new CA_API_InventorySvc.StoreInfo();
item.StoreInfo.DisplayInStore = false;
item.StoreInfo.Title = "";
item.StoreInfo.Description = "";
item.StoreInfo.CategoryID = 1;

// Set the associated Images
List<CA_API_InventorySvc.ImageInfoSubmit> imgs = new List<CA_API_InventorySvc.ImageInfoSubmit>();

CA_API_InventorySvc.ImageInfoSubmit img1 = new CA_API_InventorySvc.ImageInfoSubmit();
img1.PlacementName = "ITEMIMAGEURL1";
img1.FolderName = null;
img1.FilenameOrUrl = http://www.yourserver.com/images/img1.jpg;
imgs.Add(img1);

CA_API_InventorySvc.ImageInfoSubmit img2 = new CA_API_InventorySvc.ImageInfoSubmit();
img2.PlacementName = "ITEMIMAGEURL2";
img2.FolderName = null;
img2.FilenameOrUrl = http://www.yourserver.com/images/img2.jpg;
imgs.Add(img2);

CA_API_InventorySvc.ImageInfoSubmit img3 = new CA_API_InventorySvc.ImageInfoSubmit();
img3.PlacementName = "ITEMIMAGEURL3";
img3.FolderName = null;
img3.FilenameOrUrl = http://www.yourserver.com/images/img3.jpg;
imgs.Add(img3);

item.ImageList = imgs.ToArray();

// Set the Shipping details
item.ShippingInfo = new CA_API_InventorySvc.ShippingInfo();
item.ShippingInfo.DistributionCenterCode = "DistributionCenter1";

List<CA_API_InventorySvc.ShippingRateInfo> rates = new List<CA_API_InventorySvc.ShippingRateInfo>();

CA_API_InventorySvc.ShippingRateInfo rate1 = new CA_API_InventorySvc.ShippingRateInfo();
rate1.DestinationZoneName = "Domestic";
rate1.CarrierCode = "UPS";
rate1.ClassCode = "STD";
rate1.FirstItemRateAttribute = CA_API_InventorySvc.ShippingRateAttribute.Price;
rate1.FirstItemRate = 1.99m;
rate1.FirstItemHandlingRate = .49m;
rate1.AdditionalItemRateAttribute = CA_API_InventorySvc.ShippingRateAttribute.Price;
rate1.AdditionalItemRate = .49m;
rate1.AdditionalItemHandlingRate = .00m;
rate1.FreeShippingIfBuyItNow = false;
rates.Add(rate1);

CA_API_InventorySvc.ShippingRateInfo rate2 = new CA_API_InventorySvc.ShippingRateInfo();
rate2.DestinationZoneName = "Domestic";
rate2.CarrierCode = "FEDEX";
rate2.ClassCode = "GROUND";
rate2.FirstItemRateAttribute = CA_API_InventorySvc.ShippingRateAttribute.Price;
rate2.FirstItemRate = 1.99m;
rate2.FirstItemHandlingRate = .49m;
rate2.AdditionalItemRateAttribute = CA_API_InventorySvc.ShippingRateAttribute.Price;
rate2.AdditionalItemRate = .49m;
rate2.AdditionalItemHandlingRate = .00m;
rate2.FreeShippingIfBuyItNow = false;
rates.Add(rate2);

CA_API_InventorySvc.ShippingRateInfo rate3 = new CA_API_InventorySvc.ShippingRateInfo();
rate3.DestinationZoneName = "Domestic";
rate3.CarrierCode = "FEDEX";
rate3.ClassCode = "OVERNIGHT";
rate3.FirstItemRateAttribute = CA_API_InventorySvc.ShippingRateAttribute.Price;
rate3.FirstItemRate = 4.99m;
rate3.FirstItemHandlingRate = 1.99m;
rate3.AdditionalItemRateAttribute = CA_API_InventorySvc.ShippingRateAttribute.Price;
rate3.AdditionalItemRate = 1.99m;
rate3.AdditionalItemHandlingRate = .49m;
rate3.FreeShippingIfBuyItNow = false;
rates.Add(rate3);

item.ShippingInfo.ShippingRateList = rates.ToArray();

// Now just call the method
CA_API_InventorySvc.APIResultOfBoolean result = svc.SynchInventoryItem("acct-guid", item);

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.1 Build:#806 May 06, 2007) - Bug/feature request - Contact Administrators