All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.atkawa7.kannel.sms.SendStatus Maven / Gradle / Ivy

package io.github.atkawa7.kannel.sms;

/**
 * The returned status of an SMS sent to the smsbox.
 *
 * @author Garth Patil {@literal }
 */
public class SendStatus {

    private final int status;
    private final String message;
    private int httpStatus;

    private SendStatus(int status, String message) {
        this.status = status;
        this.message = message;
    }

    public static SendStatus parse(String response) throws Exception {
        if (response.contains(":")) {
            String[] s = response.split(":");
            return new SendStatus(Integer.parseInt(s[0]), s[1].trim());
        } else {
            throw new ParseException("Unable to parse response: " + response);
        }
    }

    public int getStatus() {
        return this.status;
    }

    public String getMessage() {
        return this.message;
    }

    public int getHttpStatus() {
        return this.httpStatus;
    }

    public void setHttpStatus(int httpStatus) {
        this.httpStatus = httpStatus;
    }

    public String toString() {
        StringBuilder o = new StringBuilder();
        o.append("Status: ").append(status).append(", Message: ").append(message).append(", HTTP: ").append(httpStatus);
        return o.toString();
    }


    public static class ParseException extends RuntimeException {
        public ParseException(String message) {
            super(message);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy