Skip to content

Commit 7b19a69

Browse files
author
dev_chenjaiwen
committed
fixed messging
1 parent 4d178e1 commit 7b19a69

File tree

4 files changed

+123
-16
lines changed

4 files changed

+123
-16
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.ComponentModel.DataAnnotations;
5+
using System.Runtime.Serialization;
6+
using System.Text;
7+
8+
namespace FikaAmazonAPI.AmazonSpApiSDK.Models.Messaging
9+
{
10+
[DataContract]
11+
public partial class Embedded : IEquatable<Embedded>, IValidatableObject
12+
{
13+
/// <summary>
14+
/// Gets or Sets Embedded
15+
/// </summary>
16+
[DataMember(Name = "actions", EmitDefaultValue = false)]
17+
public IList<GetMessagingActionResponse> ActionList { get; set; }
18+
19+
public Embedded()
20+
{
21+
this.ActionList = default(IList<GetMessagingActionResponse>);
22+
}
23+
24+
public Embedded(IList<GetMessagingActionResponse> actionList = default(IList<GetMessagingActionResponse>))
25+
{
26+
this.ActionList = actionList;
27+
}
28+
29+
/// <summary>
30+
/// Returns the string presentation of the object
31+
/// </summary>
32+
/// <returns>String presentation of the object</returns>
33+
public override string ToString()
34+
{
35+
var sb = new StringBuilder();
36+
sb.Append("class Embedded {\n");
37+
sb.Append(" actions: ").Append(ActionList).Append("\n");
38+
sb.Append("}\n");
39+
return sb.ToString();
40+
}
41+
42+
/// <summary>
43+
/// Returns the JSON string presentation of the object
44+
/// </summary>
45+
/// <returns>JSON string presentation of the object</returns>
46+
public virtual string ToJson()
47+
{
48+
return JsonConvert.SerializeObject(this, Formatting.Indented);
49+
}
50+
51+
/// <summary>
52+
/// Returns true if objects are equal
53+
/// </summary>
54+
/// <param name="input">Object to be compared</param>
55+
/// <returns>Boolean</returns>
56+
public override bool Equals(object input)
57+
{
58+
return this.Equals(input as Embedded);
59+
}
60+
61+
/// <summary>
62+
/// Returns true if GetMessagingActionsForOrderResponse instances are equal
63+
/// </summary>
64+
/// <param name="input">Instance of GetMessagingActionsForOrderResponse to be compared</param>
65+
/// <returns>Boolean</returns>
66+
public bool Equals(Embedded input)
67+
{
68+
if (input == null)
69+
return false;
70+
71+
return
72+
(
73+
this.ActionList == input.ActionList ||
74+
(this.ActionList != null &&
75+
this.ActionList.Equals(input.ActionList))
76+
);
77+
}
78+
79+
/// <summary>
80+
/// Gets the hash code
81+
/// </summary>
82+
/// <returns>Hash code</returns>
83+
public override int GetHashCode()
84+
{
85+
unchecked // Overflow is fine, just wrap
86+
{
87+
int hashCode = 41;
88+
if (this.ActionList != null)
89+
hashCode = hashCode * 59 + this.ActionList.GetHashCode();
90+
return hashCode;
91+
}
92+
}
93+
94+
/// <summary>
95+
/// To validate all properties of the instance
96+
/// </summary>
97+
/// <param name="validationContext">Validation context</param>
98+
/// <returns>Validation Result</returns>
99+
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
100+
{
101+
yield break;
102+
}
103+
}
104+
}

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/Messaging/GetMessagingActionsForOrderResponse.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public partial class GetMessagingActionsForOrderResponse : IEquatable<GetMessag
3535
/// <param name="links">links.</param>
3636
/// <param name="embedded">embedded.</param>
3737
/// <param name="errors">errors.</param>
38-
public GetMessagingActionsForOrderResponse(GetMessagingActionsForOrderResponseLinks links = default(GetMessagingActionsForOrderResponseLinks), IList<GetMessagingActionResponse> embedded = default(IList<GetMessagingActionResponse>))
38+
public GetMessagingActionsForOrderResponse(GetMessagingActionsForOrderResponseLinks links = default(GetMessagingActionsForOrderResponseLinks), Embedded embedded = default(Embedded))
3939
{
4040
this.Links = links;
4141
this.Embedded = embedded;
4242
}
4343
public GetMessagingActionsForOrderResponse()
4444
{
4545
this.Links = default(GetMessagingActionsForOrderResponseLinks);
46-
this.Embedded = default(IList<GetMessagingActionResponse>);
46+
this.Embedded = default(Embedded);
4747
}
4848

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

6161
/// <summary>
6262
/// Gets or Sets Errors

Source/FikaAmazonAPI/Services/ApiUrls.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ protected class MessaginApiUrls
139139
{
140140
private readonly static string _resourceBaseUrl = "/messaging/v1";
141141

142-
public static string GetMessagingActionsForOrder(string amazonOrderId, string marketplaceIds) => $"{_resourceBaseUrl}/orders/{amazonOrderId}?marketplaceIds={marketplaceIds}";
142+
public static string GetMessagingActionsForOrder(string amazonOrderId) => $"{_resourceBaseUrl}/orders/{amazonOrderId}";
143143
public static string ConfirmCustomizationDetails(string amazonOrderId) => $"{_resourceBaseUrl}/orders/{amazonOrderId}/messages/confirmCustomizationDetails";
144144
public static string CreateConfirmDeliveryDetails(string amazonOrderId) => $"{_resourceBaseUrl}/orders/{amazonOrderId}/messages/confirmDeliveryDetails";
145145
public static string CreateLegalDisclosure(string amazonOrderId) => $"{_resourceBaseUrl}/orders/{amazonOrderId}/messages/legalDisclosure";

Source/FikaAmazonAPI/Services/MessagingService.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ public MessagingService(AmazonCredential amazonCredential) : base(amazonCredenti
1515

1616
public GetMessagingActionsForOrderResponse GetMessagingActionsForOrder(string amazonOrderId)
1717
{
18-
CreateAuthorizedRequest(MessaginApiUrls.GetMessagingActionsForOrder(amazonOrderId, MarketPlace.ID), RestSharp.Method.GET);
18+
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
19+
queryParameters.Add(new KeyValuePair<string, string>("marketplaceIds", MarketPlace.ID));
20+
21+
CreateAuthorizedRequest(MessaginApiUrls.GetMessagingActionsForOrder(amazonOrderId), RestSharp.Method.GET, queryParameters);
1922

2023
var response = ExecuteRequest<GetMessagingActionsForOrderResponse>();
2124

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

30-
CreateAuthorizedRequest(MessaginApiUrls.ConfirmCustomizationDetails(amazonOrderId), RestSharp.Method.POST, queryParameters,postJsonObj: createConfirmCustomizationDetailsRequest);
33+
CreateAuthorizedRequest(MessaginApiUrls.ConfirmCustomizationDetails(amazonOrderId), RestSharp.Method.POST, queryParameters, postJsonObj: createConfirmCustomizationDetailsRequest);
3134

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

43-
CreateAuthorizedRequest(MessaginApiUrls.CreateConfirmDeliveryDetails(amazonOrderId), RestSharp.Method.POST, queryParameters,postJsonObj: createConfirmCustomizationDetailsRequest);
46+
CreateAuthorizedRequest(MessaginApiUrls.CreateConfirmDeliveryDetails(amazonOrderId), RestSharp.Method.POST, queryParameters, postJsonObj: createConfirmCustomizationDetailsRequest);
4447

4548
var response = ExecuteRequest<CreateConfirmCustomizationDetailsResponse>();
4649
if (response != null)
4750
return true;
4851
return false;
4952

5053
}
51-
54+
5255
public bool CreateLegalDisclosure(string amazonOrderId, CreateLegalDisclosureRequest createLegalDisclosureRequest)
5356
{
5457
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
5558
queryParameters.Add(new KeyValuePair<string, string>("marketplaceIds", MarketPlace.ID));
5659

57-
CreateAuthorizedRequest(MessaginApiUrls.CreateLegalDisclosure(amazonOrderId), RestSharp.Method.POST, queryParameters,postJsonObj: createLegalDisclosureRequest);
60+
CreateAuthorizedRequest(MessaginApiUrls.CreateLegalDisclosure(amazonOrderId), RestSharp.Method.POST, queryParameters, postJsonObj: createLegalDisclosureRequest);
5861

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

83-
CreateAuthorizedRequest(MessaginApiUrls.CreateConfirmOrderDetails(amazonOrderId), RestSharp.Method.POST, queryParameters,postJsonObj: createConfirmOrderDetailsRequest);
86+
CreateAuthorizedRequest(MessaginApiUrls.CreateConfirmOrderDetails(amazonOrderId), RestSharp.Method.POST, queryParameters, postJsonObj: createConfirmOrderDetailsRequest);
8487

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

96-
CreateAuthorizedRequest(MessaginApiUrls.CreateConfirmServiceDetails(amazonOrderId), RestSharp.Method.POST, queryParameters,postJsonObj: createConfirmServiceDetailsRequest);
99+
CreateAuthorizedRequest(MessaginApiUrls.CreateConfirmServiceDetails(amazonOrderId), RestSharp.Method.POST, queryParameters, postJsonObj: createConfirmServiceDetailsRequest);
97100

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

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

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

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

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

161164

162-
165+
163166
}
164167
}

0 commit comments

Comments
 (0)