Subversion Repositories SmartDukaan

Rev

Rev 7473 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7473 vikram.rag 1
package com.amazonservices.mws.orders.samples;
2
 
3
 
4
import java.io.File;
5
import java.io.FileWriter;
6
import java.io.IOException;
7
import java.util.Arrays;
8
import java.util.HashMap;
9
import java.util.List;
10
import java.util.Map;
11
import java.util.Map.Entry;
12
import java.util.Date;   
13
 
14
import in.shop2020.config.ConfigException;
15
import in.shop2020.logistics.LogisticsServiceException;
16
import in.shop2020.logistics.PickUpType;
17
import in.shop2020.model.v1.catalog.Amazonlisted;
18
import in.shop2020.model.v1.inventory.AmazonInventorySnapshot;
19
import in.shop2020.model.v1.order.AmazonOrder;
20
import in.shop2020.model.v1.catalog.CatalogService.Client;
21
import in.shop2020.model.v1.inventory.InventoryServiceException;
22
import in.shop2020.serving.model.ShipmentUpdate;
23
import in.shop2020.thrift.clients.CatalogClient;
24
import in.shop2020.thrift.clients.HelperClient;
25
import in.shop2020.thrift.clients.InventoryClient;
26
import in.shop2020.thrift.clients.LogisticsClient;
27
import in.shop2020.thrift.clients.PaymentClient;
28
import in.shop2020.thrift.clients.TransactionClient;
29
import in.shop2020.thrift.clients.config.ConfigClient;
30
import in.shop2020.model.v1.order.Order;
31
import in.shop2020.model.v1.order.OrderStatus;
32
import in.shop2020.model.v1.order.OrderSource;
33
import in.shop2020.model.v1.order.OrderType;
34
import in.shop2020.model.v1.order.TransactionServiceException;
35
import in.shop2020.model.v1.order.TransactionStatus;
36
import in.shop2020.payments.PaymentStatus;
37
import in.shop2020.thrift.clients.UserClient;
38
import java.security.SecureRandom;
39
import java.math.BigInteger;
40
 
41
 
42
import org.apache.thrift.TException;
43
import org.apache.thrift.transport.TTransportException;
44
 
45
public class Test {
46
 
47
public static void main(String[] args) throws TException, TransactionServiceException, ConfigException, IOException, InventoryServiceException {
48
/*AmazonOrder amazonOrder = new AmazonOrder();
49
amazonOrder.setOrderId(406292);
50
amazonOrder.setAmazonOrderCode(1234531);
51
amazonOrder.setAmazonOrderItemCode(987655121);
52
amazonOrder.setTransactionId(567891);
53
amazonOrder.setItem_id(134);
54
amazonOrder.setStatus("Pending");*/
55
   TransactionClient tcl;
56
tcl = new TransactionClient();
57
//tcl.getClient().changeAmazonOrderStatus("402-0567501-5591550","Order-Payment-Success");
58
 
12614 amit.gupta 59
System.out.println("Orders are " +  tcl.getClient().getAmazonOrdersToAcknowledge(OrderSource.AMAZON));
7473 vikram.rag 60
//System.out.println(tcl.getClient().changeOrderStatus(2, OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY, "CANCELLED_DUE_TO_LOW_INVENTORY"));
61
/*PaymentClient pcl;
62
        long txnId=0;
63
try {
64
            pcl = new PaymentClient();
65
            long merchantPaymentId = pcl.getClient().createPayment(2000000, 2000.0, 14, 196279, false);
66
            System.out.println("merchantPaymentId "+merchantPaymentId);
67
            //Update payment status as authorized
68
            pcl.getClient().updatePaymentDetails(merchantPaymentId, "", "", "0", "", "", "", "", "", PaymentStatus.PENDING, "", null);
69
            txnId = pcl.getClient().getPayment(merchantPaymentId).getMerchantTxnId();
70
            System.out.println("merchant txnId"+txnId);
71
        } catch(Exception e) {
72
            System.out.println("Unable to create payment for this order");
73
        }
74
 
75
        try {
76
            tcl = new TransactionClient();
77
            boolean status = tcl.getClient().changeTransactionStatus(txnId, TransactionStatus.COD_IN_PROCESS, "Payment authorized", PickUpType.COURIER.getValue(), OrderType.B2C, OrderSource.AMAZON);
78
            System.out.println(status);
79
 
80
            if(!status) {
81
                System.out.println("Unable to update transaction");
82
            }
83
        } catch (Exception e) {
84
            System.out.println("Unable to create transaction");
85
        }
86
 
87
 
88
        try {
89
            pcl = new PaymentClient();
90
            System.out.println("TXN ID "+txnId);
91
 
92
            List<Order> orders = tcl.getClient().getOrdersForTransaction(txnId, 2000000);
93
            System.out.println(orders);
94
        } catch (Exception e) {
95
            System.out.println("Unable to retrieve orders");
96
        }
97
 
98
*/        
99
 
100
//System.out.println(tcl.getClient().cancelAmazonOrder(311446));
101
        //System.out.println(tcl.getClient().getAmazonOrdersShipped(2000));
102
/*SecureRandom random = new SecureRandom();
103
int randomPass= random.nextInt();
104
System.out.println(randomPass);
105
String string = Integer.toString(randomPass);
106
 int[] digits = new int[string.length()];
107
 
108
 for(int i = 0; i<string.length(); ++i){
109
   digits[i] = Integer.parseInt(string.substring(i, i+1));
110
 }
111
 System.out.println("digits:" + Arrays.toString(digits));*/
112
/*TransactionClient tcl;
113
tcl = new TransactionClient();
114
        System.out.println(tcl.getClient().getOrderForAmazonOrderCode(9010,"hi again"));*/
115
/*InventoryClient inventoryServiceClient = new InventoryClient();
116
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
117
AmazonInventorySnapshot amazonInventorySnapshot = new AmazonInventorySnapshot();
118
amazonInventorySnapshot.setItem_id(898989);
119
amazonInventorySnapshot.setAvailability(1000);
120
amazonInventorySnapshot.setReserved(2032);
121
inventoryClient.addOrUpdateAmazonInventoryForItem(amazonInventorySnapshot);
122
System.out.println(inventoryClient.getAllAmazonInventory());
123
        LogisticsClient inventoryServiceClient = new LogisticsClient();
124
        try {
125
System.out.println(inventoryServiceClient.getClient().getLogisticsEstimation(2032,"201301", 0));
126
} catch (LogisticsServiceException e) {
127
// TODO Auto-generated catch block
128
e.printStackTrace();
129
}
130
 
131
        //System.out.println(s);
132
        in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
133
        in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(5);
134
        System.out.println(thriftItemInventory);
135
        Map<Long,Long> availability = thriftItemInventory.getAvailability();
136
        System.out.println(availability);
137
        for(Map.Entry<Long,Long> entry:availability.entrySet()){
138
        Long warehouseid=entry.getKey();
139
        Long inventory=entry.getValue();
140
        System.out.println("Warehouse " + warehouseid + " Inventory " + inventory);
141
        }
142
        Map<Long,Long> availability1 = thriftItemInventory.getReserved();
143
        for(Map.Entry<Long,Long> entry:availability1.entrySet()){
144
        Long warehouseid=entry.getKey();
145
        Long inventory=entry.getValue();
146
        System.out.println("Warehouse " + warehouseid + " Inventory " + inventory);
147
*/
148
  }
149
}