Rev 7473 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.amazonservices.mws.orders.samples;import java.io.File;import java.io.FileWriter;import java.io.IOException;import java.util.Arrays;import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.Map.Entry;import java.util.Date;import in.shop2020.config.ConfigException;import in.shop2020.logistics.LogisticsServiceException;import in.shop2020.logistics.PickUpType;import in.shop2020.model.v1.catalog.Amazonlisted;import in.shop2020.model.v1.inventory.AmazonInventorySnapshot;import in.shop2020.model.v1.order.AmazonOrder;import in.shop2020.model.v1.catalog.CatalogService.Client;import in.shop2020.model.v1.inventory.InventoryServiceException;import in.shop2020.serving.model.ShipmentUpdate;import in.shop2020.thrift.clients.CatalogClient;import in.shop2020.thrift.clients.HelperClient;import in.shop2020.thrift.clients.InventoryClient;import in.shop2020.thrift.clients.LogisticsClient;import in.shop2020.thrift.clients.PaymentClient;import in.shop2020.thrift.clients.TransactionClient;import in.shop2020.thrift.clients.config.ConfigClient;import in.shop2020.model.v1.order.Order;import in.shop2020.model.v1.order.OrderStatus;import in.shop2020.model.v1.order.OrderSource;import in.shop2020.model.v1.order.OrderType;import in.shop2020.model.v1.order.TransactionServiceException;import in.shop2020.model.v1.order.TransactionStatus;import in.shop2020.payments.PaymentStatus;import in.shop2020.thrift.clients.UserClient;import java.security.SecureRandom;import java.math.BigInteger;import org.apache.thrift.TException;import org.apache.thrift.transport.TTransportException;public class Test {public static void main(String[] args) throws TException, TransactionServiceException, ConfigException, IOException, InventoryServiceException {/*AmazonOrder amazonOrder = new AmazonOrder();amazonOrder.setOrderId(406292);amazonOrder.setAmazonOrderCode(1234531);amazonOrder.setAmazonOrderItemCode(987655121);amazonOrder.setTransactionId(567891);amazonOrder.setItem_id(134);amazonOrder.setStatus("Pending");*/TransactionClient tcl;tcl = new TransactionClient();//tcl.getClient().changeAmazonOrderStatus("402-0567501-5591550","Order-Payment-Success");System.out.println("Orders are " + tcl.getClient().getAmazonOrdersToAcknowledge(OrderSource.AMAZON));//System.out.println(tcl.getClient().changeOrderStatus(2, OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY, "CANCELLED_DUE_TO_LOW_INVENTORY"));/*PaymentClient pcl;long txnId=0;try {pcl = new PaymentClient();long merchantPaymentId = pcl.getClient().createPayment(2000000, 2000.0, 14, 196279, false);System.out.println("merchantPaymentId "+merchantPaymentId);//Update payment status as authorizedpcl.getClient().updatePaymentDetails(merchantPaymentId, "", "", "0", "", "", "", "", "", PaymentStatus.PENDING, "", null);txnId = pcl.getClient().getPayment(merchantPaymentId).getMerchantTxnId();System.out.println("merchant txnId"+txnId);} catch(Exception e) {System.out.println("Unable to create payment for this order");}try {tcl = new TransactionClient();boolean status = tcl.getClient().changeTransactionStatus(txnId, TransactionStatus.COD_IN_PROCESS, "Payment authorized", PickUpType.COURIER.getValue(), OrderType.B2C, OrderSource.AMAZON);System.out.println(status);if(!status) {System.out.println("Unable to update transaction");}} catch (Exception e) {System.out.println("Unable to create transaction");}try {pcl = new PaymentClient();System.out.println("TXN ID "+txnId);List<Order> orders = tcl.getClient().getOrdersForTransaction(txnId, 2000000);System.out.println(orders);} catch (Exception e) {System.out.println("Unable to retrieve orders");}*///System.out.println(tcl.getClient().cancelAmazonOrder(311446));//System.out.println(tcl.getClient().getAmazonOrdersShipped(2000));/*SecureRandom random = new SecureRandom();int randomPass= random.nextInt();System.out.println(randomPass);String string = Integer.toString(randomPass);int[] digits = new int[string.length()];for(int i = 0; i<string.length(); ++i){digits[i] = Integer.parseInt(string.substring(i, i+1));}System.out.println("digits:" + Arrays.toString(digits));*//*TransactionClient tcl;tcl = new TransactionClient();System.out.println(tcl.getClient().getOrderForAmazonOrderCode(9010,"hi again"));*//*InventoryClient inventoryServiceClient = new InventoryClient();in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();AmazonInventorySnapshot amazonInventorySnapshot = new AmazonInventorySnapshot();amazonInventorySnapshot.setItem_id(898989);amazonInventorySnapshot.setAvailability(1000);amazonInventorySnapshot.setReserved(2032);inventoryClient.addOrUpdateAmazonInventoryForItem(amazonInventorySnapshot);System.out.println(inventoryClient.getAllAmazonInventory());LogisticsClient inventoryServiceClient = new LogisticsClient();try {System.out.println(inventoryServiceClient.getClient().getLogisticsEstimation(2032,"201301", 0));} catch (LogisticsServiceException e) {// TODO Auto-generated catch blocke.printStackTrace();}//System.out.println(s);in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(5);System.out.println(thriftItemInventory);Map<Long,Long> availability = thriftItemInventory.getAvailability();System.out.println(availability);for(Map.Entry<Long,Long> entry:availability.entrySet()){Long warehouseid=entry.getKey();Long inventory=entry.getValue();System.out.println("Warehouse " + warehouseid + " Inventory " + inventory);}Map<Long,Long> availability1 = thriftItemInventory.getReserved();for(Map.Entry<Long,Long> entry:availability1.entrySet()){Long warehouseid=entry.getKey();Long inventory=entry.getValue();System.out.println("Warehouse " + warehouseid + " Inventory " + inventory);*/}}