Skip to content

Commit

Permalink
Greenfield: Add brandColor to store APIs
Browse files Browse the repository at this point in the history
Closes #5946.
  • Loading branch information
dennisreimann committed Apr 23, 2024
1 parent c61676a commit dc48116
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions BTCPayServer.Client/Models/StoreBaseData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public abstract class StoreBaseData

public string Website { get; set; }

public string BrandColor { get; set; }

public string SupportUrl { get; set; }

[JsonConverter(typeof(TimeSpanJsonConverter.Seconds))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ internal static Client.Models.StoreData FromModel(StoreData data)
Name = data.StoreName,
Website = data.StoreWebsite,
Archived = data.Archived,
BrandColor = storeBlob.BrandColor,
SupportUrl = storeBlob.StoreSupportUrl,
SpeedPolicy = data.SpeedPolicy,
DefaultPaymentMethod = data.GetDefaultPaymentId()?.ToString(),
Expand Down Expand Up @@ -192,6 +193,7 @@ private void ToModel(StoreBaseData restModel, StoreData model, PaymentMethodId d
blob.LightningDescriptionTemplate = restModel.LightningDescriptionTemplate;
blob.PaymentTolerance = restModel.PaymentTolerance;
blob.PayJoinEnabled = restModel.PayJoinEnabled;
blob.BrandColor = restModel.BrandColor;
if (restModel.AutoDetectLanguage.HasValue)
blob.AutoDetectLanguage = restModel.AutoDetectLanguage.Value;
if (restModel.ShowPayInWalletButton.HasValue)
Expand Down Expand Up @@ -237,6 +239,10 @@ private IActionResult Validate(StoreBaseData request)
{
ModelState.AddModelError(nameof(request.Website), "Website is not a valid url");
}
if (!string.IsNullOrEmpty(request.BrandColor) && !ColorPalette.IsValid(request.BrandColor))
{
ModelState.AddModelError(nameof(request.BrandColor), "Brand color is not a valid HEX Color (e.g. #F7931A)");
}
if (request.InvoiceExpiration < TimeSpan.FromMinutes(1) && request.InvoiceExpiration > TimeSpan.FromMinutes(60 * 24 * 24))
ModelState.AddModelError(nameof(request.InvoiceExpiration), "InvoiceExpiration can only be between 1 and 34560 mins");
if (request.DisplayExpirationTimer < TimeSpan.FromMinutes(1) && request.DisplayExpirationTimer > TimeSpan.FromMinutes(60 * 24 * 24))
Expand Down
6 changes: 6 additions & 0 deletions BTCPayServer/wwwroot/swagger/v1/swagger.template.stores.json
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,12 @@
"description": "The support URI of the store, can contain the placeholders `{OrderId}` and `{InvoiceId}`. Can be any valid URI, such as a website, email, and nostr.",
"format": "uri"
},
"brandColor": {
"type": "string",
"description": "The brand color of the store in HEX format",
"nullable": true,
"example": "#F7931A"
},
"defaultCurrency": {
"type": "string",
"description": "The default currency of the store",
Expand Down

0 comments on commit dc48116

Please sign in to comment.