Skip to content

Commit

Permalink
Merge pull request #623 from arslanon/main
Browse files Browse the repository at this point in the history
  • Loading branch information
abuzuhri authored Jul 24, 2023
2 parents 95feec3 + 8dedba3 commit 85e9700
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
18 changes: 18 additions & 0 deletions Source/FikaAmazonAPI.SampleCode/FeedsSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,24 @@ public void CartonContentsRequestFeed()
GetFeedDetails(feedID);
}

public void SubmitFeedEasyShipDocument()
{
ConstructFeedService createDocument = new ConstructFeedService("{sellerId}", "1.02");
var list = new List<EasyShipDocumentMessage>();
list.Add(new EasyShipDocumentMessage()
{
AmazonOrderID = "AMZ1234567890123",
DocumentTypes = new List<EasyShipDocumentType>() {
EasyShipDocumentType.ShippingLabel
}
});
createDocument.AddEasyShipDocumentMessage(list);
var xml = createDocument.GetXML();

var feedID = amazonConnection.Feed.SubmitFeed(xml, FeedType.POST_EASYSHIP_DOCUMENTS);
GetFeedDetails(feedID);
}

private void GetFeedDetails(string feedID)
{
string ResultFeedDocumentId = string.Empty;
Expand Down
2 changes: 2 additions & 0 deletions Source/FikaAmazonAPI/ConstructFeed/BaseMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class BaseMessage
public PendingOrderReportMessage PendingOrderReport { get; set; }
public PurchaseConfirmationMessage PurchaseConfirmation { get; set; }
public SalesAdjustmentMessage SalesAdjustment { get; set; }
public EasyShipDocumentMessage EasyShipDocument { get; set; }


[XmlIgnore]
Expand Down Expand Up @@ -118,6 +119,7 @@ public class BaseMessage
[XmlIgnore] public bool PendingOrderReportSpecified { get { return PendingOrderReport != null; } }
[XmlIgnore] public bool PurchaseConfirmationSpecified { get { return PurchaseConfirmation != null; } }
[XmlIgnore] public bool SalesAdjustmentSpecified { get { return SalesAdjustment != null; } }
[XmlIgnore] public bool EasyShipDocumentSpecified { get { return EasyShipDocument != null; } }



Expand Down
17 changes: 17 additions & 0 deletions Source/FikaAmazonAPI/ConstructFeed/ConstructFeedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,23 @@ public void AddProductImageMessage(IList<ProductImageMessage> messages, Constant
envelope.MessageType = Utils.Constants.FeedMessageType.ProductImage;
}

public void AddEasyShipDocumentMessage(IList<EasyShipDocumentMessage> messages, Constants.OperationType operationType = Constants.OperationType.Update)
{
var msgs = new List<BaseMessage>();
int index = 1;
foreach (var itm in messages)
{
msgs.Add(new BaseMessage()
{
MessageID = index++,
EasyShipDocument = itm,
OperationType = operationType
});
}
envelope.Message = msgs;
envelope.MessageType = Utils.Constants.FeedMessageType.EasyShipDocument;
}

public string GetXML()
{
return LinqHelper.SerializeObject(envelope);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Collections.Generic;
using System.Xml.Serialization;

namespace FikaAmazonAPI.ConstructFeed.Messages
{
/// <summary>
/// https://developer-docs.amazon.com/sp-api/docs/easyship-api-v2022-03-23-use-case-guide#step-1-submit-an-easy-ship-feed-request
/// </summary>
public class EasyShipDocumentMessage : BaseMessage
{
public EasyShipDocumentMessage() {}
[XmlElement(ElementName = "AmazonOrderID")]
public string AmazonOrderID { get; set; } = null!;
[XmlElement(ElementName = "DocumentType")]
public List<EasyShipDocumentType> DocumentTypes { get; set; }
}

public enum EasyShipDocumentType
{
ShippingLabel,
Invoice,
Warranty,
}
}
3 changes: 2 additions & 1 deletion Source/FikaAmazonAPI/Utils/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,8 @@ public enum FeedMessageType
Store,
StoreStockMovement,
WebstoreItem,
CartonContentsRequest
CartonContentsRequest,
EasyShipDocument,
}

[JsonConverter(typeof(StringEnumConverter))]
Expand Down

0 comments on commit 85e9700

Please sign in to comment.