|
| 1 | +// <auto-generated> |
| 2 | +// Auto-generated by StoneAPI, do not modify. |
| 3 | +// </auto-generated> |
| 4 | + |
| 5 | +namespace Dropbox.Api.Auth |
| 6 | +{ |
| 7 | + using sys = System; |
| 8 | + using col = System.Collections.Generic; |
| 9 | + using re = System.Text.RegularExpressions; |
| 10 | + |
| 11 | + using enc = Dropbox.Api.Stone; |
| 12 | + |
| 13 | + /// <summary> |
| 14 | + /// <para>Error occurred because the app is being rate limited.</para> |
| 15 | + /// </summary> |
| 16 | + public class RateLimitError |
| 17 | + { |
| 18 | + #pragma warning disable 108 |
| 19 | + |
| 20 | + /// <summary> |
| 21 | + /// <para>The encoder instance.</para> |
| 22 | + /// </summary> |
| 23 | + internal static enc.StructEncoder<RateLimitError> Encoder = new RateLimitErrorEncoder(); |
| 24 | + |
| 25 | + /// <summary> |
| 26 | + /// <para>The decoder instance.</para> |
| 27 | + /// </summary> |
| 28 | + internal static enc.StructDecoder<RateLimitError> Decoder = new RateLimitErrorDecoder(); |
| 29 | + |
| 30 | + /// <summary> |
| 31 | + /// <para>Initializes a new instance of the <see cref="RateLimitError" /> class.</para> |
| 32 | + /// </summary> |
| 33 | + /// <param name="reason">The reason why the app is being rate limited.</param> |
| 34 | + /// <param name="retryAfter">The number of seconds that the app should wait before |
| 35 | + /// making another request.</param> |
| 36 | + public RateLimitError(RateLimitReason reason, |
| 37 | + ulong retryAfter = 1) |
| 38 | + { |
| 39 | + if (reason == null) |
| 40 | + { |
| 41 | + throw new sys.ArgumentNullException("reason"); |
| 42 | + } |
| 43 | + |
| 44 | + this.Reason = reason; |
| 45 | + this.RetryAfter = retryAfter; |
| 46 | + } |
| 47 | + |
| 48 | + /// <summary> |
| 49 | + /// <para>Initializes a new instance of the <see cref="RateLimitError" /> class.</para> |
| 50 | + /// </summary> |
| 51 | + /// <remarks>This is to construct an instance of the object when |
| 52 | + /// deserializing.</remarks> |
| 53 | + public RateLimitError() |
| 54 | + { |
| 55 | + this.RetryAfter = 1; |
| 56 | + } |
| 57 | + |
| 58 | + /// <summary> |
| 59 | + /// <para>The reason why the app is being rate limited.</para> |
| 60 | + /// </summary> |
| 61 | + public RateLimitReason Reason { get; protected set; } |
| 62 | + |
| 63 | + /// <summary> |
| 64 | + /// <para>The number of seconds that the app should wait before making another |
| 65 | + /// request.</para> |
| 66 | + /// </summary> |
| 67 | + public ulong RetryAfter { get; protected set; } |
| 68 | + |
| 69 | + #region Encoder class |
| 70 | + |
| 71 | + /// <summary> |
| 72 | + /// <para>Encoder for <see cref="RateLimitError" />.</para> |
| 73 | + /// </summary> |
| 74 | + private class RateLimitErrorEncoder : enc.StructEncoder<RateLimitError> |
| 75 | + { |
| 76 | + /// <summary> |
| 77 | + /// <para>Encode fields of given value.</para> |
| 78 | + /// </summary> |
| 79 | + /// <param name="value">The value.</param> |
| 80 | + /// <param name="writer">The writer.</param> |
| 81 | + public override void EncodeFields(RateLimitError value, enc.IJsonWriter writer) |
| 82 | + { |
| 83 | + WriteProperty("reason", value.Reason, writer, Dropbox.Api.Auth.RateLimitReason.Encoder); |
| 84 | + WriteProperty("retry_after", value.RetryAfter, writer, enc.UInt64Encoder.Instance); |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + #endregion |
| 89 | + |
| 90 | + |
| 91 | + #region Decoder class |
| 92 | + |
| 93 | + /// <summary> |
| 94 | + /// <para>Decoder for <see cref="RateLimitError" />.</para> |
| 95 | + /// </summary> |
| 96 | + private class RateLimitErrorDecoder : enc.StructDecoder<RateLimitError> |
| 97 | + { |
| 98 | + /// <summary> |
| 99 | + /// <para>Create a new instance of type <see cref="RateLimitError" />.</para> |
| 100 | + /// </summary> |
| 101 | + /// <returns>The struct instance.</returns> |
| 102 | + protected override RateLimitError Create() |
| 103 | + { |
| 104 | + return new RateLimitError(); |
| 105 | + } |
| 106 | + |
| 107 | + /// <summary> |
| 108 | + /// <para>Set given field.</para> |
| 109 | + /// </summary> |
| 110 | + /// <param name="value">The field value.</param> |
| 111 | + /// <param name="fieldName">The field name.</param> |
| 112 | + /// <param name="reader">The json reader.</param> |
| 113 | + protected override void SetField(RateLimitError value, string fieldName, enc.IJsonReader reader) |
| 114 | + { |
| 115 | + switch (fieldName) |
| 116 | + { |
| 117 | + case "reason": |
| 118 | + value.Reason = Dropbox.Api.Auth.RateLimitReason.Decoder.Decode(reader); |
| 119 | + break; |
| 120 | + case "retry_after": |
| 121 | + value.RetryAfter = enc.UInt64Decoder.Instance.Decode(reader); |
| 122 | + break; |
| 123 | + default: |
| 124 | + reader.Skip(); |
| 125 | + break; |
| 126 | + } |
| 127 | + } |
| 128 | + } |
| 129 | + |
| 130 | + #endregion |
| 131 | + } |
| 132 | +} |
0 commit comments