Skip to content

Commit 9fd916a

Browse files
committed
fix for handling the PblPaymentLinksAllGet200Response
1 parent 614cdd8 commit 9fd916a

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

cybersource-rest-client-netstandard/cybersource-rest-client-netstandard/Client/ApiClient.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,19 @@ public object Deserialize(RestResponse response, Type type) // CHANGED
706706
// at this point, it must be a model (json)
707707
try
708708
{
709-
return JsonConvert.DeserializeObject(response.Content, type, serializerSettings);
709+
if (type == typeof(Model.PblPaymentLinksAllGet200Response))
710+
{
711+
JsonSerializerSettings customSerializerSettings = new JsonSerializerSettings
712+
{
713+
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
714+
ContractResolver = new Utilities.CustomContractResolver()
715+
};
716+
return JsonConvert.DeserializeObject(response.Content, type, customSerializerSettings);
717+
}
718+
else
719+
{
720+
return JsonConvert.DeserializeObject(response.Content, type, serializerSettings);
721+
}
710722
}
711723
catch (Exception e)
712724
{
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Newtonsoft.Json.Serialization;
2+
3+
namespace CyberSource.Utilities
4+
{
5+
public class CustomContractResolver : DefaultContractResolver
6+
{
7+
protected override string ResolvePropertyName(string propertyName)
8+
{
9+
if (propertyName == "Links")
10+
{
11+
return "_links";
12+
}
13+
/*if (propertyName == "SdkLinks")
14+
{
15+
return "links";
16+
}*/
17+
return base.ResolvePropertyName(propertyName);
18+
}
19+
20+
}
21+
}

cybersource-rest-client-netstandard/cybersource-rest-client-netstandard/generator/cybersource-csharp-template/ApiClient.mustache

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,19 @@ namespace {{packageName}}.Client
760760
// at this point, it must be a model (json)
761761
try
762762
{
763-
return JsonConvert.DeserializeObject(response.Content, type, serializerSettings);
763+
if (type == typeof(Model.PblPaymentLinksAllGet200Response))
764+
{
765+
JsonSerializerSettings customSerializerSettings = new JsonSerializerSettings
766+
{
767+
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
768+
ContractResolver = new Utilities.CustomContractResolver()
769+
};
770+
return JsonConvert.DeserializeObject(response.Content, type, customSerializerSettings);
771+
}
772+
else
773+
{
774+
return JsonConvert.DeserializeObject(response.Content, type, serializerSettings);
775+
}
764776
}
765777
catch (Exception e)
766778
{

0 commit comments

Comments
 (0)