package org.ta.pddserver.model.pddlg.request;

import com.alibaba.fastjson.JSON;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.ta.pddserver.model.pddlg.common.TraceObject;

import java.util.List;

@Data
@Slf4j
public class PddLogisticsCoTrackNotifyRequest extends LGBaseModel {

    private DataObject dataObject;

    public PddLogisticsCoTrackNotifyRequest() {
        this.setType("pdd.logistics.co.track.notify");
        this.setData_type("JSON");
    }

    @Data
    public static class DataObject {
        List<TraceObject> traces;
    }



    @Override
    public void parseData() {
        try {
            this.dataObject = JSON.parseObject(this.getData(), DataObject.class);
        } catch (Exception e) {
            log.error("PddLogisticsCoTrackSubRequest parseData error");
            e.printStackTrace();
        }
    }

    @Override
    public void encodeData() {
        this.data = JSON.toJSONString(this.dataObject.getTraces());
        log.info("data={}", this.data);
        this.dataObject = null;
    }
}
