Skip to content

Commit cb85602

Browse files
author
Florian Weihmann
committed
Bugfix converting Enums to Integer
1 parent f7228b1 commit cb85602

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
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/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)