Refactoring: Move AppItem to Client lib and use the class for item list (#6258)

* Refactoring: Move AppItem to Client lib and use the class for item list

This makes it available for the app, which would otherwise have to replicate the model. Also uses the proper class for the item/perk list of the app models.

* Remove unused app item payment methods property

* Do not ignore nullable values in JSON

* Revert to use Newtonsoft types
This commit is contained in:
d11n
2024-11-05 03:49:30 +01:00
committed by GitHub
parent 225264a283
commit ff79a31066
22 changed files with 219 additions and 245 deletions

View File

@@ -355,6 +355,7 @@ namespace BTCPayServer.Controllers.Greenfield
{
var settings = appData.GetSettings<PointOfSaleSettings>();
Enum.TryParse<PosViewType>(settings.DefaultView.ToString(), true, out var defaultView);
var items = AppService.Parse(settings.Template);
return new PointOfSaleAppData
{
@@ -382,16 +383,7 @@ namespace BTCPayServer.Controllers.Greenfield
RedirectUrl = settings.RedirectUrl,
Description = settings.Description,
RedirectAutomatically = settings.RedirectAutomatically,
Items = JsonConvert.DeserializeObject(
JsonConvert.SerializeObject(
AppService.Parse(settings.Template),
new JsonSerializerSettings
{
ContractResolver =
new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
}
)
)
Items = items
};
}
@@ -420,6 +412,7 @@ namespace BTCPayServer.Controllers.Greenfield
{
var settings = appData.GetSettings<CrowdfundSettings>();
Enum.TryParse<CrowdfundResetEvery>(settings.ResetEvery.ToString(), true, out var resetEvery);
var perks = AppService.Parse(settings.PerksTemplate);
return new CrowdfundAppData
{
@@ -451,15 +444,7 @@ namespace BTCPayServer.Controllers.Greenfield
SortPerksByPopularity = settings.SortPerksByPopularity,
Sounds = settings.Sounds,
AnimationColors = settings.AnimationColors,
Perks = JsonConvert.DeserializeObject(
JsonConvert.SerializeObject(
AppService.Parse(settings.PerksTemplate),
new JsonSerializerSettings
{
ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
}
)
)
Perks = perks
};
}