content: /*
   *     Copyright (C) 2016  Merbin J Anselm <merbinjanselm@gmail.com>
   *
   *     This program is free software; you can redistribute it and/or modify
   *     it under the terms of the GNU General Public License as published by
   *     the Free Software Foundation; either version 2 of the License, or
   *     (at your option) any later version.
   *
   *     This program is distributed in the hope that it will be useful,
   *     but WITHOUT ANY WARRANTY; without even the implied warranty of
   *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *     GNU General Public License for more details.
   *
   *     You should have received a copy of the GNU General Public License along
   *     with this program; if not, write to the Free Software Foundation, Inc.,
   *     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   */
  
  package in.blogspot.anselmbros.torchie.utils.IabUtils;
  
  /**
   * Represents the result of an in-app billing operation.
   * A result is composed of a response code (an integer) and possibly a
   * message (String). You can get those by calling
   * {@link #getResponse} and {@link #getMessage()}, respectively. You
   * can also inquire whether a result is a success or a failure by
   * calling {@link #isSuccess()} and {@link #isFailure()}.
   */
  public class IabResult {
      int mResponse;
      String mMessage;
  
      public IabResult(int response, String message) {
          mResponse = response;
          if (message == null || message.trim().length() == 0) {
              mMessage = IabHelper.getResponseDesc(response);
          } else {
              mMessage = message + " (response: " + IabHelper.getResponseDesc(response) + ")";
          }
      }
  
      public int getResponse() {
          return mResponse;
      }
  
      public String getMessage() {
          return mMessage;
      }
  
      public boolean isSuccess() {
          return mResponse == IabHelper.BILLING_RESPONSE_RESULT_OK;
      }
  
      public boolean isFailure() {
          return !isSuccess();
      }
  
      public String toString() {
          return "IabResult: " + getMessage();
      }
  }
  
  