Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 97 additions & 10 deletions Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,145 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations;

namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2
{

/// <summary>
/// A tracking event.
/// </summary>
[DataContract]
public class Event {
public partial class Event : IEquatable<Event>, IValidatableObject
{
/// <summary>
/// Gets or Sets EventCode
/// </summary>
[DataMember(Name="eventCode", EmitDefaultValue=false)]
[DataMember(Name = "eventCode", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "eventCode")]
public EventCode EventCode { get; set; }
public EventCode? EventCode { get; set; }

/// <summary>
/// Gets or Sets Location
/// </summary>
[DataMember(Name="location", EmitDefaultValue=false)]
[DataMember(Name = "location", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "location")]
public Location Location { get; set; }

/// <summary>
/// The ISO 8601 formatted timestamp of the event.
/// </summary>
/// <value>The ISO 8601 formatted timestamp of the event.</value>
[DataMember(Name="eventTime", EmitDefaultValue=false)]
[DataMember(Name = "eventTime", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "eventTime")]
public DateTime? EventTime { get; set; }

/// <summary>
/// Gets or Sets ShipmentType
/// </summary>
[DataMember(Name = "shipmentType", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "shipmentType", NullValueHandling = NullValueHandling.Ignore)]
public ShipmentType? ShipmentType { get; set; }


/// <summary>
/// Get the string presentation of the object
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString() {
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class Event {\n");
sb.Append(" EventCode: ").Append(EventCode).Append("\n");
sb.Append(" Location: ").Append(Location).Append("\n");
sb.Append(" EventTime: ").Append(EventTime).Append("\n");
sb.Append(" ShipmentType: ").Append(ShipmentType).Append("\n");
sb.Append("}\n");
return sb.ToString();
}

/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="input">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object input)
{
return this.Equals(input as Event);
}

/// <summary>
/// Returns true if ModelEvent instances are equal
/// </summary>
/// <param name="input">Instance of ModelEvent to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(Event input)
{
if (input == null)
return false;

return
(
this.EventCode == input.EventCode ||
(this.EventCode != null &&
this.EventCode.Equals(input.EventCode))
) &&
(
this.Location == input.Location ||
(this.Location != null &&
this.Location.Equals(input.Location))
) &&
(
this.EventTime == input.EventTime ||
(this.EventTime != null &&
this.EventTime.Equals(input.EventTime))
) &&
(
this.ShipmentType == input.ShipmentType ||
(this.ShipmentType != null &&
this.ShipmentType.Equals(input.ShipmentType))
);
}

/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
int hashCode = 41;
if (this.EventCode != null)
hashCode = hashCode * 59 + this.EventCode.GetHashCode();
if (this.Location != null)
hashCode = hashCode * 59 + this.Location.GetHashCode();
if (this.EventTime != null)
hashCode = hashCode * 59 + this.EventTime.GetHashCode();
if (this.ShipmentType != null)
hashCode = hashCode * 59 + this.ShipmentType.GetHashCode();
return hashCode;
}
}

/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}

/// <summary>
/// Get the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson() {
public string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}

}
}
}
101 changes: 83 additions & 18 deletions Source/FikaAmazonAPI/AmazonSpApiSDK/Models/ShippingV2/EventCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,98 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {
namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2
{

/// <summary>
/// The tracking event type.
/// </summary>
[DataContract]
public class EventCode {

/// <summary>
/// The tracking event type.
/// </summary>
/// <value>The tracking event type.</value>
[JsonConverter(typeof(StringEnumConverter))]
public enum EventCode
{
/// <summary>
/// Get the string presentation of the object
/// Enum ReadyForReceive for value: ReadyForReceive
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString() {
var sb = new StringBuilder();
sb.Append("class EventCode {\n");
sb.Append("}\n");
return sb.ToString();
}

[EnumMember(Value = "ReadyForReceive")]
ReadyForReceive = 1,
/// <summary>
/// Enum PickupDone for value: PickupDone
/// </summary>
[EnumMember(Value = "PickupDone")]
PickupDone = 2,
/// <summary>
/// Enum Delivered for value: Delivered
/// </summary>
[EnumMember(Value = "Delivered")]
Delivered = 3,
/// <summary>
/// Enum Departed for value: Departed
/// </summary>
[EnumMember(Value = "Departed")]
Departed = 4,
/// <summary>
/// Enum DeliveryAttempted for value: DeliveryAttempted
/// </summary>
[EnumMember(Value = "DeliveryAttempted")]
DeliveryAttempted = 5,
/// <summary>
/// Enum Lost for value: Lost
/// </summary>
[EnumMember(Value = "Lost")]
Lost = 6,
/// <summary>
/// Enum OutForDelivery for value: OutForDelivery
/// </summary>
[EnumMember(Value = "OutForDelivery")]
OutForDelivery = 7,
/// <summary>
/// Enum ArrivedAtCarrierFacility for value: ArrivedAtCarrierFacility
/// </summary>
[EnumMember(Value = "ArrivedAtCarrierFacility")]
ArrivedAtCarrierFacility = 8,
/// <summary>
/// Enum Rejected for value: Rejected
/// </summary>
[EnumMember(Value = "Rejected")]
Rejected = 9,
/// <summary>
/// Enum Undeliverable for value: Undeliverable
/// </summary>
[EnumMember(Value = "Undeliverable")]
Undeliverable = 10,
/// <summary>
/// Enum PickupCancelled for value: PickupCancelled
/// </summary>
[EnumMember(Value = "PickupCancelled")]
PickupCancelled = 11,
/// <summary>
/// Enum ReturnInitiated for value: ReturnInitiated
/// </summary>
[EnumMember(Value = "ReturnInitiated")]
ReturnInitiated = 12,
/// <summary>
/// Enum AvailableForPickup for value: AvailableForPickup
/// </summary>
[EnumMember(Value = "AvailableForPickup")]
AvailableForPickup = 13,
/// <summary>
/// Enum RecipientRequestedAlternateDeliveryTiming for value: RecipientRequestedAlternateDeliveryTiming
/// </summary>
[EnumMember(Value = "RecipientRequestedAlternateDeliveryTiming")]
RecipientRequestedAlternateDeliveryTiming = 14,
/// <summary>
/// Get the JSON string presentation of the object
/// Enum PackageReceivedByCarrier for value: PackageReceivedByCarrier
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson() {
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
[EnumMember(Value = "PackageReceivedByCarrier")]
PackageReceivedByCarrier = 15
}

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ShippingV2 {

/// <summary>
/// Shipment type.
/// </summary>
/// <value>Shipment type.</value>
[JsonConverter(typeof(StringEnumConverter))]
public enum ShipmentType
{

[EnumMember(Value = "FORWARD")]
FORWARD = 1,

[EnumMember(Value = "RETURNS")]
RETURNS = 2
}

}

11 changes: 11 additions & 0 deletions Source/FikaAmazonAPI/Services/ShippingServiceV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,16 @@ public async Task<GetTrackingResult> GetTrackingAsync(string carrierId, string t
return response.Payload;
return null;
}

public GetShipmentDocumentsResult GetShipmentDocuments(string shipmentId, string packageClientReferenceId, string format) =>
Task.Run(() => GetShipmentDocumentsAsync(shipmentId, packageClientReferenceId, format)).ConfigureAwait(false).GetAwaiter().GetResult();
public async Task<GetShipmentDocumentsResult> GetShipmentDocumentsAsync(string shipmentId, string packageClientReferenceId, string format, CancellationToken cancellationToken = default)
{
await CreateAuthorizedRequestAsync(ShippingApiV2Urls.GetShipmentDocuments(shipmentId, packageClientReferenceId, format), RestSharp.Method.Get, cancellationToken: cancellationToken);
var response = await ExecuteRequestAsync<GetShipmentDocumentsResponse>(RateLimitType.ShippingV2_GetShipmentDocument, cancellationToken);
if (response != null && response.Payload != null)
return response.Payload;
return null;
}
}
}
Loading