Skip to content

Commit

Permalink
Merge pull request #18 from J-W-Chan/main
Browse files Browse the repository at this point in the history
fix messageing api and finanical api
  • Loading branch information
abuzuhri authored Nov 19, 2021
2 parents 4d178e1 + 92fd41b commit 7f29ebc
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 19 deletions.
104 changes: 104 additions & 0 deletions Source/FikaAmazonAPI/AmazonSpApiSDK/Models/Messaging/Embedded.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Text;

namespace FikaAmazonAPI.AmazonSpApiSDK.Models.Messaging
{
[DataContract]
public partial class Embedded : IEquatable<Embedded>, IValidatableObject
{
/// <summary>
/// Gets or Sets Embedded
/// </summary>
[DataMember(Name = "actions", EmitDefaultValue = false)]
public IList<GetMessagingActionResponse> ActionList { get; set; }

public Embedded()
{
this.ActionList = default(IList<GetMessagingActionResponse>);
}

public Embedded(IList<GetMessagingActionResponse> actionList = default(IList<GetMessagingActionResponse>))
{
this.ActionList = actionList;
}

/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class Embedded {\n");
sb.Append(" actions: ").Append(ActionList).Append("\n");
sb.Append("}\n");
return sb.ToString();
}

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

/// <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 Embedded);
}

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

return
(
this.ActionList == input.ActionList ||
(this.ActionList != null &&
this.ActionList.Equals(input.ActionList))
);
}

/// <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.ActionList != null)
hashCode = hashCode * 59 + this.ActionList.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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public partial class GetMessagingActionsForOrderResponse : IEquatable<GetMessag
/// <param name="links">links.</param>
/// <param name="embedded">embedded.</param>
/// <param name="errors">errors.</param>
public GetMessagingActionsForOrderResponse(GetMessagingActionsForOrderResponseLinks links = default(GetMessagingActionsForOrderResponseLinks), IList<GetMessagingActionResponse> embedded = default(IList<GetMessagingActionResponse>))
public GetMessagingActionsForOrderResponse(GetMessagingActionsForOrderResponseLinks links = default(GetMessagingActionsForOrderResponseLinks), Embedded embedded = default(Embedded))
{
this.Links = links;
this.Embedded = embedded;
}
public GetMessagingActionsForOrderResponse()
{
this.Links = default(GetMessagingActionsForOrderResponseLinks);
this.Embedded = default(IList<GetMessagingActionResponse>);
this.Embedded = default(Embedded);
}

/// <summary>
Expand All @@ -56,7 +56,7 @@ public GetMessagingActionsForOrderResponse()
/// Gets or Sets Embedded
/// </summary>
[DataMember(Name="_embedded", EmitDefaultValue=false)]
public IList<GetMessagingActionResponse> Embedded { get; set; }
public Embedded Embedded { get; set; }

/// <summary>
/// Gets or Sets Errors
Expand Down
4 changes: 2 additions & 2 deletions Source/FikaAmazonAPI/Services/ApiUrls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ protected class MessaginApiUrls
{
private readonly static string _resourceBaseUrl = "/messaging/v1";

public static string GetMessagingActionsForOrder(string amazonOrderId, string marketplaceIds) => $"{_resourceBaseUrl}/orders/{amazonOrderId}?marketplaceIds={marketplaceIds}";
public static string GetMessagingActionsForOrder(string amazonOrderId) => $"{_resourceBaseUrl}/orders/{amazonOrderId}";
public static string ConfirmCustomizationDetails(string amazonOrderId) => $"{_resourceBaseUrl}/orders/{amazonOrderId}/messages/confirmCustomizationDetails";
public static string CreateConfirmDeliveryDetails(string amazonOrderId) => $"{_resourceBaseUrl}/orders/{amazonOrderId}/messages/confirmDeliveryDetails";
public static string CreateLegalDisclosure(string amazonOrderId) => $"{_resourceBaseUrl}/orders/{amazonOrderId}/messages/legalDisclosure";
Expand Down Expand Up @@ -328,7 +328,7 @@ public static string ListFinancialEventGroups
public static string ListFinancialEventsByOrderId(string orderId) => $"{_resourceBaseUrl}/orders/{orderId}/financialEvents";
public static string ListFinancialEvents
{
get => $"{_resourceBaseUrl}/listFinancialEvents";
get => $"{_resourceBaseUrl}/financialEvents";
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/FikaAmazonAPI/Services/FinancialService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public IList<FinancialEvents> ListFinancialEvents(ParameterListFinancialEvents p

var parameter = parameterListFinancials.getParameters();

CreateAuthorizedRequest(FinanceApiUrls.ListFinancialEventGroups, RestSharp.Method.GET, parameter);
CreateAuthorizedRequest(FinanceApiUrls.ListFinancialEvents, RestSharp.Method.GET, parameter);
var response = ExecuteRequest<ListFinancialEventsResponse>();

list.Add(response.Payload.FinancialEvents);
Expand All @@ -97,7 +97,7 @@ private ListFinancialEventsPayload GetFinancialEventsByNextToken(string nextToke
queryParameters.Add(new KeyValuePair<string, string>("NextToken", nextToken));


CreateAuthorizedRequest(FinanceApiUrls.ListFinancialEventGroups, RestSharp.Method.GET, queryParameters);
CreateAuthorizedRequest(FinanceApiUrls.ListFinancialEvents, RestSharp.Method.GET, queryParameters);
var response = ExecuteRequest<ListFinancialEventsResponse>();
return response.Payload;
}
Expand Down
27 changes: 15 additions & 12 deletions Source/FikaAmazonAPI/Services/MessagingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ public MessagingService(AmazonCredential amazonCredential) : base(amazonCredenti

public GetMessagingActionsForOrderResponse GetMessagingActionsForOrder(string amazonOrderId)
{
CreateAuthorizedRequest(MessaginApiUrls.GetMessagingActionsForOrder(amazonOrderId, MarketPlace.ID), RestSharp.Method.GET);
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
queryParameters.Add(new KeyValuePair<string, string>("marketplaceIds", MarketPlace.ID));

CreateAuthorizedRequest(MessaginApiUrls.GetMessagingActionsForOrder(amazonOrderId), RestSharp.Method.GET, queryParameters);

var response = ExecuteRequest<GetMessagingActionsForOrderResponse>();

Expand All @@ -27,7 +30,7 @@ public bool ConfirmCustomizationDetails(string amazonOrderId, CreateConfirmCusto
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
queryParameters.Add(new KeyValuePair<string, string>("marketplaceIds", MarketPlace.ID));

CreateAuthorizedRequest(MessaginApiUrls.ConfirmCustomizationDetails(amazonOrderId), RestSharp.Method.POST, queryParameters,postJsonObj: createConfirmCustomizationDetailsRequest);
CreateAuthorizedRequest(MessaginApiUrls.ConfirmCustomizationDetails(amazonOrderId), RestSharp.Method.POST, queryParameters, postJsonObj: createConfirmCustomizationDetailsRequest);

var response = ExecuteRequest<CreateConfirmCustomizationDetailsResponse>();
if (response != null)
Expand All @@ -40,21 +43,21 @@ public bool CreateConfirmDeliveryDetails(string amazonOrderId, CreateConfirmCust
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
queryParameters.Add(new KeyValuePair<string, string>("marketplaceIds", MarketPlace.ID));

CreateAuthorizedRequest(MessaginApiUrls.CreateConfirmDeliveryDetails(amazonOrderId), RestSharp.Method.POST, queryParameters,postJsonObj: createConfirmCustomizationDetailsRequest);
CreateAuthorizedRequest(MessaginApiUrls.CreateConfirmDeliveryDetails(amazonOrderId), RestSharp.Method.POST, queryParameters, postJsonObj: createConfirmCustomizationDetailsRequest);

var response = ExecuteRequest<CreateConfirmCustomizationDetailsResponse>();
if (response != null)
return true;
return false;

}

public bool CreateLegalDisclosure(string amazonOrderId, CreateLegalDisclosureRequest createLegalDisclosureRequest)
{
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
queryParameters.Add(new KeyValuePair<string, string>("marketplaceIds", MarketPlace.ID));

CreateAuthorizedRequest(MessaginApiUrls.CreateLegalDisclosure(amazonOrderId), RestSharp.Method.POST, queryParameters,postJsonObj: createLegalDisclosureRequest);
CreateAuthorizedRequest(MessaginApiUrls.CreateLegalDisclosure(amazonOrderId), RestSharp.Method.POST, queryParameters, postJsonObj: createLegalDisclosureRequest);

var response = ExecuteRequest<CreateLegalDisclosureResponse>();
if (response != null)
Expand All @@ -80,7 +83,7 @@ public bool CreateConfirmOrderDetails(string amazonOrderId, CreateConfirmOrderDe
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
queryParameters.Add(new KeyValuePair<string, string>("marketplaceIds", MarketPlace.ID));

CreateAuthorizedRequest(MessaginApiUrls.CreateConfirmOrderDetails(amazonOrderId), RestSharp.Method.POST, queryParameters,postJsonObj: createConfirmOrderDetailsRequest);
CreateAuthorizedRequest(MessaginApiUrls.CreateConfirmOrderDetails(amazonOrderId), RestSharp.Method.POST, queryParameters, postJsonObj: createConfirmOrderDetailsRequest);

var response = ExecuteRequest<CreateConfirmOrderDetailsResponse>();
if (response != null)
Expand All @@ -93,7 +96,7 @@ public bool CreateConfirmServiceDetails(string amazonOrderId, CreateConfirmServi
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
queryParameters.Add(new KeyValuePair<string, string>("marketplaceIds", MarketPlace.ID));

CreateAuthorizedRequest(MessaginApiUrls.CreateConfirmServiceDetails(amazonOrderId), RestSharp.Method.POST, queryParameters,postJsonObj: createConfirmServiceDetailsRequest);
CreateAuthorizedRequest(MessaginApiUrls.CreateConfirmServiceDetails(amazonOrderId), RestSharp.Method.POST, queryParameters, postJsonObj: createConfirmServiceDetailsRequest);

var response = ExecuteRequest<CreateConfirmOrderDetailsResponse>();
if (response != null)
Expand All @@ -105,7 +108,7 @@ public bool CreateAmazonMotors(string amazonOrderId, CreateAmazonMotorsRequest c
{
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
queryParameters.Add(new KeyValuePair<string, string>("marketplaceIds", MarketPlace.ID));
CreateAuthorizedRequest(MessaginApiUrls.CreateAmazonMotors(amazonOrderId), RestSharp.Method.POST, queryParameters,postJsonObj: createAmazonMotorsRequest);
CreateAuthorizedRequest(MessaginApiUrls.CreateAmazonMotors(amazonOrderId), RestSharp.Method.POST, queryParameters, postJsonObj: createAmazonMotorsRequest);

var response = ExecuteRequest<CreateConfirmOrderDetailsResponse>();
if (response != null)
Expand All @@ -116,7 +119,7 @@ public bool CreateWarranty(string amazonOrderId, CreateWarrantyRequest createWar
{
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
queryParameters.Add(new KeyValuePair<string, string>("marketplaceIds", MarketPlace.ID));
CreateAuthorizedRequest(MessaginApiUrls.CreateWarranty(amazonOrderId), RestSharp.Method.POST, queryParameters,postJsonObj: createWarrantyRequest);
CreateAuthorizedRequest(MessaginApiUrls.CreateWarranty(amazonOrderId), RestSharp.Method.POST, queryParameters, postJsonObj: createWarrantyRequest);

var response = ExecuteRequest<CreateConfirmOrderDetailsResponse>();
if (response != null)
Expand All @@ -139,7 +142,7 @@ public bool CreateDigitalAccessKey(string amazonOrderId, CreateDigitalAccessKeyR
{
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
queryParameters.Add(new KeyValuePair<string, string>("marketplaceIds", MarketPlace.ID));
CreateAuthorizedRequest(MessaginApiUrls.CreateDigitalAccessKey(amazonOrderId), RestSharp.Method.POST, queryParameters,postJsonObj: createDigitalAccessKeyRequest);
CreateAuthorizedRequest(MessaginApiUrls.CreateDigitalAccessKey(amazonOrderId), RestSharp.Method.POST, queryParameters, postJsonObj: createDigitalAccessKeyRequest);

var response = ExecuteRequest<CreateConfirmOrderDetailsResponse>();
if (response != null)
Expand All @@ -150,7 +153,7 @@ public bool CreateUnexpectedProblem(string amazonOrderId, CreateUnexpectedProble
{
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
queryParameters.Add(new KeyValuePair<string, string>("marketplaceIds", MarketPlace.ID));
CreateAuthorizedRequest(MessaginApiUrls.CreateUnexpectedProblem(amazonOrderId), RestSharp.Method.POST, queryParameters,postJsonObj: createUnexpectedProblemRequest);
CreateAuthorizedRequest(MessaginApiUrls.CreateUnexpectedProblem(amazonOrderId), RestSharp.Method.POST, queryParameters, postJsonObj: createUnexpectedProblemRequest);

var response = ExecuteRequest<CreateUnexpectedProblemResponse>();
if (response != null)
Expand All @@ -159,6 +162,6 @@ public bool CreateUnexpectedProblem(string amazonOrderId, CreateUnexpectedProble
}



}
}

0 comments on commit 7f29ebc

Please sign in to comment.