|
| 1 | +using Newtonsoft.Json; |
1 | 2 | using System;
|
2 |
| -using System.Text; |
3 |
| -using System.Collections; |
4 | 3 | using System.Collections.Generic;
|
| 4 | +using System.ComponentModel.DataAnnotations; |
| 5 | +using System.IO; |
5 | 6 | using System.Runtime.Serialization;
|
6 |
| -using Newtonsoft.Json; |
| 7 | +using System.Text; |
7 | 8 |
|
8 | 9 | namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
|
9 | 10 |
|
10 |
| - /// <summary> |
11 |
| - /// The monetary value in the currency indicated, in ISO 4217 standard format. |
12 |
| - /// </summary> |
13 |
| - [DataContract] |
14 |
| - public class Currency { |
15 | 11 | /// <summary>
|
16 |
| - /// The monetary value. |
| 12 | + /// The total value of all items in the container. |
17 | 13 | /// </summary>
|
18 |
| - /// <value>The monetary value.</value> |
19 |
| - [DataMember(Name="value", EmitDefaultValue=false)] |
20 |
| - [JsonProperty(PropertyName = "value")] |
21 |
| - public decimal? Value { get; set; } |
| 14 | + [DataContract] |
| 15 | + public partial class Currency : IEquatable<Currency>, IValidatableObject |
| 16 | + { |
| 17 | + /// <summary> |
| 18 | + /// Initializes a new instance of the <see cref="Currency" /> class. |
| 19 | + /// </summary> |
| 20 | + [JsonConstructorAttribute] |
| 21 | + public Currency() { } |
| 22 | + /// <summary> |
| 23 | + /// Initializes a new instance of the <see cref="Currency" /> class. |
| 24 | + /// </summary> |
| 25 | + /// <param name="Value">The amount of currency. (required).</param> |
| 26 | + /// <param name="Unit">A 3-character currency code. (required).</param> |
| 27 | + public Currency(decimal? Value = default(decimal?), string Unit = default(string)) |
| 28 | + { |
| 29 | + // to ensure "Value" is required (not null) |
| 30 | + if (Value == null) |
| 31 | + { |
| 32 | + throw new InvalidDataException("Value is a required property for Currency and cannot be null"); |
| 33 | + } |
| 34 | + else |
| 35 | + { |
| 36 | + this.Value = Value; |
| 37 | + } |
| 38 | + // to ensure "Unit" is required (not null) |
| 39 | + if (Unit == null) |
| 40 | + { |
| 41 | + throw new InvalidDataException("Unit is a required property for Currency and cannot be null"); |
| 42 | + } |
| 43 | + else |
| 44 | + { |
| 45 | + this.Unit = Unit; |
| 46 | + } |
| 47 | + } |
22 | 48 |
|
23 |
| - /// <summary> |
24 |
| - /// The ISO 4217 format 3-character currency code. |
25 |
| - /// </summary> |
26 |
| - /// <value>The ISO 4217 format 3-character currency code.</value> |
27 |
| - [DataMember(Name="unit", EmitDefaultValue=false)] |
28 |
| - [JsonProperty(PropertyName = "unit")] |
29 |
| - public string Unit { get; set; } |
| 49 | + /// <summary> |
| 50 | + /// The amount of currency. |
| 51 | + /// </summary> |
| 52 | + /// <value>The amount of currency.</value> |
| 53 | + [DataMember(Name = "value", EmitDefaultValue = false)] |
| 54 | + public decimal? Value { get; set; } |
30 | 55 |
|
| 56 | + /// <summary> |
| 57 | + /// A 3-character currency code. |
| 58 | + /// </summary> |
| 59 | + /// <value>A 3-character currency code.</value> |
| 60 | + [DataMember(Name = "unit", EmitDefaultValue = false)] |
| 61 | + public string Unit { get; set; } |
31 | 62 |
|
32 |
| - /// <summary> |
33 |
| - /// Get the string presentation of the object |
34 |
| - /// </summary> |
35 |
| - /// <returns>String presentation of the object</returns> |
36 |
| - public override string ToString() { |
37 |
| - var sb = new StringBuilder(); |
38 |
| - sb.Append("class Currency {\n"); |
39 |
| - sb.Append(" Value: ").Append(Value).Append("\n"); |
40 |
| - sb.Append(" Unit: ").Append(Unit).Append("\n"); |
41 |
| - sb.Append("}\n"); |
42 |
| - return sb.ToString(); |
43 |
| - } |
| 63 | + /// <summary> |
| 64 | + /// Returns the string presentation of the object |
| 65 | + /// </summary> |
| 66 | + /// <returns>String presentation of the object</returns> |
| 67 | + public override string ToString() |
| 68 | + { |
| 69 | + var sb = new StringBuilder(); |
| 70 | + sb.Append("class Currency {\n"); |
| 71 | + sb.Append(" Value: ").Append(Value).Append("\n"); |
| 72 | + sb.Append(" Unit: ").Append(Unit).Append("\n"); |
| 73 | + sb.Append("}\n"); |
| 74 | + return sb.ToString(); |
| 75 | + } |
44 | 76 |
|
45 |
| - /// <summary> |
46 |
| - /// Get the JSON string presentation of the object |
47 |
| - /// </summary> |
48 |
| - /// <returns>JSON string presentation of the object</returns> |
49 |
| - public string ToJson() { |
50 |
| - return JsonConvert.SerializeObject(this, Formatting.Indented); |
51 |
| - } |
| 77 | + /// <summary> |
| 78 | + /// Returns the JSON string presentation of the object |
| 79 | + /// </summary> |
| 80 | + /// <returns>JSON string presentation of the object</returns> |
| 81 | + public string ToJson() |
| 82 | + { |
| 83 | + return JsonConvert.SerializeObject(this, Formatting.Indented); |
| 84 | + } |
52 | 85 |
|
53 |
| -} |
| 86 | + /// <summary> |
| 87 | + /// Returns true if objects are equal |
| 88 | + /// </summary> |
| 89 | + /// <param name="input">Object to be compared</param> |
| 90 | + /// <returns>Boolean</returns> |
| 91 | + public override bool Equals(object input) |
| 92 | + { |
| 93 | + return this.Equals(input as Currency); |
| 94 | + } |
| 95 | + |
| 96 | + /// <summary> |
| 97 | + /// Returns true if Currency instances are equal |
| 98 | + /// </summary> |
| 99 | + /// <param name="input">Instance of Currency to be compared</param> |
| 100 | + /// <returns>Boolean</returns> |
| 101 | + public bool Equals(Currency input) |
| 102 | + { |
| 103 | + if (input == null) |
| 104 | + return false; |
| 105 | + |
| 106 | + return |
| 107 | + ( |
| 108 | + this.Value == input.Value || |
| 109 | + (this.Value != null && |
| 110 | + this.Value.Equals(input.Value)) |
| 111 | + ) && |
| 112 | + ( |
| 113 | + this.Unit == input.Unit || |
| 114 | + (this.Unit != null && |
| 115 | + this.Unit.Equals(input.Unit)) |
| 116 | + ); |
| 117 | + } |
| 118 | + |
| 119 | + /// <summary> |
| 120 | + /// Gets the hash code |
| 121 | + /// </summary> |
| 122 | + /// <returns>Hash code</returns> |
| 123 | + public override int GetHashCode() |
| 124 | + { |
| 125 | + unchecked // Overflow is fine, just wrap |
| 126 | + { |
| 127 | + int hashCode = 41; |
| 128 | + if (this.Value != null) |
| 129 | + hashCode = hashCode * 59 + this.Value.GetHashCode(); |
| 130 | + if (this.Unit != null) |
| 131 | + hashCode = hashCode * 59 + this.Unit.GetHashCode(); |
| 132 | + return hashCode; |
| 133 | + } |
| 134 | + } |
| 135 | + |
| 136 | + /// <summary> |
| 137 | + /// To validate all properties of the instance |
| 138 | + /// </summary> |
| 139 | + /// <param name="validationContext">Validation context</param> |
| 140 | + /// <returns>Validation Result</returns> |
| 141 | + IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext) |
| 142 | + { |
| 143 | + // Unit (string) maxLength |
| 144 | + if (this.Unit != null && this.Unit.Length > 3) |
| 145 | + { |
| 146 | + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Unit, length must be less than 3.", new[] { "Unit" }); |
| 147 | + } |
| 148 | + |
| 149 | + // Unit (string) minLength |
| 150 | + if (this.Unit != null && this.Unit.Length < 3) |
| 151 | + { |
| 152 | + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Unit, length must be greater than 3.", new[] { "Unit" }); |
| 153 | + } |
| 154 | + |
| 155 | + yield break; |
| 156 | + } |
| 157 | + } |
54 | 158 | }
|
0 commit comments