Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

package in.shop2020.datalogger.event;

import in.shop2020.datalogger.EventType;

import org.json.JSONException;
import org.json.JSONObject;

public class CouponRemoved extends Event {

        private String couponCode;

        public CouponRemoved(String[] eventFileds) {
                super(eventFileds);
                couponCode = eventFileds[4].trim();
        }

        public CouponRemoved(EventType eType, String sessionId, long userId, String email, String[] logData) {
                super(eType, sessionId, userId, email);
                couponCode = logData[4].trim();
        }
        
        public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(eventType.name() + ", ");
        sb.append("userEmail : " + userEmail);
        sb.append(" couponCode : " + this.couponCode);
        sb.append(" time : " + time);
        sb.append(" session : " + sessionId);
        
        return sb.toString();
    }

    @Override
    public JSONObject getLogDataInJson() {
        JSONObject logDataInJson = new JSONObject();
        try {
            logDataInJson.put("coupon_code", this.couponCode);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return logDataInJson;
    }
    
    public String getCouponCode()       {
        return this.couponCode;
    }
    
    public void setCouponCode(String couponCode)        {
        this.couponCode = couponCode;
    }
}