001/*
002 * Copyright (c) 2011-2017 Nexmo Inc
003 *
004 * Permission is hereby granted, free of charge, to any person obtaining a copy
005 * of this software and associated documentation files (the "Software"), to deal
006 * in the Software without restriction, including without limitation the rights
007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008 * copies of the Software, and to permit persons to whom the Software is
009 * furnished to do so, subject to the following conditions:
010 *
011 * The above copyright notice and this permission notice shall be included in
012 * all copies or substantial portions of the Software.
013 *
014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
020 * THE SOFTWARE.
021 */
022package com.nexmo.client.sms;
023
024
025/**
026 * Represents the result of the reachability check that was performed.
027 * <p>
028 * This is only provided if a reachability check was requested when submitting the message.
029 *
030 * @author  Paul Cook
031 */
032public class SmsSubmissionReachabilityStatus implements java.io.Serializable {
033
034    private static final long serialVersionUID = 8121497095898864184L;
035
036    /**
037     * The reachability status of this messages destination could not be determined
038     */
039    public static final int REACHABILITY_STATUS_UNKNOWN = 0;
040
041    /**
042     * The destination of this message is reachable
043     */
044    public static final int REACHABILITY_STATUS_REACHABLE = 1;
045
046    /**
047     * The destination of this message can not be reached and thus can not be delivered to
048     */
049    public static final int REACHABILITY_STATUS_UNDELIVERABLE = 2;
050
051    /**
052     * The destination of this message is temporarily unavailable (eg, switched off)
053     */
054    public static final int REACHABILITY_STATUS_ABSENT = 3;
055
056    /**
057     * The destination of this message is not a valid destination and thus could not be delivered to
058     */
059    public static final int REACHABILITY_STATUS_BAD_NUMBER = 4;
060
061    private final int status;
062    private final String description;
063
064    protected SmsSubmissionReachabilityStatus(final int status,
065                                              final String description) {
066        this.status = status;
067        this.description = description;
068    }
069
070    /**
071     * @return int status code representing outcome of the reachability check performed on this message
072     */
073    public int getStatus() {
074        return this.status;
075    }
076
077    /**
078     * @return String A description of the outcome of the reachability check performed on this message
079     */
080    public String getDescription() {
081        return this.description;
082    }
083
084    @Override
085    public String toString() {
086        return "REACHABILITY -- STAT [ " + this.status + " ] [ " + this.description + " ] ";
087    }
088
089    @Override
090    public boolean equals(Object obj) {
091        if (obj instanceof  SmsSubmissionReachabilityStatus) {
092            SmsSubmissionReachabilityStatus other = (SmsSubmissionReachabilityStatus)obj;
093            return this.getStatus() == other.getStatus() && this.getDescription().equals(other.getDescription());
094        } else {
095            return false;
096        }
097    }
098}