Package

Source Code of CatalogUploadAddModifyDeleteExample

/**
* PlayTrade API Java Client
* Copyright 2013 PureBuy Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use the this PlayTrade API Java Client except
* in compliance with the License.
*
* You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.File;
import java.io.IOException;

import uk.co.purebuy.commerce.businessobjects.importexport.playtrade.call.CatalogUploadAddModifyDeleteCall;
import uk.co.purebuy.commerce.businessobjects.importexport.playtrade.call.PlayTradeApiCallException;

import uk.co.purebuy.commerce.businessobjects.importexport.playtrade.dom.CatalogUploadAddModifyDelete;
import uk.co.purebuy.commerce.businessobjects.importexport.playtrade.dom.CatalogUploadAddModifyDeleteRow;
import uk.co.purebuy.commerce.businessobjects.importexport.playtrade.dom.CatalogUploadModifyOnly;
import uk.co.purebuy.commerce.businessobjects.importexport.playtrade.dom.CatalogUploadModifyOnly.DispatchFromCode;
import uk.co.purebuy.commerce.businessobjects.importexport.playtrade.dom.CatalogUploadModifyOnly.DispatchToCode;

/**
* Example that adds or modifies a product in the sellers PlayTrade Catalog via
* an API call
*
* @author Dave/James Allcock
* Copyright 2013 PureBuy Ltd
*/
public class CatalogUploadAddModifyDeleteExample
{
  /**
   * @param args none
   * @throws IOException if couldnt create the temp batch file
   * @throws PlayTradeApiCallException if error occured while making the call to playtrade
   */
  public static void main(String[] args) throws IOException,
      PlayTradeApiCallException
  {
    // create the feed
    CatalogUploadAddModifyDelete feed = new CatalogUploadAddModifyDelete();

    // Add the header row
    feed.setHeader(new CatalogUploadAddModifyDeleteRow(true));

    // Create and add some Catalog Data to the feed
    // create a data row for each product
    CatalogUploadAddModifyDeleteRow row = new CatalogUploadAddModifyDeleteRow();
    row.setProductId("upc_ean_code");
    row.setProductIdType(CatalogUploadAddModifyDelete.ProductIDTypeCode.UPC_EAN);
    row.setSku("my_sku_code");
    row.setDeliveredPriceGBP("19.99");
    row.setDeliveredPriceEuro("26,99");
    row.setQuantity("97");
    row.setItemCondition(CatalogUploadModifyOnly.ItemConditionCode.NEW
        .toString());
    row.setAddDelete(CatalogUploadAddModifyDelete.AddModifyDelete.ADD_OR_MODIFY);
    row.setComment("This is a great product");
    row.setDispatchFrom(DispatchFromCode.UK);
    row.setDispatchTo(DispatchToCode.UK_ONLY);

    // add the product data row to the feed
    feed.addRowData(row);

    // create the feed file
    File batchfile = feed.createTempFile();
    feed.writeCSVFile(batchfile);

    // submit the feed file to the playtrade API
    CatalogUploadAddModifyDeleteCall call = new CatalogUploadAddModifyDeleteCall();
    call.setUsername("user@email.com");
    call.setPassword("password");
    call.setBatchfile(batchfile);
    call.callCatalogUploadAddModifyDelete();
  }

}
TOP

Related Classes of CatalogUploadAddModifyDeleteExample

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.