Skip to content

Commit 57edd40

Browse files
committed
Changes in ShippingV2 API models to change type to string
1 parent e75e25d commit 57edd40

24 files changed

+567
-483
lines changed

Source/FikaAmazonAPI/AmazonConnection.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class AmazonConnection
3434
public ServicesService Services => this._Services ?? throw _NoCredentials;
3535
public ShipmentInvoicingService ShipmentInvoicing => this._ShipmentInvoicing ?? throw _NoCredentials;
3636
public ShippingService Shipping => this._Shipping ?? throw _NoCredentials;
37+
public ShippingServiceV2 ShippingV2 => this._ShippingV2 ?? throw _NoCredentials;
3738
public UploadService Upload => this._Upload ?? throw _NoCredentials;
3839
public TokenService Tokens => this._Tokens ?? throw _NoCredentials;
3940
public FulFillmentInboundService FulFillmentInbound => this._FulFillmentInbound ?? throw _NoCredentials;
@@ -69,6 +70,7 @@ public class AmazonConnection
6970
private ServicesService _Services { get; set; }
7071
private ShipmentInvoicingService _ShipmentInvoicing { get; set; }
7172
private ShippingService _Shipping { get; set; }
73+
private ShippingServiceV2 _ShippingV2 { get; set; }
7274
private UploadService _Upload { get; set; }
7375

7476
private TokenService _Tokens { get; set; }
@@ -125,6 +127,7 @@ private void Init(AmazonCredential Credentials)
125127
this._Services = new ServicesService(this.Credentials);
126128
this._ShipmentInvoicing = new ShipmentInvoicingService(this.Credentials);
127129
this._Shipping = new ShippingService(this.Credentials);
130+
this._ShippingV2 = new ShippingServiceV2(this.Credentials);
128131
this._Upload = new UploadService(this.Credentials);
129132
this._Tokens = new TokenService(this.Credentials);
130133
this._FulFillmentInbound = new FulFillmentInboundService(this.Credentials);

Source/FikaAmazonAPI/AmazonCredential.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class AmazonCredential
1919
public bool IsActiveLimitRate { get; set; } = true;
2020
public Environments Environment { get; set; } = Environments.Production;
2121
public int MaxThrottledRetryCount { get; set; } = 3;
22-
public string ShippingBusinessId { get; set; }
22+
public ShippingBusiness? ShippingBusiness { get; set; }
2323

2424
public AmazonCredential()
2525
{

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/CarrierId.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/CarrierName.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/City.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/CountryCode.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 144 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,158 @@
1+
using Newtonsoft.Json;
12
using System;
2-
using System.Text;
3-
using System.Collections;
43
using System.Collections.Generic;
4+
using System.ComponentModel.DataAnnotations;
5+
using System.IO;
56
using System.Runtime.Serialization;
6-
using Newtonsoft.Json;
7+
using System.Text;
78

89
namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
910

10-
/// <summary>
11-
/// The monetary value in the currency indicated, in ISO 4217 standard format.
12-
/// </summary>
13-
[DataContract]
14-
public class Currency {
1511
/// <summary>
16-
/// The monetary value.
12+
/// The total value of all items in the container.
1713
/// </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+
}
2248

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; }
3055

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; }
3162

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+
}
4476

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+
}
5285

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+
}
54158
}

0 commit comments

Comments
 (0)