Skip to content

Commit 5f2cc36

Browse files
authored
Merge pull request #772 from prorena/main
Fixed confusing exception message for ParameterPatchListingItem
2 parents c162ab7 + cb85602 commit 5f2cc36

File tree

3 files changed

+52
-7
lines changed

3 files changed

+52
-7
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using FikaAmazonAPI.Parameter.ListingItem;
2+
using FikaAmazonAPI.Utils;
3+
4+
namespace FikaAmazonAPI.SampleCode
5+
{
6+
public class ListingsItemsSample
7+
{
8+
private readonly AmazonConnection amazonConnection;
9+
public ListingsItemsSample(AmazonConnection amazonConnection)
10+
{
11+
this.amazonConnection = amazonConnection;
12+
}
13+
14+
public async Task SetListingsItemAttribute(string sellerId)
15+
{
16+
var sku = "MP-23Q3W00058-Q898-03";
17+
var marketPlace = MarketPlace.Germany;
18+
19+
PatchOperation[] patches = new PatchOperation[1];
20+
21+
patches[0] = new PatchOperation()
22+
{
23+
op = Op.replace,
24+
path = "/attributes/gpsr_safety_attestation",
25+
value = new object[] { true }
26+
};
27+
28+
ParameterPatchListingItem parameter = new()
29+
{
30+
listingsItemPatchRequest = new ListingsItemPatchRequest() { patches = patches, productType = "BRA" },
31+
sellerId = sellerId,
32+
sku = sku,
33+
marketplaceIds = new string[] { marketPlace.ID }
34+
};
35+
36+
await amazonConnection.ListingsItem.PatchListingsItemAsync(parameter);
37+
}
38+
}
39+
}

Source/FikaAmazonAPI/Parameter/ListingsItems/ParameterPatchListingItem.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ public bool Check()
2626
}
2727
if (this.listingsItemPatchRequest == null)
2828
{
29-
throw new InvalidDataException("ListingsItemPutRequest is a required property for ParameterPatchListingItem and cannot be null");
29+
throw new InvalidDataException("ListingsItemPatchRequest is a required property for ParameterPatchListingItem and cannot be null");
3030
}
31-
if (string.IsNullOrWhiteSpace(this.listingsItemPatchRequest.productType))
31+
if (string.IsNullOrWhiteSpace(this.listingsItemPatchRequest.productType))
3232
{
33-
throw new InvalidDataException("ListingsItemPutRequest is a required property for ParameterPatchListingItem and cannot be null");
33+
throw new InvalidDataException("ListingsItemPatchRequest.productType is a required property for ParameterPatchListingItem and cannot be null");
3434
}
35-
if (this.listingsItemPatchRequest.patches==null|| !this.listingsItemPatchRequest.patches.Any())
35+
if (this.listingsItemPatchRequest.patches == null || !this.listingsItemPatchRequest.patches.Any())
3636
{
3737
throw new InvalidDataException("Patches is a required property for ParameterPatchListingItem and cannot be null");
3838
}
39-
return true;
39+
return true;
4040
}
4141

4242
public string sellerId { get; set; }
@@ -47,7 +47,7 @@ public bool Check()
4747

4848
public string issueLocale { get; set; }
4949

50-
public ListingsItemPatchRequest listingsItemPatchRequest { get; set; }
50+
public ListingsItemPatchRequest listingsItemPatchRequest { get; set; }
5151

5252
}
5353

Source/FikaAmazonAPI/Parameter/ParameterBased.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using FikaAmazonAPI.Parameter;
22
using FikaAmazonAPI.Utils;
33
using Newtonsoft.Json;
4+
using Newtonsoft.Json.Converters;
45
using System;
56
using System.Collections;
67
using System.Collections.Generic;
@@ -67,7 +68,12 @@ public virtual List<KeyValuePair<string, string>> getParameters()
6768
}
6869
else
6970
{
70-
output = JsonConvert.SerializeObject(value);
71+
var settings = new JsonSerializerSettings()
72+
{
73+
Converters = new List<JsonConverter>() { new StringEnumConverter() }
74+
};
75+
76+
output = JsonConvert.SerializeObject(value, settings);
7177
}
7278

7379

0 commit comments

Comments
 (0)