Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2751 varun.gupt 1
package in.shop2020.datalogger.event;
2
 
3
import org.json.JSONArray;
4
import org.json.JSONException;
5
import org.json.JSONObject;
6
 
7
import in.shop2020.datalogger.EventType;
8
 
9
public class CouponApplied extends Event {
10
 
11
	private String couponCode;
12
 
13
	public CouponApplied(String[] eventFileds) {
14
		super(eventFileds);
15
		couponCode = eventFileds[4].trim();
16
	}
17
 
18
	public CouponApplied(EventType eType, String sessionId, long userId, String email, String[] logData) {
19
		super(eType, sessionId, userId, email);
20
		couponCode = logData[4].trim();
21
	}
22
 
23
	public String toString() {
24
        StringBuilder sb = new StringBuilder();
25
        sb.append(eventType.name() + ", ");
26
        sb.append("userEmail : " + userEmail);
27
        sb.append(" couponCode : " + this.couponCode);
28
        sb.append(" time : " + time);
29
        sb.append(" session : " + sessionId);
30
 
31
        return sb.toString();
32
    }
33
 
34
    @Override
35
    public JSONObject getLogDataInJson() {
36
        JSONObject logDataInJson = new JSONObject();
37
        try {
38
            logDataInJson.put("couponCode", this.couponCode);
39
        } catch (JSONException e) {
40
            e.printStackTrace();
41
        }
42
        return logDataInJson;
43
    }
44
 
45
    public String getCouponCode()	{
46
    	return this.couponCode;
47
    }
48
 
49
    public void setCouponCode(String couponCode)	{
50
    	this.couponCode = couponCode;
51
    }
52
}