// <auto-generated>
// Auto-generated by StoneAPI, do not modify.
// </auto-generated>

namespace Dropbox.Api.Sharing
{
    using sys = System;
    using col = System.Collections.Generic;
    using re = System.Text.RegularExpressions;

    using enc = Dropbox.Api.Stone;

    /// <summary>
    /// <para>The list folder members cursor arg object</para>
    /// </summary>
    /// <seealso cref="ListFolderMembersArgs" />
    public class ListFolderMembersCursorArg
    {
        #pragma warning disable 108

        /// <summary>
        /// <para>The encoder instance.</para>
        /// </summary>
        internal static enc.StructEncoder<ListFolderMembersCursorArg> Encoder = new ListFolderMembersCursorArgEncoder();

        /// <summary>
        /// <para>The decoder instance.</para>
        /// </summary>
        internal static enc.StructDecoder<ListFolderMembersCursorArg> Decoder = new ListFolderMembersCursorArgDecoder();

        /// <summary>
        /// <para>Initializes a new instance of the <see cref="ListFolderMembersCursorArg" />
        /// class.</para>
        /// </summary>
        /// <param name="actions">This is a list indicating whether each returned member will
        /// include a boolean value <see cref="Dropbox.Api.Sharing.MemberPermission.Allow" />
        /// that describes whether the current user can perform the MemberAction on the
        /// member.</param>
        /// <param name="limit">The maximum number of results that include members, groups and
        /// invitees to return per request.</param>
        public ListFolderMembersCursorArg(col.IEnumerable<MemberAction> actions = null,
                                          uint limit = 1000)
        {
            var actionsList = enc.Util.ToList(actions);

            if (limit < 1U)
            {
                throw new sys.ArgumentOutOfRangeException("limit", "Value should be greater or equal than 1");
            }
            if (limit > 1000U)
            {
                throw new sys.ArgumentOutOfRangeException("limit", "Value should be less of equal than 1000");
            }

            this.Actions = actionsList;
            this.Limit = limit;
        }

        /// <summary>
        /// <para>Initializes a new instance of the <see cref="ListFolderMembersCursorArg" />
        /// class.</para>
        /// </summary>
        /// <remarks>This is to construct an instance of the object when
        /// deserializing.</remarks>
        public ListFolderMembersCursorArg()
        {
            this.Limit = 1000;
        }

        /// <summary>
        /// <para>This is a list indicating whether each returned member will include a boolean
        /// value <see cref="Dropbox.Api.Sharing.MemberPermission.Allow" /> that describes
        /// whether the current user can perform the MemberAction on the member.</para>
        /// </summary>
        public col.IList<MemberAction> Actions { get; protected set; }

        /// <summary>
        /// <para>The maximum number of results that include members, groups and invitees to
        /// return per request.</para>
        /// </summary>
        public uint Limit { get; protected set; }

        #region Encoder class

        /// <summary>
        /// <para>Encoder for  <see cref="ListFolderMembersCursorArg" />.</para>
        /// </summary>
        private class ListFolderMembersCursorArgEncoder : enc.StructEncoder<ListFolderMembersCursorArg>
        {
            /// <summary>
            /// <para>Encode fields of given value.</para>
            /// </summary>
            /// <param name="value">The value.</param>
            /// <param name="writer">The writer.</param>
            public override void EncodeFields(ListFolderMembersCursorArg value, enc.IJsonWriter writer)
            {
                if (value.Actions.Count > 0)
                {
                    WriteListProperty("actions", value.Actions, writer, Dropbox.Api.Sharing.MemberAction.Encoder);
                }
                WriteProperty("limit", value.Limit, writer, enc.UInt32Encoder.Instance);
            }
        }

        #endregion


        #region Decoder class

        /// <summary>
        /// <para>Decoder for  <see cref="ListFolderMembersCursorArg" />.</para>
        /// </summary>
        private class ListFolderMembersCursorArgDecoder : enc.StructDecoder<ListFolderMembersCursorArg>
        {
            /// <summary>
            /// <para>Create a new instance of type <see cref="ListFolderMembersCursorArg"
            /// />.</para>
            /// </summary>
            /// <returns>The struct instance.</returns>
            protected override ListFolderMembersCursorArg Create()
            {
                return new ListFolderMembersCursorArg();
            }

            /// <summary>
            /// <para>Set given field.</para>
            /// </summary>
            /// <param name="value">The field value.</param>
            /// <param name="fieldName">The field name.</param>
            /// <param name="reader">The json reader.</param>
            protected override void SetField(ListFolderMembersCursorArg value, string fieldName, enc.IJsonReader reader)
            {
                switch (fieldName)
                {
                    case "actions":
                        value.Actions = ReadList<MemberAction>(reader, Dropbox.Api.Sharing.MemberAction.Decoder);
                        break;
                    case "limit":
                        value.Limit = enc.UInt32Decoder.Instance.Decode(reader);
                        break;
                    default:
                        reader.Skip();
                        break;
                }
            }
        }

        #endregion
    }
}
