// Copyright (c) 2017 Jan Pluskal, Viliam Letavay
//
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.

/**
 * Autogenerated by Thrift Compiler (0.9.3)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
using System;
using System.Text;
using Thrift.Protocol;

namespace Netfox.SnooperMessenger.Protocol
{

  #if !SILVERLIGHT
  [Serializable]
  #endif
  public partial class MNMessagesSyncFailedSend : TBase
  {
    private long _OfflineThreadingId;
    private string _ErrorMessage;
    private bool _IsRetryable;
    private int _ErrorCode;

    public long OfflineThreadingId
    {
      get
      {
        return _OfflineThreadingId;
      }
      set
      {
        __isset.OfflineThreadingId = true;
        this._OfflineThreadingId = value;
      }
    }

    public string ErrorMessage
    {
      get
      {
        return _ErrorMessage;
      }
      set
      {
        __isset.ErrorMessage = true;
        this._ErrorMessage = value;
      }
    }

    public bool IsRetryable
    {
      get
      {
        return _IsRetryable;
      }
      set
      {
        __isset.IsRetryable = true;
        this._IsRetryable = value;
      }
    }

    public int ErrorCode
    {
      get
      {
        return _ErrorCode;
      }
      set
      {
        __isset.ErrorCode = true;
        this._ErrorCode = value;
      }
    }


    public Isset __isset;
    #if !SILVERLIGHT
    [Serializable]
    #endif
    public struct Isset {
      public bool OfflineThreadingId;
      public bool ErrorMessage;
      public bool IsRetryable;
      public bool ErrorCode;
    }

    public MNMessagesSyncFailedSend() {
    }

    public void Read (TProtocol iprot)
    {
      iprot.IncrementRecursionDepth();
      try
      {
        TField field;
        iprot.ReadStructBegin();
        while (true)
        {
          field = iprot.ReadFieldBegin();
          if (field.Type == TType.Stop) { 
            break;
          }
          switch (field.ID)
          {
            case 1:
              if (field.Type == TType.I64) {
                OfflineThreadingId = iprot.ReadI64();
              } else { 
                TProtocolUtil.Skip(iprot, field.Type);
              }
              break;
            case 2:
              if (field.Type == TType.String) {
                ErrorMessage = iprot.ReadString();
              } else { 
                TProtocolUtil.Skip(iprot, field.Type);
              }
              break;
            case 3:
              if (field.Type == TType.Bool) {
                IsRetryable = iprot.ReadBool();
              } else { 
                TProtocolUtil.Skip(iprot, field.Type);
              }
              break;
            case 4:
              if (field.Type == TType.I32) {
                ErrorCode = iprot.ReadI32();
              } else { 
                TProtocolUtil.Skip(iprot, field.Type);
              }
              break;
            default: 
              TProtocolUtil.Skip(iprot, field.Type);
              break;
          }
          iprot.ReadFieldEnd();
        }
        iprot.ReadStructEnd();
      }
      finally
      {
        iprot.DecrementRecursionDepth();
      }
    }

    public void Write(TProtocol oprot) {
      oprot.IncrementRecursionDepth();
      try
      {
        TStruct struc = new TStruct("MNMessagesSyncFailedSend");
        oprot.WriteStructBegin(struc);
        TField field = new TField();
        if (__isset.OfflineThreadingId) {
          field.Name = "OfflineThreadingId";
          field.Type = TType.I64;
          field.ID = 1;
          oprot.WriteFieldBegin(field);
          oprot.WriteI64(OfflineThreadingId);
          oprot.WriteFieldEnd();
        }
        if (ErrorMessage != null && __isset.ErrorMessage) {
          field.Name = "ErrorMessage";
          field.Type = TType.String;
          field.ID = 2;
          oprot.WriteFieldBegin(field);
          oprot.WriteString(ErrorMessage);
          oprot.WriteFieldEnd();
        }
        if (__isset.IsRetryable) {
          field.Name = "IsRetryable";
          field.Type = TType.Bool;
          field.ID = 3;
          oprot.WriteFieldBegin(field);
          oprot.WriteBool(IsRetryable);
          oprot.WriteFieldEnd();
        }
        if (__isset.ErrorCode) {
          field.Name = "ErrorCode";
          field.Type = TType.I32;
          field.ID = 4;
          oprot.WriteFieldBegin(field);
          oprot.WriteI32(ErrorCode);
          oprot.WriteFieldEnd();
        }
        oprot.WriteFieldStop();
        oprot.WriteStructEnd();
      }
      finally
      {
        oprot.DecrementRecursionDepth();
      }
    }

    public override string ToString() {
      StringBuilder __sb = new StringBuilder("MNMessagesSyncFailedSend(");
      bool __first = true;
      if (__isset.OfflineThreadingId) {
        if(!__first) { __sb.Append(", "); }
        __first = false;
        __sb.Append("OfflineThreadingId: ");
        __sb.Append(OfflineThreadingId);
      }
      if (ErrorMessage != null && __isset.ErrorMessage) {
        if(!__first) { __sb.Append(", "); }
        __first = false;
        __sb.Append("ErrorMessage: ");
        __sb.Append(ErrorMessage);
      }
      if (__isset.IsRetryable) {
        if(!__first) { __sb.Append(", "); }
        __first = false;
        __sb.Append("IsRetryable: ");
        __sb.Append(IsRetryable);
      }
      if (__isset.ErrorCode) {
        if(!__first) { __sb.Append(", "); }
        __first = false;
        __sb.Append("ErrorCode: ");
        __sb.Append(ErrorCode);
      }
      __sb.Append(")");
      return __sb.ToString();
    }

  }

}
