package org.wso2.carbon.device.mgt.ios.api.utils.beans;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * This is used to map the status of an operation.
 */
@ApiModel(
        value = "OperationStatusBean",
        description = "This class carries all information related map statuses of the operations."
)
public class OperationStatusBean {

    @ApiModelProperty(
            name = "operationId",
            value = "Operation Id.",
            required = true
    )
    String operationId;

    @ApiModelProperty(
            name = "status",
            value = "Status of the Operation.",
            required = true
    )
    private Status status;

    public String getOperationId() {
        return operationId;
    }

    public void setOperationId(String operationId) {
        this.operationId = operationId;
    }

    public enum Status {
        NEW, INPROGRESS, COMPLETED, ERROR
    }

    public Status getStatus() {
        return status;
    }

//    public void setStatus(Status status) {
//        this.status = status;
//    }

    public void setStatus(String status) {
        if (Status.NEW.name().equals(status)) {
            this.status = Status.NEW;
        } else if (Status.INPROGRESS.name().equals(status)) {
            this.status = Status.INPROGRESS;
        } else if (Status.COMPLETED.name().equals(status)) {
            this.status = Status.COMPLETED;
        } else if (Status.ERROR.name().equals(status)) {
            this.status = Status.ERROR;
        }
    }
}
