Skip to content

Commit

Permalink
Add docs to all public classes and properties
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkyjac committed May 17, 2024
1 parent 38df5dd commit 5ecddb0
Show file tree
Hide file tree
Showing 50 changed files with 717 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Kentico.Xperience.Shopify.Activities
{
/// <summary>
/// Interface for logging ecommerce activities.
/// </summary>
public interface IEcommerceActivityLogger
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
{
public partial class CurrencyFormatInfo
{
/// <summary>
/// Code name of the form to edit <see cref="CurrencyFormatInfo"/> object.
/// </summary>
public const string UI_FORM_NAME = "ShopifyCurrencyFormatForm";
}
}
11 changes: 11 additions & 0 deletions src/Kentico.Xperience.Shopify/Admin/ShopifyCurrencyFormatCreate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@
order: 300)]
namespace Kentico.Xperience.Shopify.Admin
{
/// <summary>
/// Page for creating a new currency format.
/// </summary>
public class ShopifyCurrencyFormatCreate : CreatePage<CurrencyFormatInfo, ShopifyCurrencyFormatEditSection>
{
/// <summary>
/// Initializes a new instance of the <see cref="ShopifyCurrencyFormatCreate"/> class.
/// </summary>
/// <param name="formComponentMapper">The form component mapper.</param>
/// <param name="formDataBinder">The form data binder.</param>
/// <param name="pageUrlGenerator">The page URL generator.</param>
public ShopifyCurrencyFormatCreate(IFormComponentMapper formComponentMapper, IFormDataBinder formDataBinder, IPageUrlGenerator pageUrlGenerator)
: base(formComponentMapper, formDataBinder, pageUrlGenerator)
{
}


/// <inheritdoc/>
public override Task ConfigurePage()
{
PageConfiguration.UIFormName = CurrencyFormatInfo.UI_FORM_NAME;
Expand Down
12 changes: 12 additions & 0 deletions src/Kentico.Xperience.Shopify/Admin/ShopifyCurrencyFormatEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,31 @@
order: UIPageOrder.First)]
namespace Kentico.Xperience.Shopify.Admin
{
/// <summary>
/// Page for editing a currency format.
/// </summary>
public class ShopifyCurrencyFormatEdit : InfoEditPage<CurrencyFormatInfo>
{
/// <summary>
/// Initializes a new instance of the <see cref="ShopifyCurrencyFormatEdit"/> class.
/// </summary>
/// <param name="formComponentMapper">The form component mapper.</param>
/// <param name="formDataBinder">The form data binder.</param>
public ShopifyCurrencyFormatEdit(IFormComponentMapper formComponentMapper, IFormDataBinder formDataBinder)
: base(formComponentMapper, formDataBinder)
{
}


/// <inheritdoc/>
public override Task ConfigurePage()
{
PageConfiguration.UIFormName = CurrencyFormatInfo.UI_FORM_NAME;
return base.ConfigurePage();
}


/// <inheritdoc/>
[PageParameter(typeof(IntPageModelBinder))]
public override int ObjectId { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
order: 400)]
namespace Kentico.Xperience.Shopify.Admin
{
/// <summary>
/// Page for editing section for currency format objects.
/// </summary>
public class ShopifyCurrencyFormatEditSection : EditSectionPage<CurrencyFormatInfo>
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@

namespace Kentico.Xperience.Shopify.Admin
{
/// <summary>
/// Model for Shopify currency format.
/// </summary>
public class ShopifyCurrencyFormatModel
{
/// <summary>
/// The currency code (ISO 4217).
/// </summary>
[TextInputComponent(Label = "Currency code", ExplanationText = "ISO 4217 currency code")]
[RegexStringValidator(@"[A-Z]{3}")]
[RequiredValidationRule]
public string? CurrencyCode { get; set; }


/// <summary>
/// The currency price format.
/// </summary>
[TextInputComponent(Label = "Currency price format", WatermarkText = "$0.00")]
[RequiredValidationRule]
public string? CurrencyPriceFormat { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@
order: 1)]
namespace Kentico.Xperience.Shopify.Admin
{
/// <summary>
/// Page for listing Shopify currency formats.
/// </summary>
public class ShopifyCurrencyFormatsListing : ListingPage
{
/// <inheritdoc/>
protected override string ObjectType => CurrencyFormatInfo.OBJECT_TYPE;


/// <inheritdoc/>
public override Task ConfigurePage()
{
PageConfiguration.AddEditRowAction<ShopifyCurrencyFormatEdit>();
Expand All @@ -27,6 +33,8 @@ public override Task ConfigurePage()
return base.ConfigurePage();
}


/// <inheritdoc/>
[PageCommand]
public override Task<ICommandResponse<RowActionResult>> Delete(int id) => base.Delete(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@

namespace Kentico.Xperience.Shopify.Admin
{
/// <summary>
/// Application for managing Shopify integration settings.
/// </summary>
[UIPermission(SystemPermissions.VIEW)]
[UIPermission(SystemPermissions.UPDATE)]
public class ShopifyIntegrationSettingsApplication : ApplicationPage
{
/// <summary>
/// The identifier of the Shopify integration settings application.
/// </summary>
public const string IDENTIFIER = "Kentico.Xperience.Shopify.Common.IntegrationSettings";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,40 @@

namespace Kentico.Xperience.Shopify.Admin
{
/// <summary>
/// Page for editing Shopify integration settings.
/// </summary>
public class ShopifyIntegrationSettingsEdit : ModelEditPage<ShopifyIntegrationSettingsModel>
{
/// <summary>
/// Initializes a new instance of the <see cref="ShopifyIntegrationSettingsEdit"/> class.
/// </summary>
public ShopifyIntegrationSettingsEdit(Xperience.Admin.Base.Forms.Internal.IFormItemCollectionProvider formItemCollectionProvider, IFormDataBinder formDataBinder) : base(formItemCollectionProvider, formDataBinder)
{
}

private IntegrationSettingsInfo? settingsInfo;

private IntegrationSettingsInfo? SettingsInfo => settingsInfo ??= IntegrationSettingsInfo.Provider.Get()
.TopN(1)
.FirstOrDefault();

private ShopifyIntegrationSettingsModel? model;


/// <summary>
/// Gets or sets the model for Shopify integration settings.
/// </summary>
protected override ShopifyIntegrationSettingsModel Model => model ??= CreateShopifySettingsModel(SettingsInfo);


/// <inheritdoc/>
public override Task ConfigurePage()
{
PageConfiguration.Headline = "It is recommended to use appsettings.json or user secrets to store API credentials. Use this primarly for developement.";
return base.ConfigurePage();
}


/// <inheritdoc/>
protected override Task<ICommandResponse> ProcessFormData(ShopifyIntegrationSettingsModel model, ICollection<IFormItem> formItems)
{
var info = SettingsInfo ?? new IntegrationSettingsInfo();
Expand All @@ -51,6 +60,7 @@ protected override Task<ICommandResponse> ProcessFormData(ShopifyIntegrationSett
return base.ProcessFormData(model, formItems);
}


private ShopifyIntegrationSettingsModel CreateShopifySettingsModel(IntegrationSettingsInfo? integrationSettings)
{
if (integrationSettings == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,39 @@

namespace Kentico.Xperience.Shopify.Admin
{
/// <summary>
/// Model for Shopify integration settings.
/// </summary>
public class ShopifyIntegrationSettingsModel
{
/// <summary>
/// The Shopify store URL.
/// </summary>
[UrlValidationRule]
[TextInputComponent(Label = "Shopify store URL", Order = 1)]
[RequiredValidationRule]
public string? ShopifyStoreUrl { get; set; }


/// <summary>
/// The Admin API key.
/// </summary>
[PasswordComponent(Label = "Admin API key", Order = 2, IgnorePasswordPolicy = true)]
[RequiredValidationRule]
public string? AdminApiKey { get; set; }


/// <summary>
/// The Storefront API key.
/// </summary>
[PasswordComponent(Label = "Storefront API key", Order = 3, IgnorePasswordPolicy = true)]
[RequiredValidationRule]
public string? StorefrontApiKey { get; set; }


/// <summary>
/// The Storefront API version.
/// </summary>
[TextInputComponent(Label = "Storefront API version", Order = 4, ExplanationText = "Api version in format YYYY-MM. Admin API version is not needed since it is set by ShopifySharp NuGet package version")]
[RequiredValidationRule]
public string? StorefrontApiVersion { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,31 @@

[assembly: RegisterFormComponent(ShopifyCollectionSelectorComponent.IDENTIFIER, typeof(ShopifyCollectionSelectorComponent), "Shopify collections dropdown", IconClass = "icon-menu")]
namespace Kentico.Xperience.Shopify.Components.FormComponents;

/// <summary>
/// Form component for selecting Shopify collections.
/// </summary>
public class ShopifyCollectionSelectorComponent : SelectorFormComponent<ShopifyCollectionSelectorProperties>
{
private readonly IShopifyCollectionService collectionService;

/// <summary>
/// The identifier of the Shopify collection selector component.
/// </summary>
public const string IDENTIFIER = "Kentico.Xperience.Shopify.ShopifyCollectionSelector";


/// <summary>
/// Initializes a new instance of the <see cref="ShopifyCollectionSelectorComponent"/> class.
/// </summary>
/// <param name="collectionService">The service for interacting with Shopify collections.</param>
public ShopifyCollectionSelectorComponent(IShopifyCollectionService collectionService)
{
this.collectionService = collectionService;
}

// Retrieves data to be displayed in the selector

/// <inheritdoc />
protected override IEnumerable<HtmlOptionItem> GetHtmlOptions()
{
var collections = collectionService.GetCollectionListing().GetAwaiter().GetResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
namespace Kentico.Xperience.Shopify.Components.FormComponents;

#pragma warning disable S2094 // Classes should not be empty
/// <summary>
/// Properties for a Shopify collection selector.
/// </summary>
public class ShopifyCollectionSelectorProperties : SelectorProperties
#pragma warning restore S2094 // Classes should not be empty
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,30 @@
[assembly: RegisterFormComponent(ShopifyCurrencySelectorComponent.IDENTIFIER, typeof(ShopifyCurrencySelectorComponent), "Shopify enabled currencies dropdown", IconClass = "icon-dollar-sign")]
namespace Kentico.Xperience.Shopify.Components.FormComponents;

/// <summary>
/// Form component for selecting Shopify enabled currencies.
/// </summary>
public class ShopifyCurrencySelectorComponent : SelectorFormComponent<ShopifyCurrencySelectorProperties>
{
private readonly IShopifyCurrencyService currencyService;

/// <summary>
/// The identifier of the Shopify currency selector component.
/// </summary>
public const string IDENTIFIER = "Kentico.Xperience.Shopify.ShopifyCurrencySelector";


/// <summary>
/// Initializes a new instance of the <see cref="ShopifyCurrencySelectorComponent"/> class.
/// </summary>
/// <param name="currencyService">The service for interacting with Shopify currencies.</param>
public ShopifyCurrencySelectorComponent(IShopifyCurrencyService currencyService) : base()
{
this.currencyService = currencyService;
}


/// <inheritdoc/>
protected override IEnumerable<HtmlOptionItem> GetHtmlOptions()
{
var currencies = currencyService.GetCurrencyCodes().GetAwaiter().GetResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
namespace Kentico.Xperience.Shopify.Components.FormComponents;

#pragma warning disable S2094 // Classes should not be empty
/// <summary>
/// Properties for a Shopify currency selector.
/// </summary>
public class ShopifyCurrencySelectorProperties : SelectorProperties
#pragma warning restore S2094 // Classes should not be empty
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace Kentico.Xperience.Shopify.Config
{
/// <summary>
/// Service for managing currency formats.
/// </summary>
public interface IShopifyCurrencyFormatService
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
/// </summary>
public interface IShopifyIntegrationSettingsService
{
/// <summary>
/// Get shopify configuration form appsettings or database if
/// no appsettings does not contain these settings.
/// </summary>
/// <returns></returns>
ShopifyConfig? GetSettings();
}
}
10 changes: 10 additions & 0 deletions src/Kentico.Xperience.Shopify/Config/ShopifyConfig.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
namespace Kentico.Xperience.Shopify.Config
{
/// <summary>
/// Configuration settings for Shopify.
/// </summary>
public class ShopifyConfig
{
/// <summary>
/// The name of the configuration section.
/// </summary>
public static readonly string SECTION_NAME = "CMSShopifyConfig";


/// <summary>
/// Shopify store URL
/// </summary>
public required string ShopifyUrl { get; set; }


/// <summary>
/// Admin API token
/// </summary>
public required string AdminApiKey { get; set; }


/// <summary>
/// Storefront API token
/// </summary>
public required string StorefrontApiKey { get; set; }


/// <summary>
/// Storefront API version
/// </summary>
Expand Down
Loading

0 comments on commit 5ecddb0

Please sign in to comment.