package com.nokia.sms.sgip;

import java.util.concurrent.Callable;

import com.nokia.sms.sgip.message.Head;
import com.nokia.sms.sgip.message.SgipMessage;
import com.nokia.sms.sgip.message.BindResponseMessage;
import com.nokia.sms.sgip.message.SubmitResponseMessage;
import com.nokia.sms.sgip.message.DeliverResponseMessage;
import com.nokia.sms.sgip.message.ReportResponseMessage;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class RespCaller implements Callable<Byte> {

    private SgipMessage respMessage;

    @Override
    public Byte call() throws Exception {
        byte result = -99;
        Head head = this.respMessage.getHead();
        switch (head.getCommandId()) {
            case -2147483647:
                result = ((BindResponseMessage) this.respMessage).getOperateResult();
                break;
            case -2147483645:
                result = ((SubmitResponseMessage) this.respMessage).getOperateResult();
                break;
            case -2147483644:
                result = ((DeliverResponseMessage) this.respMessage).getOperateResult();
                break;
            case -2147483643:
                result = ((ReportResponseMessage) this.respMessage).getOperateResult();
                break;
            case -2147483646:
                result = -100;
                break;
            default:
                result = -100;
        }
        log.trace("result=" + result);
        return Byte.valueOf(result);
    }

    public void setRespMessage(SgipMessage message) {
        this.respMessage = message;
    }
    
}
