Skip to content

Commit 29f5658

Browse files
committed
fix parameter type
1 parent 5bd2ff5 commit 29f5658

File tree

6 files changed

+37
-8
lines changed

6 files changed

+37
-8
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System;
2+
3+
namespace FikaAmazonAPI.Parameter
4+
{
5+
public class BodyParameterAttribute : Attribute
6+
{
7+
}
8+
}

Source/FikaAmazonAPI/Parameter/ListingsItems/ParameterPutListingItem.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,18 @@ public bool Check()
4141
}
4242
return true;
4343
}
44+
45+
[PathParameter]
4446
public string sellerId { get; set; }
4547

48+
[PathParameter]
4649
public string sku { get; set; }
4750

4851
public ICollection<string> marketplaceIds { get; set; }
4952

5053
public string issueLocale { get; set; }
5154

55+
[BodyParameter]
5256
public ListingsItemPutRequest listingsItemPutRequest { get; set; }
5357

5458
}

Source/FikaAmazonAPI/Parameter/ParameterBased.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public virtual List<KeyValuePair<string, string>> getParameters()
3030
foreach (PropertyInfo p in pi)
3131
{
3232
if (p.CustomAttributes.Any(x => x.AttributeType == typeof(IgnoreToAddParameterAttribute))) continue;
33+
if (p.CustomAttributes.Any(x => x.AttributeType == typeof(PathParameterAttribute))) continue;
34+
if (p.CustomAttributes.Any(x => x.AttributeType == typeof(BodyParameterAttribute))) continue;
3335
var value = p.GetValue(this);
3436
if (value != null)
3537
{
@@ -48,7 +50,7 @@ public virtual List<KeyValuePair<string, string>> getParameters()
4850
{
4951
output = value.ToString();
5052
}
51-
else if(p.PropertyType.IsEnum || IsNullableEnum(p.PropertyType))
53+
else if (p.PropertyType.IsEnum || IsNullableEnum(p.PropertyType))
5254
{
5355
output = value.ToString();
5456
}
@@ -61,19 +63,19 @@ public virtual List<KeyValuePair<string, string>> getParameters()
6163
output = string.Join(",", result);
6264
}
6365
else continue;
64-
66+
6567
}
6668
else
6769
{
6870
output = JsonConvert.SerializeObject(value);
6971
}
70-
72+
7173

7274
var propName = p.Name;
7375

7476
queryParameters.Add(new KeyValuePair<string, string>(propName, output));
7577
}
76-
78+
7779
}
7880

7981
return queryParameters;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System;
2+
3+
namespace FikaAmazonAPI.Parameter
4+
{
5+
public class PathParameterAttribute : Attribute
6+
{
7+
}
8+
}

Source/FikaAmazonAPI/Parameter/ProductTypes/GetDefinitionsProductTypeParameter.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ namespace FikaAmazonAPI.Parameter.ProductTypes
77
{
88
public class GetDefinitionsProductTypeParameter : ParameterBased
99
{
10+
[PathParameter]
1011
public string productType { get; set; }
1112
public string sellerId { get; set; }
1213
public ICollection<string> marketplaceIds { get; set; } = new List<string>();
1314
public string productTypeVersion { get; set; }
14-
public RequirementsEnum requirements { get; set; }
15-
public RequirementsEnforcedEnum requirementsEnforced { get; set; }
16-
public LocaleEnum locale { get; set; }
15+
public RequirementsEnum? requirements { get; set; }
16+
public RequirementsEnforcedEnum? requirementsEnforced { get; set; }
17+
public LocaleEnum? locale { get; set; }
1718

1819
}
1920
}

Source/FikaAmazonAPI/Services/ListingsItemService.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using FikaAmazonAPI.AmazonSpApiSDK.Models.ListingsItems;
22
using FikaAmazonAPI.Parameter.ListingItem;
33
using FikaAmazonAPI.Utils;
4+
using System.Collections.Generic;
45
using System.Threading;
56
using System.Threading.Tasks;
67

@@ -26,9 +27,14 @@ public ListingsItemSubmissionResponse PutListingsItem(ParameterPutListingItem pa
2627
Task.Run(() => PutListingsItemAsync(parameterPutListingItem)).ConfigureAwait(false).GetAwaiter().GetResult();
2728
public async Task<ListingsItemSubmissionResponse> PutListingsItemAsync(ParameterPutListingItem parameterPutListingItem, CancellationToken cancellationToken = default)
2829
{
30+
if (parameterPutListingItem.marketplaceIds == null || parameterPutListingItem.marketplaceIds.Count == 0)
31+
{
32+
parameterPutListingItem.marketplaceIds = new List<string>() { AmazonCredential.MarketPlace.ID };
33+
}
34+
2935
parameterPutListingItem.Check();
3036
var queryParameters = parameterPutListingItem.getParameters();
31-
await CreateAuthorizedRequestAsync(ListingsItemsApiUrls.PutListingItem(parameterPutListingItem.sellerId, parameterPutListingItem.sku), RestSharp.Method.Put, postJsonObj: parameterPutListingItem.listingsItemPutRequest, queryParameters: queryParameters, cancellationToken: cancellationToken);
37+
await CreateAuthorizedRequestAsync(ListingsItemsApiUrls.PutListingItem(parameterPutListingItem.sellerId, parameterPutListingItem.sku), RestSharp.Method.Put, queryParameters, postJsonObj: parameterPutListingItem.listingsItemPutRequest, cancellationToken: cancellationToken);
3238
var response = await ExecuteRequestAsync<ListingsItemSubmissionResponse>(RateLimitType.ListingsItem_PutListingsItem, cancellationToken);
3339
return response;
3440
}

0 commit comments

Comments
 (0)