| Line 18... |
Line 18... |
| 18 |
public class SpiceDeckRechargeService {
|
18 |
public class SpiceDeckRechargeService {
|
| 19 |
private static Logger logger = LoggerFactory.getLogger(SpiceDeckRechargeService.class);
|
19 |
private static Logger logger = LoggerFactory.getLogger(SpiceDeckRechargeService.class);
|
| 20 |
private static final String voucherGenerationUrl = "http://www.spicedeck.com/mcommerce/couponregister.sdesk";
|
20 |
private static final String voucherGenerationUrl = "http://www.spicedeck.com/mcommerce/couponregister.sdesk";
|
| 21 |
private static final String voucherActivationUrl = "http://www.spicedeck.com/mcommerce/couponassign.sdesk";
|
21 |
private static final String voucherActivationUrl = "http://www.spicedeck.com/mcommerce/couponassign.sdesk";
|
| 22 |
|
22 |
|
| 23 |
public static void storeVoucher(String username, String password, long amount) throws Exception{
|
23 |
public static void storeVoucher(String username, String password, long amount, long numberOfVouchers) throws Exception{
|
| - |
|
24 |
for(int i=0; i<numberOfVouchers; i++){
|
| 24 |
String coupon = generateVoucher(username, password, amount);
|
25 |
String coupon = generateVoucher(username, password, amount);
|
| 25 |
Voucher voucher = new Voucher();
|
26 |
Voucher voucher = new Voucher();
|
| 26 |
voucher.setVoucherType(VoucherType.MOBILE);
|
27 |
voucher.setVoucherType(VoucherType.SPICEDECK_MOBILE);
|
| 27 |
voucher.setAmount(amount);
|
28 |
voucher.setAmount(amount);
|
| 28 |
voucher.setVoucherCode(coupon);
|
29 |
voucher.setVoucherCode(coupon);
|
| 29 |
voucher.setIssuedOn(new Date().getTime());
|
30 |
voucher.setIssuedOn(new Date().getTime());
|
| 30 |
Client pc = new PromotionClient().getClient();
|
31 |
Client pc = new PromotionClient().getClient();
|
| 31 |
pc.addVoucher(voucher);
|
32 |
pc.addVoucher(voucher);
|
| - |
|
33 |
}
|
| 32 |
}
|
34 |
}
|
| 33 |
|
35 |
|
| 34 |
public static void issueVoucher(String username, String password, long userId, String userEmail, long amount) throws Exception{
|
36 |
public static void issueVoucher(String username, String password, long userId, String userEmail, long amount) throws Exception{
|
| 35 |
Client pc = new PromotionClient().getClient();
|
37 |
Client pc = new PromotionClient().getClient();
|
| 36 |
Voucher voucher = pc.assignVoucher(userId, userEmail, VoucherType.MOBILE, amount);
|
38 |
Voucher voucher = pc.assignVoucher(userId, userEmail, VoucherType.SPICEDECK_MOBILE, amount);
|
| 37 |
boolean isActivated = activateVoucher(username, password, voucher.getVoucherCode(), voucher.getUserEmail());
|
39 |
boolean isActivated = activateVoucher(username, password, voucher.getVoucherCode(), voucher.getUserEmail());
|
| 38 |
if(!isActivated){
|
40 |
if(!isActivated){
|
| 39 |
throw new Exception("Voucher could not get activated.");
|
41 |
throw new Exception("Voucher could not get activated.");
|
| 40 |
}
|
42 |
}
|
| 41 |
}
|
43 |
}
|
| Line 95... |
Line 97... |
| 95 |
}
|
97 |
}
|
| 96 |
|
98 |
|
| 97 |
public static void main(String args[]) throws Exception{
|
99 |
public static void main(String args[]) throws Exception{
|
| 98 |
//System.out.println(SpiceDeckRechargeService.generateVoucher("sachingyal", "abc1234", 1));
|
100 |
//System.out.println(SpiceDeckRechargeService.generateVoucher("sachingyal", "abc1234", 1));
|
| 99 |
//System.out.println(SpiceDeckRechargeService.activateVoucher("sachingyal", "abc1234", "SHL1340274524944", "rajveer.singh@saholic.com"));
|
101 |
//System.out.println(SpiceDeckRechargeService.activateVoucher("sachingyal", "abc1234", "SHL1340274524944", "rajveer.singh@saholic.com"));
|
| 100 |
//storeVoucher("sachingyal", "abc1234", 5);
|
102 |
storeVoucher("sachingyal", "abc1234", 5, 1);
|
| 101 |
issueVoucher("sachingyal", "abc1234", 191919, "anupam.singh@shop2020.in", 5);
|
103 |
issueVoucher("sachingyal", "abc1234", 191919, "mandeep.dhir@shop2020.in", 5);
|
| 102 |
}
|
104 |
}
|
| 103 |
}
|
105 |
}
|