package com.sikey.wa04.common.dto.header;

import com.sikey.wa04.common.constants.HeaderConstant;
import lombok.Data;
import lombok.ToString;

import java.util.Map;

@Data
@ToString
public class GenericManufacturerHeader {
    private String system;
    private String systemVersion;
    private String softWareVersion;

    private String deviceModel;

    private String manufacturer;
    private String timeZone;
    private Long timestamp;
    private String requestId;
    private String localization;

    private String signal;
    private String maxSignal;
    private String battery;
    private String step;

    public GenericManufacturerHeader(Map<String, Object> headers) {
        setSystem(String.valueOf(headers.getOrDefault(HeaderConstant.SYSTEM, "")));
        setSystemVersion(String.valueOf(headers.getOrDefault(HeaderConstant.SYSTEM_VERSION, "")));
        setSoftWareVersion(String.valueOf(headers.getOrDefault(HeaderConstant.SOFTWARE_VERSION, "")));

        setDeviceModel(String.valueOf(headers.getOrDefault(HeaderConstant.DEVICE_MODEL, "")));

        setManufacturer(String.valueOf(headers.getOrDefault(HeaderConstant.MANUFACTURER, "")));
        setTimeZone(String.valueOf(headers.getOrDefault(HeaderConstant.TIME_ZONE, "")));
        setRequestId(String.valueOf(headers.getOrDefault(HeaderConstant.REQUEST_ID, "")));
        setTimestamp(Long.parseLong(String.valueOf(headers.getOrDefault(HeaderConstant.TIMESTAMP, 0L))));
        setLocalization(String.valueOf(headers.getOrDefault(HeaderConstant.LOCALIZATION, "")));

        // 信号
        setSignal(String.valueOf(headers.getOrDefault(HeaderConstant.SIGNAL,"")));
        // 最大信号
        setMaxSignal(String.valueOf(headers.getOrDefault(HeaderConstant.MAX_SIGNAL, "")));
        // 电量
        setBattery(String.valueOf(headers.getOrDefault(HeaderConstant.BATTERY,"")));
        // 步数
        setStep(String.valueOf(headers.getOrDefault(HeaderConstant.STEP,"")));
    }
}
