├── Categories.md ├── Customers.md ├── LICENSE ├── Nop.Plugin.Api.Tests ├── ControllersTests │ ├── Categories │ │ ├── CategoriesControllerTests_CreateCategory.cs │ │ ├── CategoriesControllerTests_GetCategories.cs │ │ ├── CategoriesControllerTests_GetCategoriesById.cs │ │ └── CategoriesControllerTests_GetCategoriesCount.cs │ ├── Customers │ │ ├── CustomersControllerTests_GetCustomerById.cs │ │ ├── CustomersControllerTests_GetCustomers.cs │ │ ├── CustomersControllerTests_GetCustomersCount.cs │ │ └── CustomersControllerTests_Search.cs │ ├── Orders │ │ ├── OrdersControllerTests_GetOrderById.cs │ │ ├── OrdersControllerTests_GetOrders.cs │ │ ├── OrdersControllerTests_GetOrdersByCustomerId.cs │ │ └── OrdersControllerTests_GetOrdersCount.cs │ ├── ProductCategoryMappings │ │ ├── ProductCategoryMappingsControllerTests_GetMappingById.cs │ │ ├── ProductCategoryMappingsControllerTests_GetMappings.cs │ │ └── ProductCategoryMappingsControllerTests_GetMappingsCount.cs │ ├── Products │ │ ├── ProductsControllerTests_GetProductById.cs │ │ ├── ProductsControllerTests_GetProducts.cs │ │ └── ProductsControllerTests_GetProductsCount.cs │ └── ShoppingCartItems │ │ ├── ShoppingCartItemsControllerTests_GetShoppingCartItems.cs │ │ └── ShoppingCartItemsControllerTests_GetShoppingCartItemsByCustomerId.cs ├── ConvertersTests │ ├── ApiTypeConverter │ │ ├── ApiTypeConverterTests_ToDateTimeNullable.cs │ │ ├── ApiTypeConverterTests_ToEnumNullable.cs │ │ ├── ApiTypeConverterTests_ToInt.cs │ │ ├── ApiTypeConverterTests_ToIntNullable.cs │ │ ├── ApiTypeConverterTests_ToListOfInts.cs │ │ └── ApiTypeConverterTests_ToStatus.cs │ └── ObjectConverter │ │ ├── DummyObjects │ │ └── SomeTestingObject.cs │ │ └── ObjectConverterTests_ToObject.cs ├── Helpers │ └── ActionResultExecutor.cs ├── MappingTests │ └── CategoryMappings_Merge.cs ├── ModelBinderTests │ ├── DummyObjects │ │ └── DummyModel.cs │ ├── JsonModelBinderTests_BindModel.cs │ └── ParametersModelBinderTests_BindModel.cs ├── Nop.Plugin.Api.Tests.csproj ├── SerializersTests │ ├── DummyObjects │ │ ├── DummyObjectWithComplexTypes.cs │ │ ├── DummyObjectWithSimpleTypes.cs │ │ ├── SerializableDummyObjectWithComplexTypes.cs │ │ └── SerializableDummyObjectWithSimpleTypes.cs │ └── JsonFieldsSerializerTests_Serialize.cs ├── ServicesTests │ ├── Categories │ │ ├── GetCategories │ │ │ ├── CategoriesApiServiceTests_GetCategories_ProductIdParameter.cs │ │ │ ├── CategoriesApiServiceTests_GetCategories_SinceIdParameter.cs │ │ │ ├── CategoryApiServiceTests_GetCategories_CreatedParameters.cs │ │ │ ├── CategoryApiServiceTests_GetCategories_DefaultParameters.cs │ │ │ ├── CategoryApiServiceTests_GetCategories_IdsParameter.cs │ │ │ ├── CategoryApiServiceTests_GetCategories_LimitParameter.cs │ │ │ ├── CategoryApiServiceTests_GetCategories_PageParameter.cs │ │ │ ├── CategoryApiServiceTests_GetCategories_PublishedStatusParameter.cs │ │ │ └── CategoryApiServiceTests_GetCategories_UpdatedParameters.cs │ │ ├── GetCategoriesCount │ │ │ ├── CategoryApiServiceTests_GetCategoriesCount_CreatedParameters.cs │ │ │ ├── CategoryApiServiceTests_GetCategoriesCount_DefaultParameters.cs │ │ │ ├── CategoryApiServiceTests_GetCategoriesCount_ProductIdParameter.cs │ │ │ ├── CategoryApiServiceTests_GetCategoriesCount_PublishedStatusParameter.cs │ │ │ └── CategoryApiServiceTests_GetCategoriesCount_UpdatedParameters.cs │ │ └── GetCategoryById │ │ │ └── CategoryApiServiceTests_GetCategoryById.cs │ ├── CountryApiServiceTests.cs │ ├── Customers │ │ └── CustomerApiServiceTests.cs │ ├── Orders │ │ ├── GetOrderById │ │ │ └── OrderApiServiceTests_GetOrderById.cs │ │ ├── GetOrders │ │ │ ├── OrderApiServiceTests_GetOrders_CreatedParameters.cs │ │ │ ├── OrderApiServiceTests_GetOrders_CustomerIdParameter.cs │ │ │ ├── OrderApiServiceTests_GetOrders_DefaultParameters.cs │ │ │ ├── OrderApiServiceTests_GetOrders_IdsParameter.cs │ │ │ ├── OrderApiServiceTests_GetOrders_LimitParameter.cs │ │ │ ├── OrderApiServiceTests_GetOrders_PageParameter.cs │ │ │ ├── OrderApiServiceTests_GetOrders_SinceIdParameter.cs │ │ │ └── OrderApiServiceTests_GetOrders_StatusesParameters.cs │ │ ├── GetOrdersByCustomerId │ │ │ └── OrderApiServiceTests_GetOrdersByCustomerId.cs │ │ └── GetOrdersCount │ │ │ ├── OrderApiServiceTests_GetOrdersCount_CreatedParameters.cs │ │ │ ├── OrderApiServiceTests_GetOrdersCount_CustomerIdParameter.cs │ │ │ ├── OrderApiServiceTests_GetOrdersCount_DefaultParameters.cs │ │ │ └── OrderApiServiceTests_GetOrdersCount_StatusesParameters.cs │ ├── ProductCategoryMappings │ │ ├── GetMappingById │ │ │ └── ProductCategoryMappingsApiServiceTests_GetById.cs │ │ ├── GetMappings │ │ │ ├── ProductCategoryMappingsApiServiceTests_GetMappings_CategoryIdParameter.cs │ │ │ ├── ProductCategoryMappingsApiServiceTests_GetMappings_DefaultParameters.cs │ │ │ ├── ProductCategoryMappingsApiServiceTests_GetMappings_LimitParameter.cs │ │ │ ├── ProductCategoryMappingsApiServiceTests_GetMappings_PageParameter.cs │ │ │ ├── ProductCategoryMappingsApiServiceTests_GetMappings_ProductIdParameter.cs │ │ │ └── ProductCategoryMappingsApiServiceTests_GetMappings_SinceIdParameter.cs │ │ └── GetMappingsCount │ │ │ └── ProductCategoryMappingsApiServiceTests_GetMappingsCount.cs │ ├── Products │ │ ├── GetProductById │ │ │ └── ProductApiServiceTests_GetProductById.cs │ │ ├── GetProducts │ │ │ ├── ProductApiServiceTests_GetProducts_CategoryIdParameter.cs │ │ │ ├── ProductApiServiceTests_GetProducts_CreatedParameters.cs │ │ │ ├── ProductApiServiceTests_GetProducts_DefaultParameters.cs │ │ │ ├── ProductApiServiceTests_GetProducts_IdsParameter.cs │ │ │ ├── ProductApiServiceTests_GetProducts_LimitParameter.cs │ │ │ ├── ProductApiServiceTests_GetProducts_PageParameter.cs │ │ │ ├── ProductApiServiceTests_GetProducts_PublishedStatusParameter.cs │ │ │ ├── ProductApiServiceTests_GetProducts_SinceIdParameter.cs │ │ │ ├── ProductApiServiceTests_GetProducts_UpdatedParameters.cs │ │ │ └── ProductApiServiceTests_GetProducts_VendorNameParameter.cs │ │ └── GetProductsCount │ │ │ ├── ProductApiServiceTests_GetProductsCount_CategoryIdParameter.cs │ │ │ ├── ProductApiServiceTests_GetProductsCount_CreatedParameters.cs │ │ │ ├── ProductApiServiceTests_GetProductsCount_DefaultParameters.cs │ │ │ ├── ProductApiServiceTests_GetProductsCount_PublishedStatusParameter.cs │ │ │ ├── ProductApiServiceTests_GetProductsCount_UpdatedParameters.cs │ │ │ └── ProductApiServiceTests_GetProductsCount_VendorNameParameter.cs │ ├── ShoppingCartItems │ │ └── GetShoppingCartItems │ │ │ ├── ShoppingCartItemsTests_GetShoppingCartItems_CreatedParameters.cs │ │ │ ├── ShoppingCartItemsTests_GetShoppingCartItems_CustomerIdParameter.cs │ │ │ ├── ShoppingCartItemsTests_GetShoppingCartItems_LimitParameter.cs │ │ │ ├── ShoppingCartItemsTests_GetShoppingCartItems_PageParameters.cs │ │ │ └── ShoppingCartItemsTests_GetShoppingCartItems_UpdatedParameters.cs │ └── StateProvinceApiServiceTests.cs ├── SetUp.cs ├── ValidatorTests │ ├── FieldsValidatorTests_GetValidFields.cs │ └── TypeValidatorTests_IsValid.cs ├── app.config └── packages.config ├── Nop.Plugin.Api ├── ApiAuthentication.cs ├── ApiMapperConfiguration.cs ├── ApiPlugin.cs ├── ApiStartup.cs ├── Attributes │ ├── ApiAuthorize.cs │ ├── BaseAttributeInvoker.cs │ ├── DoNotMap.cs │ ├── GetRequestsErrorInterceptorActionFilter.cs │ ├── ImageAttribute.cs │ ├── ImageCollectionAttribute.cs │ ├── ProductTypeValidationAttribute.cs │ └── ValidateVendor.cs ├── Authorization │ ├── Policies │ │ ├── ActiveApiPluginAuthorizationPolicy.cs │ │ ├── ActiveClientAuthorizationPolicy.cs │ │ ├── RequestsFromSwaggerAuthorizationPolicy.cs │ │ └── ValidSchemeAuthorizationPolicy.cs │ └── Requirements │ │ ├── ActiveApiPluginRequirement.cs │ │ ├── ActiveClientRequirement.cs │ │ ├── AuthorizationSchemeRequirement.cs │ │ └── RequestFromSwaggerOptional.cs ├── AutoMapper │ └── AutoMapperApiConfiguration.cs ├── Constants │ ├── Configurations.cs │ ├── Plugin.cs │ ├── ViewNames.cs │ └── WebHookNames.cs ├── Controllers │ ├── Admin │ │ ├── ApiAdminController.cs │ │ └── ManageClientsAdminController.cs │ ├── BaseApiController.cs │ ├── CategoriesController.cs │ ├── CustomerRolesController.cs │ ├── CustomersController.cs │ ├── LanguagesController.cs │ ├── ManufacturersController.cs │ ├── NewsLetterSubscriptionController.cs │ ├── OrderItemsController.cs │ ├── OrdersController.cs │ ├── ProductAttributesController.cs │ ├── ProductCategoryMappingsController.cs │ ├── ProductManufacturerMappingsController.cs │ ├── ProductSpecificationAttributesController.cs │ ├── ProductsController.cs │ ├── ShoppingCartItemsController.cs │ ├── SpecificationAttributesController.cs │ ├── StoreController.cs │ ├── WebHookFiltersController.cs │ └── WebHookRegistrationsController.cs ├── Converters │ ├── ApiTypeConverter.cs │ ├── IApiTypeConverter.cs │ ├── IObjectConverter.cs │ └── ObjectConverter.cs ├── DTOs │ ├── AddressDto.cs │ ├── Base │ │ └── BaseDto.cs │ ├── Categories │ │ ├── CategoriesCountRootObject.cs │ │ ├── CategoriesRootObject.cs │ │ └── CategoryDto.cs │ ├── CustomerRoles │ │ ├── CustomerRoleDto.cs │ │ └── CustomerRolesRootObject.cs │ ├── Customers │ │ ├── BaseCustomerDto.cs │ │ ├── CustomerAttributeMappingDto.cs │ │ ├── CustomerDto.cs │ │ ├── CustomerForShoppingCartItemDto.cs │ │ ├── CustomersCountRootObject.cs │ │ ├── CustomersRootObject.cs │ │ └── OrderCustomerDto.cs │ ├── Errors │ │ └── ErrorsRootObject.cs │ ├── ISerializableObject.cs │ ├── Images │ │ ├── ImageDto.cs │ │ └── ImageMappingDto.cs │ ├── Languages │ │ ├── LanguageDto.cs │ │ ├── LanguagesRootObject.cs │ │ └── LocalizedNameDto.cs │ ├── Manufacturers │ │ ├── DiscountManufacturerMappingDto.cs │ │ ├── ManufacturerDto.cs │ │ ├── ManufacturersCountRootObject.cs │ │ └── ManufacturersRootObject.cs │ ├── NewsLetterSubscriptions │ │ ├── NewsLetterSubscriptionDto.cs │ │ └── NewsLetterSubscriptionsRootObject.cs │ ├── OrderItems │ │ ├── OrderItemDto.cs │ │ ├── OrderItemsCountRootObject.cs │ │ └── OrderItemsRootObject.cs │ ├── Orders │ │ ├── OrderDto.cs │ │ ├── OrdersCountRootObject.cs │ │ ├── OrdersRootObject.cs │ │ └── SingleOrderRootObject.cs │ ├── ProductAttributes │ │ ├── ProductAttributeDto.cs │ │ ├── ProductAttributesCountRootObject.cs │ │ └── ProductAttributesRootObjectDto.cs │ ├── ProductCategoryMappings │ │ ├── ProductCategoryMappingsCountRootObject.cs │ │ ├── ProductCategoryMappingsDto.cs │ │ └── ProductCategoryMappingsRootObject.cs │ ├── ProductItemAttributeDto.cs │ ├── ProductManufacturerMappings │ │ ├── ProductManufacturerMappingsCountRootObject.cs │ │ ├── ProductManufacturerMappingsDto.cs │ │ └── ProductManufacturerMappingsRootObject.cs │ ├── Products │ │ ├── ProductAttributeCombinationDto.cs │ │ ├── ProductAttributeMappingDto.cs │ │ ├── ProductAttributeValueDto.cs │ │ ├── ProductDto.cs │ │ ├── ProductsCountRootObject.cs │ │ └── ProductsRootObjectDto.cs │ ├── ShoppingCarts │ │ ├── ShoppingCartItemDto.cs │ │ └── ShoppingCartItemsRootObject.cs │ ├── SpecificationAttributes │ │ ├── ProductSpecificationAttributeDto.cs │ │ ├── ProductSpecificationAttributesCountRootObject.cs │ │ ├── ProductSpecificationAttributesRootObjectDto.cs │ │ ├── SpecificationAttributeDto.cs │ │ ├── SpecificationAttributeOptionDto.cs │ │ ├── SpecificationAttributesCountRootObject.cs │ │ └── SpecificationAttributesRootObjectDto.cs │ └── Stores │ │ ├── StoreDto.cs │ │ └── StoresRootObject.cs ├── Data │ └── ApiObjectContext.cs ├── DataMappings │ └── WebHooksMap.cs ├── DataStructures │ └── ApiList.cs ├── Delta │ └── Delta.cs ├── Domain │ ├── ApiSettings.cs │ └── WebHooks.cs ├── Factories │ ├── AddressFactory.cs │ ├── CategoryFactory.cs │ ├── CustomerFactory.cs │ ├── IFactory.cs │ ├── ManufacturerFactory.cs │ ├── OrderFactory.cs │ ├── ProductFactory.cs │ └── ShoppingCartItemFactory.cs ├── Helpers │ ├── CryptoHelper.cs │ ├── CustomerRolesHelper.cs │ ├── DTOHelper.cs │ ├── IConfigManаgerHelper.cs │ ├── ICustomerRolesHelper.cs │ ├── IDTOHelper.cs │ ├── IJsonHelper.cs │ ├── IMappingHelper.cs │ ├── JTokenHelper.cs │ ├── JsonHelper.cs │ ├── MappingHelper.cs │ ├── NopConfigManаgerHelper.cs │ └── ReflectionHelper.cs ├── IdentityServer │ ├── Endpoints │ │ ├── AuthorizeCallbackEndpoint.cs │ │ ├── AuthorizeEndpoint.cs │ │ ├── AuthorizeEndpointBase.cs │ │ ├── AuthorizeResponseExtensions.cs │ │ ├── AuthorizeResult.cs │ │ ├── TokenEndpoint.cs │ │ ├── TokenErrorResult.cs │ │ └── TokenResult.cs │ ├── Extensions │ │ ├── NameValueCollectionExtensions.cs │ │ └── StringsExtensions.cs │ ├── Generators │ │ └── CustomAuthorizeInteractionResponseGenerator.cs │ ├── Infrastructure │ │ └── ObjectSerializer.cs │ ├── Middlewares │ │ └── IdentityServerScopeParameterMiddleware.cs │ └── Services │ │ └── ProfileService.cs ├── Infrastructure │ └── DependencyRegister.cs ├── JSON │ ├── ActionResults │ │ ├── ErrorActionResult.cs │ │ └── RawJsonActionResult.cs │ └── Serializers │ │ ├── IJsonFieldsSerializer.cs │ │ └── JsonFieldsSerializer.cs ├── KendoUI │ ├── DataSourceRequest.cs │ └── DataSourceResult.cs ├── MappingExtensions │ ├── AddressDtoMappings.cs │ ├── BaseMapping.cs │ ├── CategoryDtoMappings.cs │ ├── ClientMappings.cs │ ├── ConfigurationMappings.cs │ ├── CustomerDtoMappings.cs │ ├── CustomerRoleDtoMappings.cs │ ├── LanguageDtoMappings.cs │ ├── ManufacturerDtoMappings.cs │ ├── NewsLetterSubscriptoonDtoMappings.cs │ ├── OrderDtoMappings.cs │ ├── OrderItemDtoMappings.cs │ ├── ProductAttributeCombinationDtoMappings.cs │ ├── ProductAttributeDtoMappings.cs │ ├── ProductCategoryMappingDtoMappings.cs │ ├── ProductDtoMappings.cs │ ├── ProductManufacturerMappingDtoMappings.cs │ ├── ShoppingCartItemDtoMappings.cs │ ├── SpecificationAttributeDtoMapping.cs │ └── StoreDtoMappings.cs ├── Maps │ ├── IJsonPropertyMap.cs │ └── JsonPropertyMap.cs ├── Migrations │ └── IdentityServer │ │ ├── ConfigurationDb │ │ ├── 20170319181717_Config.Designer.cs │ │ ├── 20170319181717_Config.cs │ │ ├── 20171107104928_DotNetCore2IdentityServerConfigurationDbMigration.Designer.cs │ │ ├── 20171107104928_DotNetCore2IdentityServerConfigurationDbMigration.cs │ │ ├── 20191009140628_identityserver25update.Designer.cs │ │ ├── 20191009140628_identityserver25update.cs │ │ └── ConfigurationDbContextModelSnapshot.cs │ │ └── PersistedGrantDb │ │ ├── 20170319181710_Grants.Designer.cs │ │ ├── 20170319181710_Grants.cs │ │ ├── 20191009140613_identityserver25update.Designer.cs │ │ ├── 20191009140613_identityserver25update.cs │ │ └── PersistedGrantDbContextModelSnapshot.cs ├── ModelBinders │ ├── JsonModelBinder.cs │ └── ParametersModelBinder.cs ├── Models │ ├── CategoriesParameters │ │ ├── BaseCategoriesParametersModel.cs │ │ ├── CategoriesCountParametersModel.cs │ │ └── CategoriesParametersModel.cs │ ├── ClientApiModel.cs │ ├── ConfigurationModel.cs │ ├── CustomersParameters │ │ ├── CustomersParametersModel.cs │ │ └── CustomersSearchParametersModel.cs │ ├── DefaultWeApiErrorsModel.cs │ ├── ManufacturersParameters │ │ ├── BaseManufacturersParametersModel.cs │ │ ├── ManufacturersCountParametersModel.cs │ │ └── ManufacturersParametersModel.cs │ ├── NewsLetterSubscriptionsParameters │ │ └── NewsLetterSubscriptionsParametersModel.cs │ ├── OrderItemsParameters │ │ └── OrderItemsParametersModel.cs │ ├── OrdersParameters │ │ ├── BaseOrdersParametersModel.cs │ │ ├── OrdersCountParametersModel.cs │ │ └── OrdersParametersModel.cs │ ├── ProductAttributesParameters │ │ └── ProductAttributesParametersModel.cs │ ├── ProductCategoryMappingsParameters │ │ ├── BaseCategoryMappingsParametersModel.cs │ │ ├── ProductCategoryMappingsCountParametersModel.cs │ │ └── ProductCategoryMappingsParametersModel.cs │ ├── ProductManufacturerMappingsParameters │ │ ├── BaseManufacturerMappingsParametersModel.cs │ │ ├── ProductManufacturerMappingsCountParametersModel.cs │ │ └── ProductManufacturerMappingsParametersModel.cs │ ├── ProductSpecificationAttributesParameters │ │ ├── ProductSpecificationAttributesCountParametersModel.cs │ │ └── ProductSpecificationAttributesParametersModel.cs │ ├── ProductsParameters │ │ ├── BaseProductsParametersModel.cs │ │ ├── ProductsCountParametersModel.cs │ │ └── ProductsParametersModel.cs │ ├── ShoppingCartsParameters │ │ ├── BaseShoppingCartItemsParametersModel.cs │ │ ├── ShoppingCartItemsForCustomerParametersModel.cs │ │ └── ShoppingCartItemsParametersModel.cs │ └── SpecificationAttributesParameters │ │ ├── SpecificationAttributesCountParametersModel.cs │ │ └── SpecificationAttributesParametersModel.cs ├── Nop.Plugin.Api.csproj ├── RouteProvider.cs ├── Services │ ├── CategoryApiService.cs │ ├── ClientService.cs │ ├── CustomerApiService.cs │ ├── ICategoryApiService.cs │ ├── IClientService.cs │ ├── ICustomerApiService.cs │ ├── IManufacturerApiService.cs │ ├── INewsLetterSubscriptionApiService.cs │ ├── IOrderApiService.cs │ ├── IOrderItemApiService.cs │ ├── IProductApiService.cs │ ├── IProductAttributeConverter.cs │ ├── IProductAttributesApiService.cs │ ├── IProductCategoryMappingsApiService.cs │ ├── IProductManufacturerMappingsApiService.cs │ ├── IProductPictureService.cs │ ├── IShoppingCartItemApiService.cs │ ├── ISpecificationAttributeApiService.cs │ ├── IWebHookService.cs │ ├── ManufacturerApiService.cs │ ├── NewsLetterSubscriptionApiService.cs │ ├── OrderApiService.cs │ ├── OrderItemApiService.cs │ ├── ProductApiService.cs │ ├── ProductAttributeConverter.cs │ ├── ProductAttributesApiService.cs │ ├── ProductCategoryMappingsApiService.cs │ ├── ProductManufacturerMappingsApiService.cs │ ├── ProductPictureService.cs │ ├── ShoppingCartItemApiService.cs │ ├── SpecificationAttributesApiService.cs │ └── WebHookService.cs ├── Validators │ ├── AddressDtoValidator.cs │ ├── BaseDtoValidator.cs │ ├── CategoryDtoValidator.cs │ ├── ClientValidator.cs │ ├── CustomerDtoValidator.cs │ ├── FieldsValidator.cs │ ├── IFieldsValidator.cs │ ├── ManufacturerDtoValidator.cs │ ├── OrderDtoValidator.cs │ ├── OrderItemDtoValidator.cs │ ├── ProductAttributeCombinationDtoValidator.cs │ ├── ProductAttributeDtoValidator.cs │ ├── ProductCategoryMappingDtoValidator.cs │ ├── ProductDtoValidator.cs │ ├── ProductManufacturerMappingDtoValidator.cs │ ├── ProductSpecificationAttributeDtoValidator.cs │ ├── ShoppingCartItemDtoValidator.cs │ ├── SpecificationAttributeDtoValidator.cs │ ├── SpecificationAttributeOptionDtoValidator.cs │ └── TypeValidator.cs ├── Views │ ├── Clients │ │ ├── ClientSettings.cshtml │ │ ├── Create.cshtml │ │ ├── CreateOrUpdate.cshtml │ │ ├── Edit.cshtml │ │ └── List.cshtml │ ├── Settings.cshtml │ └── _ViewImports.cshtml ├── WebHooks │ ├── ApiWebHookSender.cs │ ├── FilterProvider.cs │ ├── NopWebHooksLogger.cs │ └── WebHookEventConsumer.cs ├── logo.jpg ├── plugin.json └── upgrade_script.sql ├── OrderItems.md ├── Orders.md ├── ProductCategoryMappings.md ├── Products.md ├── README.md ├── ShoppingCartItems.md ├── WebHooks.md └── uploadedItems.json /Categories.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Nop-Templates.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/ControllersTests/Orders/OrdersControllerTests_GetOrdersByCustomerId.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using AutoMock; 3 | using Nop.Core.Domain.Orders; 4 | using Nop.Plugin.Api.Controllers; 5 | using Nop.Plugin.Api.Services; 6 | using NUnit.Framework; 7 | using Rhino.Mocks; 8 | 9 | namespace Nop.Plugin.Api.Tests.ControllersTests.Orders 10 | { 11 | [TestFixture] 12 | public class OrdersControllerTests_GetOrdersByCustomerId 13 | { 14 | [Test] 15 | [TestCase(-5)] 16 | [TestCase(0)] 17 | [TestCase(10)] 18 | [TestCase(int.MaxValue)] 19 | public void WhenCustomerIdIsPassed_ShouldCallTheServiceWithThePassedParameters(int customerId) 20 | { 21 | // Arange 22 | var autoMocker = new RhinoAutoMocker(); 23 | 24 | autoMocker.Get().Expect(x => x.GetOrdersByCustomerId(customerId)).Return(new List()); 25 | 26 | // Act 27 | autoMocker.ClassUnderTest.GetOrdersByCustomerId(customerId); 28 | 29 | // Assert 30 | autoMocker.Get().VerifyAllExpectations(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/ConvertersTests/ApiTypeConverter/ApiTypeConverterTests_ToInt.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.Converters; 2 | using NUnit.Framework; 3 | 4 | namespace Nop.Plugin.Api.Tests.ConvertersTests.ApiTypeConverter 5 | { 6 | [TestFixture] 7 | public class ApiTypeConverterTests_ToInt 8 | { 9 | private IApiTypeConverter _apiTypeConverter; 10 | 11 | [SetUp] 12 | public void SetUp() 13 | { 14 | _apiTypeConverter = new Converters.ApiTypeConverter(); 15 | } 16 | 17 | [Test] 18 | [TestCase("3ed")] 19 | [TestCase("sd4")] 20 | [TestCase("675435345345345345345345343456546")] 21 | [TestCase("-675435345345345345345345343456546")] 22 | [TestCase("$%%^%^$#^&&%#)__(^&")] 23 | [TestCase("2015-02-12")] 24 | [TestCase("12:45")] 25 | public void WhenInvalidIntPassed_ShouldReturnZero(string invalidInt) 26 | { 27 | //Arange 28 | 29 | //Act 30 | int result = _apiTypeConverter.ToInt(invalidInt); 31 | 32 | //Assert 33 | Assert.AreEqual(0, result); 34 | } 35 | 36 | [Test] 37 | [TestCase("")] 38 | [TestCase(null)] 39 | public void WhenNullOrEmptyStringPassed_ShouldReturnZero(string nullOrEmpty) 40 | { 41 | //Arange 42 | 43 | //Act 44 | int result = _apiTypeConverter.ToInt(nullOrEmpty); 45 | 46 | //Assert 47 | Assert.AreEqual(0, result); 48 | } 49 | 50 | [Test] 51 | [TestCase("3")] 52 | [TestCase("234234")] 53 | [TestCase("0")] 54 | [TestCase("-44")] 55 | [TestCase("000000005")] 56 | public void WhenValidIntPassed_ShouldReturnThatInt(string validInt) 57 | { 58 | //Arange 59 | int valid = int.Parse(validInt); 60 | 61 | //Act 62 | int result = _apiTypeConverter.ToInt(validInt); 63 | 64 | //Assert 65 | Assert.AreEqual(valid, result); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/ConvertersTests/ApiTypeConverter/ApiTypeConverterTests_ToIntNullable.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.Converters; 2 | using NUnit.Framework; 3 | 4 | namespace Nop.Plugin.Api.Tests.ConvertersTests.ApiTypeConverter 5 | { 6 | [TestFixture] 7 | public class ApiTypeConverterTests_ToIntNullable 8 | { 9 | private IApiTypeConverter _apiTypeConverter; 10 | 11 | [SetUp] 12 | public void SetUp() 13 | { 14 | _apiTypeConverter = new Converters.ApiTypeConverter(); 15 | } 16 | 17 | [Test] 18 | [TestCase("3ed")] 19 | [TestCase("sd4")] 20 | [TestCase("675435345345345345345345343456546")] 21 | [TestCase("-675435345345345345345345343456546")] 22 | [TestCase("$%%^%^$#^&&%#)__(^&")] 23 | [TestCase("2015-02-12")] 24 | [TestCase("12:45")] 25 | public void WhenInvalidIntPassed_ShouldReturnNull(string invalidInt) 26 | { 27 | //Arange 28 | 29 | //Act 30 | int? result = _apiTypeConverter.ToIntNullable(invalidInt); 31 | 32 | //Assert 33 | Assert.IsNull(result); 34 | } 35 | 36 | [Test] 37 | [TestCase("")] 38 | [TestCase(null)] 39 | public void WhenNullOrEmptyStringPassed_ShouldReturnNull(string nullOrEmpty) 40 | { 41 | //Arange 42 | 43 | //Act 44 | int? result = _apiTypeConverter.ToIntNullable(nullOrEmpty); 45 | 46 | //Assert 47 | Assert.IsNull(result); 48 | } 49 | 50 | [Test] 51 | [TestCase("3")] 52 | [TestCase("234234")] 53 | [TestCase("0")] 54 | [TestCase("-44")] 55 | [TestCase("000000005")] 56 | public void WhenValidIntPassed_ShouldReturnThatInt(string validInt) 57 | { 58 | //Arange 59 | int valid = int.Parse(validInt); 60 | 61 | //Act 62 | int? result = _apiTypeConverter.ToIntNullable(validInt); 63 | 64 | //Assert 65 | Assert.AreEqual(valid, result); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/ConvertersTests/ObjectConverter/DummyObjects/SomeTestingObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nop.Core.Domain.Orders; 3 | using Nop.Core.Domain.Payments; 4 | using Nop.Core.Domain.Shipping; 5 | 6 | namespace Nop.Plugin.Api.Tests.ConvertersTests.ObjectConverter.DummyObjects 7 | { 8 | public class SomeTestingObject 9 | { 10 | public int IntProperty { get; set; } 11 | public string StringProperty { get; set; } 12 | public DateTime? DateTimeNullableProperty { get; set; } 13 | public bool? BooleanNullableStatusProperty { get; set; } 14 | public OrderStatus? OrderStatus { get; set; } 15 | public PaymentStatus? PaymentStatus { get; set; } 16 | public ShippingStatus? ShippingStatus { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/Helpers/ActionResultExecutor.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Tests.Helpers 2 | { 3 | using System.Net; 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Rhino.Mocks; 7 | 8 | public static class ActionResultExecutor 9 | { 10 | public static HttpStatusCode ExecuteResult(IActionResult result) 11 | { 12 | var actionContext = MockRepository.GenerateStub(); 13 | actionContext.HttpContext = new DefaultHttpContext(); 14 | 15 | result.ExecuteResultAsync(actionContext); 16 | var statusCode = actionContext.HttpContext.Response.StatusCode; 17 | 18 | return (HttpStatusCode)statusCode; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/ModelBinderTests/DummyObjects/DummyModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Nop.Plugin.Api.Tests.ModelBinderTests.DummyObjects 4 | { 5 | public class DummyModel 6 | { 7 | public string StringProperty { get; set; } 8 | public int IntProperty { get; set; } 9 | public int? IntNullableProperty { get; set; } 10 | public DateTime? DateTimeNullableProperty { get; set; } 11 | public bool? BooleanNullableStatusProperty { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/Nop.Plugin.Api.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net461 4 | 4.0.0.0 5 | Nop-Templates, Ltd 6 | Nop-Templates, Ltd 7 | The project contains a set of classes for testing of Nop.Plugin.Api 8 | Copyright © Nop-Templates, Ltd 9 | Git 10 | Nop.Plugin.Api.Tests 11 | 12 | 13 | 14 | 1.0.3.2 15 | 16 | 17 | 3.9.0 18 | 19 | 20 | 3.6.1 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/SerializersTests/DummyObjects/DummyObjectWithComplexTypes.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Nop.Plugin.Api.Tests.SerializersTests.DummyObjects 5 | { 6 | public class DummyObjectWithComplexTypes 7 | { 8 | [JsonProperty("string_property")] 9 | public string StringProperty { get; set; } 10 | 11 | [JsonProperty("int_property")] 12 | public int IntProperty { get; set; } 13 | 14 | [JsonProperty("bool_property")] 15 | public bool BoolProperty { get; set; } 16 | 17 | [JsonProperty("list_of_dummy_object_with_simple_types")] 18 | public IList ListOfDummyObjectWithSimpleTypes { get; set; } 19 | 20 | [JsonProperty("dummy_object_with_simple_types")] 21 | public DummyObjectWithSimpleTypes DummyObjectWithSimpleTypes { get; set; } 22 | 23 | public override bool Equals(object obj) 24 | { 25 | if (obj is DummyObjectWithComplexTypes) 26 | { 27 | var that = obj as DummyObjectWithComplexTypes; 28 | 29 | return that.StringProperty.Equals(StringProperty) && 30 | that.IntProperty == IntProperty && 31 | that.BoolProperty == BoolProperty && 32 | that.ListOfDummyObjectWithSimpleTypes.Equals(ListOfDummyObjectWithSimpleTypes) && 33 | that.DummyObjectWithSimpleTypes.Equals(DummyObjectWithSimpleTypes); 34 | } 35 | 36 | return false; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/SerializersTests/DummyObjects/DummyObjectWithSimpleTypes.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.Tests.SerializersTests.DummyObjects 4 | { 5 | public class DummyObjectWithSimpleTypes 6 | { 7 | [JsonProperty("first_property")] 8 | public string FirstProperty { get; set; } 9 | 10 | [JsonProperty("second_property")] 11 | public string SecondProperty { get; set; } 12 | 13 | public override bool Equals(object obj) 14 | { 15 | if (obj is DummyObjectWithSimpleTypes) 16 | { 17 | var that = obj as DummyObjectWithSimpleTypes; 18 | 19 | return that.FirstProperty.Equals(FirstProperty) && that.SecondProperty.Equals(SecondProperty); 20 | } 21 | 22 | return false; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/SerializersTests/DummyObjects/SerializableDummyObjectWithComplexTypes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | using Nop.Plugin.Api.DTOs; 5 | 6 | namespace Nop.Plugin.Api.Tests.SerializersTests.DummyObjects 7 | { 8 | public class SerializableDummyObjectWithComplexTypes : ISerializableObject 9 | { 10 | public SerializableDummyObjectWithComplexTypes() 11 | { 12 | Items = new List(); 13 | } 14 | 15 | [JsonProperty("primary_complex_property")] 16 | public IList Items { get; set; } 17 | 18 | public string GetPrimaryPropertyName() 19 | { 20 | return "primary_complex_property"; 21 | } 22 | 23 | public Type GetPrimaryPropertyType() 24 | { 25 | return typeof(DummyObjectWithComplexTypes); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/SerializersTests/DummyObjects/SerializableDummyObjectWithSimpleTypes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | using Nop.Plugin.Api.DTOs; 5 | 6 | namespace Nop.Plugin.Api.Tests.SerializersTests.DummyObjects 7 | { 8 | public class SerializableDummyObjectWithSimpleTypes : ISerializableObject 9 | { 10 | public SerializableDummyObjectWithSimpleTypes() 11 | { 12 | Items = new List(); 13 | } 14 | 15 | [JsonProperty("primary_property")] 16 | public IList Items { get; set; } 17 | 18 | public string GetPrimaryPropertyName() 19 | { 20 | return "primary_property"; 21 | } 22 | 23 | public Type GetPrimaryPropertyType() 24 | { 25 | return typeof (DummyObjectWithSimpleTypes); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/ServicesTests/CountryApiServiceTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Nop.Core.Data; 4 | using Nop.Core.Domain.Directory; 5 | using Nop.Plugin.Api.Services; 6 | using NUnit.Framework; 7 | using Rhino.Mocks; 8 | 9 | namespace Nop.Plugin.Api.Tests.ServicesTests 10 | { 11 | //[TestFixture] 12 | //public class CountryApiServiceTests 13 | //{ 14 | // private ICountryApiService _countryApiService; 15 | 16 | // [SetUp] 17 | // public new void SetUp() 18 | // { 19 | // var countryRepositoryStub = MockRepository.GenerateStub>(); 20 | 21 | // countryRepositoryStub.Stub(x => x.Table).Return((new List() 22 | // { 23 | 24 | // new Country() 25 | // { 26 | // Name = "test country 1" 27 | // }, 28 | // new Country() 29 | // { 30 | // Name = "test country 2" 31 | // } 32 | 33 | // }).AsQueryable()); 34 | 35 | // _countryApiService = new CountryApiService(countryRepositoryStub); 36 | // } 37 | 38 | // [Test] 39 | // public void Get_country_by_existing_name() 40 | // { 41 | // var countryResult = _countryApiService.GetCountryByName("test country 1"); 42 | 43 | // Assert.IsNotNull(countryResult); 44 | // Assert.AreEqual("test country 1", countryResult.Name); 45 | // } 46 | 47 | // [Test] 48 | // public void Get_country_by_non_existing_name() 49 | // { 50 | // var countryResult = _countryApiService.GetCountryByName("non existing country name"); 51 | 52 | // Assert.IsNull(countryResult); 53 | // } 54 | //} 55 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/ServicesTests/StateProvinceApiServiceTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Nop.Core.Data; 4 | using Nop.Core.Domain.Directory; 5 | using Nop.Plugin.Api.Services; 6 | using NUnit.Framework; 7 | using Rhino.Mocks; 8 | 9 | namespace Nop.Plugin.Api.Tests.ServicesTests 10 | { 11 | //[TestFixture] 12 | //public class StateProvinceApiServiceTests 13 | //{ 14 | // private IStateProvinceApiService _stateProvinceApiService; 15 | 16 | // [SetUp] 17 | // public new void SetUp() 18 | // { 19 | // var stateProvinceRepositoryStub = MockRepository.GenerateStub>(); 20 | 21 | // stateProvinceRepositoryStub.Stub(x => x.Table).Return((new List() 22 | // { 23 | // new StateProvince() 24 | // { 25 | // Name = "test state 1" 26 | // }, 27 | // new StateProvince() 28 | // { 29 | // Name = "test state 2" 30 | // } 31 | // }).AsQueryable()); 32 | 33 | // _stateProvinceApiService = new StateProvinceApiService(stateProvinceRepositoryStub); 34 | // } 35 | 36 | // [Test] 37 | // public void Get_state_by_existing_name() 38 | // { 39 | // StateProvince state = _stateProvinceApiService.GetStateProvinceByName("test state 1"); 40 | 41 | // Assert.IsNotNull(state); 42 | // Assert.AreEqual("test state 1", state.Name); 43 | // } 44 | 45 | // [Test] 46 | // public void Get_state_by_non_existing_name() 47 | // { 48 | // StateProvince state = _stateProvinceApiService.GetStateProvinceByName("non existing state name"); 49 | 50 | // Assert.IsNull(state); 51 | // } 52 | //} 53 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/SetUp.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Nop.Plugin.Api.Tests 4 | { 5 | [SetUpFixture] 6 | public class SetUp 7 | { 8 | [OneTimeSetUp] 9 | public void RunBeforeAnyTests() 10 | { 11 | // We need to create all the mappings before any of the test are run 12 | // All maps are created in the ApiMapperConfiguration constructor. 13 | ApiMapperConfiguration mapps = new ApiMapperConfiguration(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/ValidatorTests/TypeValidatorTests_IsValid.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Globalization; 3 | using System.Threading; 4 | using Nop.Plugin.Api.DTOs.Products; 5 | using NUnit.Framework; 6 | using Nop.Plugin.Api.Tests.SerializersTests.DummyObjects; 7 | using Nop.Plugin.Api.Validators; 8 | 9 | namespace Nop.Plugin.Api.Tests.ValidatorTests 10 | { 11 | public class TypeValidatorTests_IsValid 12 | { 13 | [Test] 14 | [SetCulture("de-de")] 15 | [Description("Regression test for issue #11 - https://github.com/SevenSpikes/api-plugin-for-nopcommerce/issues/11")] 16 | public void WhenCurrentCultureUsesCommaAsDecimalPoint_ShouldProperlyValidateProductPrice() 17 | { 18 | //Arange 19 | Dictionary properties = new Dictionary(); 20 | properties.Add("price", 33.33); 21 | 22 | var cut = new TypeValidator(); 23 | 24 | //Act 25 | bool result = cut.IsValid(properties); 26 | 27 | // Assert 28 | Assert.IsTrue(result); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/ApiAuthentication.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api 2 | { 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Security.Cryptography.X509Certificates; 6 | using IdentityModel; 7 | using Microsoft.AspNetCore.Authentication; 8 | using Microsoft.AspNetCore.Authentication.JwtBearer; 9 | using Microsoft.Extensions.DependencyInjection; 10 | using Microsoft.IdentityModel.Tokens; 11 | using Nop.Plugin.Api.Helpers; 12 | using Nop.Services.Authentication.External; 13 | using Org.BouncyCastle.Asn1.X509.Qualified; 14 | 15 | public class ApiAuthentication : IExternalAuthenticationRegistrar 16 | { 17 | public void Configure(AuthenticationBuilder builder) 18 | { 19 | RsaSecurityKey signingKey = CryptoHelper.CreateRsaSecurityKey(); 20 | 21 | builder.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, jwt => 22 | { 23 | jwt.Audience = "nop_api"; 24 | jwt.TokenValidationParameters = new TokenValidationParameters 25 | { 26 | ValidateActor = false, 27 | ValidateIssuer = false, 28 | NameClaimType = JwtClaimTypes.Name, 29 | RoleClaimType = JwtClaimTypes.Role, 30 | // Uncomment this if you are using an certificate to sign your tokens. 31 | // IssuerSigningKey = new X509SecurityKey(cert), 32 | IssuerSigningKeyResolver = (string token, SecurityToken securityToken, string kid, 33 | TokenValidationParameters validationParameters) => 34 | new List { signingKey } 35 | }; 36 | }); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Attributes/ApiAuthorize.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Infrastructure; 2 | using Nop.Services.Plugins; 3 | 4 | namespace Nop.Plugin.Api.Attributes 5 | { 6 | using Microsoft.AspNetCore.Authorization; 7 | 8 | // We need the ApiAuthorize attribute because when the api plugin assembly is loaded in memory by PluginManager 9 | // all of its attributes are being initialized by the .NetFramework. 10 | // The authorize attribute of the api plugin is marked with the Bearer authentication scheme, but the scheme is registered in the ApiStartup class, 11 | // which is called on plugin install. 12 | // If the plugin is not installed the authorize attribute will still be initialized when the assembly is loaded in memory, but the scheme won't be registered, 13 | // which will cause an exception. 14 | // That is why we need to make sure that the plugin is installed before setting the scheme. 15 | public class ApiAuthorize : AuthorizeAttribute 16 | { 17 | public new string Policy 18 | { 19 | get => base.AuthenticationSchemes; 20 | set => base.AuthenticationSchemes = GetAuthenticationSchemeName(value); 21 | } 22 | 23 | public new string AuthenticationSchemes 24 | { 25 | get => base.AuthenticationSchemes; 26 | set => base.AuthenticationSchemes = GetAuthenticationSchemeName(value); 27 | } 28 | 29 | private static string GetAuthenticationSchemeName(string value) 30 | { 31 | var pluginService = EngineContext.Current.Resolve(); 32 | var pluginDescriptor = pluginService.GetPluginDescriptorBySystemName(Nop.Plugin.Api.Constants.Plugin.SystemName); 33 | bool pluginInstalled = pluginDescriptor != null && pluginDescriptor.Installed; 34 | 35 | if (pluginInstalled) 36 | { 37 | return value; 38 | } 39 | 40 | return default(string); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Attributes/BaseAttributeInvoker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Nop.Plugin.Api.Attributes 5 | { 6 | public abstract class BaseValidationAttribute : Attribute 7 | { 8 | public abstract void Validate(object instance); 9 | public abstract Dictionary GetErrors(); 10 | } 11 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Attributes/DoNotMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Nop.Plugin.Api.Attributes 4 | { 5 | public class DoNotMapAttribute : Attribute 6 | { 7 | // just a marker 8 | } 9 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Attributes/ImageCollectionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Nop.Plugin.Api.DTOs.Images; 3 | 4 | namespace Nop.Plugin.Api.Attributes 5 | { 6 | public class ImageCollectionValidationAttribute : BaseValidationAttribute 7 | { 8 | private Dictionary _errors = new Dictionary(); 9 | 10 | public override void Validate(object instance) 11 | { 12 | // Images are not required so they could be null 13 | // and there is nothing to validate in this case 14 | if (instance == null) 15 | return; 16 | 17 | var imagesCollection = instance as ICollection; 18 | 19 | foreach (var image in imagesCollection) 20 | { 21 | var imageValidationAttribute = new ImageValidationAttribute(); 22 | 23 | imageValidationAttribute.Validate(image); 24 | 25 | var errorsForImage = imageValidationAttribute.GetErrors(); 26 | 27 | if (errorsForImage.Count > 0) 28 | { 29 | _errors = errorsForImage; 30 | break; 31 | } 32 | } 33 | } 34 | 35 | public override Dictionary GetErrors() 36 | { 37 | return _errors; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Attributes/ProductTypeValidationAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Nop.Core.Domain.Catalog; 4 | 5 | namespace Nop.Plugin.Api.Attributes 6 | { 7 | public class ProductTypeValidationAttribute : BaseValidationAttribute 8 | { 9 | private readonly Dictionary _errors = new Dictionary(); 10 | 11 | public override void Validate(object instance) 12 | { 13 | // Product Type is not required so it could be null 14 | // and there is nothing to validate in this case 15 | if (instance == null) 16 | return; 17 | 18 | var isDefined = Enum.IsDefined(typeof(ProductType), instance); 19 | 20 | if (!isDefined) 21 | { 22 | _errors.Add("ProductType","Invalid product type"); 23 | } 24 | } 25 | 26 | public override Dictionary GetErrors() 27 | { 28 | return _errors; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Attributes/ValidateVendor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Nop.Core.Infrastructure; 3 | using Nop.Services.Vendors; 4 | 5 | namespace Nop.Plugin.Api.Attributes 6 | { 7 | public class ValidateVendor : BaseValidationAttribute 8 | { 9 | private Dictionary _errors; 10 | 11 | private IVendorService _vendorService; 12 | 13 | private IVendorService VendorService 14 | { 15 | get 16 | { 17 | if (_vendorService == null) 18 | { 19 | _vendorService = EngineContext.Current.Resolve(); 20 | } 21 | 22 | return _vendorService; 23 | } 24 | } 25 | 26 | public ValidateVendor() 27 | { 28 | _errors = new Dictionary(); 29 | } 30 | 31 | public override void Validate(object instance) 32 | { 33 | var vendorId = 0; 34 | 35 | if (instance != null && int.TryParse(instance.ToString(), out vendorId)) 36 | { 37 | if (vendorId > 0) 38 | { 39 | var vendor = VendorService.GetVendorById(vendorId); 40 | 41 | if (vendor == null) 42 | { 43 | _errors.Add("Invalid vendor id", "Non existing vendor"); 44 | } 45 | } 46 | } 47 | } 48 | 49 | public override Dictionary GetErrors() 50 | { 51 | return _errors; 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Authorization/Policies/ActiveApiPluginAuthorizationPolicy.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Authorization.Policies 2 | { 3 | using System.Threading.Tasks; 4 | using Microsoft.AspNetCore.Authorization; 5 | using Nop.Plugin.Api.Authorization.Requirements; 6 | 7 | public class ActiveApiPluginAuthorizationPolicy : AuthorizationHandler 8 | { 9 | protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, ActiveApiPluginRequirement requirement) 10 | { 11 | if (requirement.IsActive()) 12 | { 13 | context.Succeed(requirement); 14 | } 15 | else 16 | { 17 | context.Fail(); 18 | } 19 | 20 | return Task.CompletedTask; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Authorization/Policies/ActiveClientAuthorizationPolicy.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Authorization.Policies 2 | { 3 | using System.Threading.Tasks; 4 | using Microsoft.AspNetCore.Authorization; 5 | using Nop.Plugin.Api.Authorization.Requirements; 6 | 7 | public class ActiveClientAuthorizationPolicy : AuthorizationHandler 8 | { 9 | protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, ActiveClientRequirement requirement) 10 | { 11 | if (requirement.IsClientActive()) 12 | { 13 | context.Succeed(requirement); 14 | } 15 | else 16 | { 17 | context.Fail(); 18 | } 19 | 20 | return Task.CompletedTask; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Authorization/Policies/RequestsFromSwaggerAuthorizationPolicy.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Authorization.Policies 2 | { 3 | using System.Threading.Tasks; 4 | using Microsoft.AspNetCore.Authorization; 5 | using Nop.Plugin.Api.Authorization.Requirements; 6 | 7 | public class RequestsFromSwaggerAuthorizationPolicy : AuthorizationHandler 8 | { 9 | protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RequestFromSwaggerOptional requirement) 10 | { 11 | if (requirement.AllowRequestsFromSwagger()) 12 | { 13 | if (requirement.IsRequestFromSwagger(context.Resource as string)) 14 | { 15 | context.Succeed(requirement); 16 | } 17 | else 18 | { 19 | context.Fail(); 20 | } 21 | } 22 | else 23 | { 24 | context.Succeed(requirement); 25 | } 26 | 27 | return Task.CompletedTask; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Authorization/Policies/ValidSchemeAuthorizationPolicy.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Authorization.Policies 2 | { 3 | using System.Threading.Tasks; 4 | using Microsoft.AspNetCore.Authorization; 5 | using Nop.Plugin.Api.Authorization.Requirements; 6 | 7 | public class ValidSchemeAuthorizationPolicy : AuthorizationHandler 8 | { 9 | protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, AuthorizationSchemeRequirement requirement) 10 | { 11 | var mvcContext = context.Resource as 12 | Microsoft.AspNetCore.Mvc.Filters.AuthorizationFilterContext; 13 | 14 | if (requirement.IsValid(mvcContext?.HttpContext.Request.Headers)) 15 | { 16 | context.Succeed(requirement); 17 | } 18 | else 19 | { 20 | context.Fail(); 21 | } 22 | 23 | return Task.CompletedTask; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Authorization/Requirements/ActiveApiPluginRequirement.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Authorization.Requirements 2 | { 3 | using Microsoft.AspNetCore.Authorization; 4 | using Nop.Core.Infrastructure; 5 | using Nop.Plugin.Api.Domain; 6 | 7 | public class ActiveApiPluginRequirement : IAuthorizationRequirement 8 | { 9 | public bool IsActive() 10 | { 11 | var settings = EngineContext.Current.Resolve(); 12 | 13 | if (settings.EnableApi) 14 | { 15 | return true; 16 | } 17 | 18 | return false; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Authorization/Requirements/ActiveClientRequirement.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Authorization.Requirements 2 | { 3 | using Microsoft.AspNetCore.Authorization; 4 | using Microsoft.AspNetCore.Http; 5 | using Nop.Core.Infrastructure; 6 | using Nop.Plugin.Api.Services; 7 | 8 | public class ActiveClientRequirement : IAuthorizationRequirement 9 | { 10 | public bool IsClientActive() 11 | { 12 | if (!ClientExistsAndActive()) 13 | { 14 | // don't authorize if any of the above is not true 15 | return false; 16 | } 17 | 18 | return true; 19 | } 20 | 21 | private bool ClientExistsAndActive() 22 | { 23 | var httpContextAccessor = EngineContext.Current.Resolve(); 24 | 25 | var clientId = 26 | httpContextAccessor.HttpContext.User.FindFirst("client_id")?.Value; 27 | 28 | if (clientId != null) 29 | { 30 | var clientService = EngineContext.Current.Resolve(); 31 | var client = clientService.FindClientByClientId(clientId); 32 | 33 | if (client != null && client.Enabled) 34 | { 35 | return true; 36 | } 37 | } 38 | 39 | return false; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Authorization/Requirements/AuthorizationSchemeRequirement.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Authorization.Requirements 2 | { 3 | using Microsoft.AspNetCore.Authentication.JwtBearer; 4 | using Microsoft.AspNetCore.Authorization; 5 | using Microsoft.AspNetCore.Http; 6 | 7 | public class AuthorizationSchemeRequirement : IAuthorizationRequirement 8 | { 9 | public bool IsValid(IHeaderDictionary requestHeaders) 10 | { 11 | if (requestHeaders != null && 12 | requestHeaders.ContainsKey("Authorization") && 13 | requestHeaders["Authorization"].ToString().Contains(JwtBearerDefaults.AuthenticationScheme)) 14 | { 15 | return true; 16 | } 17 | 18 | return false; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Authorization/Requirements/RequestFromSwaggerOptional.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Authorization.Requirements 2 | { 3 | using Microsoft.AspNetCore.Authorization; 4 | using Nop.Core.Infrastructure; 5 | using Nop.Plugin.Api.Domain; 6 | 7 | public class RequestFromSwaggerOptional : IAuthorizationRequirement 8 | { 9 | public bool IsRequestFromSwagger(string requestReferrer) 10 | { 11 | // Swagger client does not support BearerToken authentication. 12 | // That is why we don't check for Bearer token authentication but check only 2 things: 13 | // 1. The store owner explicitly has allowed Swagger to make requests to the API 14 | // 2. Check if the request really comes from Swagger documentation page. Since Swagger documentation page is located on /swagger/index we simply check that the Refferer contains "swagger" 15 | if (requestReferrer != null && requestReferrer.Contains("swagger")) 16 | { 17 | return true; 18 | } 19 | 20 | return true; 21 | } 22 | 23 | public bool AllowRequestsFromSwagger() 24 | { 25 | var settings = EngineContext.Current.Resolve(); 26 | 27 | return settings.AllowRequestsFromSwagger; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/AutoMapper/AutoMapperApiConfiguration.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using AutoMapper.Configuration; 3 | 4 | namespace Nop.Plugin.Api.AutoMapper 5 | { 6 | public static class AutoMapperApiConfiguration 7 | { 8 | private static MapperConfigurationExpression s_mapperConfigurationExpression; 9 | private static IMapper s_mapper; 10 | private static readonly object s_mapperLockObject = new object(); 11 | 12 | public static MapperConfigurationExpression MapperConfigurationExpression => s_mapperConfigurationExpression ?? 13 | (s_mapperConfigurationExpression = new MapperConfigurationExpression()); 14 | 15 | public static IMapper Mapper 16 | { 17 | get 18 | { 19 | if (s_mapper == null) 20 | { 21 | lock (s_mapperLockObject) 22 | { 23 | if (s_mapper == null) 24 | { 25 | var mapperConfiguration = new MapperConfiguration(MapperConfigurationExpression); 26 | 27 | s_mapper = mapperConfiguration.CreateMapper(); 28 | } 29 | } 30 | } 31 | 32 | return s_mapper; 33 | } 34 | } 35 | 36 | public static TDestination MapTo(this TSource source) 37 | { 38 | return Mapper.Map(source); 39 | } 40 | 41 | public static TDestination MapTo(this TSource source, TDestination destination) 42 | { 43 | return Mapper.Map(source, destination); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Constants/Configurations.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Constants 2 | { 3 | public class Configurations 4 | { 5 | // time is in seconds (10 years = 315360000 seconds) and should not exceed 2038 year 6 | // https://stackoverflow.com/questions/43593074/jwt-validation-fails/43605820 7 | public const int DefaultAccessTokenExpiration = 315360000; 8 | public const int DefaultRefreshTokenExpiration = int.MaxValue; 9 | public const int DefaultLimit = 50; 10 | public const int DefaultPageValue = 1; 11 | public const int DefaultSinceId = 0; 12 | public const int DefaultCustomerId = 0; 13 | public const string DefaultOrder = "Id"; 14 | public const int MaxLimit = 250; 15 | public const int MinLimit = 1; 16 | public const string PublishedStatus = "published"; 17 | public const string UnpublishedStatus = "unpublished"; 18 | public const string AnyStatus = "any"; 19 | public const string JsonTypeMapsPattern = "json.maps"; 20 | 21 | public const string NEWSLETTER_SUBSCRIBERS_KEY = "Nop.api.newslettersubscribers"; 22 | } 23 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Constants/Plugin.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Constants 2 | { 3 | public class Plugin 4 | { 5 | public const string SystemName = "Nop.Plugin.Api"; 6 | } 7 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Constants/ViewNames.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Constants 2 | { 3 | public class ViewNames 4 | { 5 | public const string AdminApiSettings = "~/Plugins/Nop.Plugin.Api/Views/Settings.cshtml"; 6 | public const string AdminApiClientsCreateOrUpdate = "~/Plugins/Nop.Plugin.Api/Views/Clients/CreateOrUpdate.cshtml"; 7 | public const string AdminApiClientsSettings = "~/Plugins/Nop.Plugin.Api/Views/Clients/ClientSettings.cshtml"; 8 | public const string AdminApiClientsList = "~/Plugins/Nop.Plugin.Api/Views/Clients/List.cshtml"; 9 | public const string AdminApiClientsCreate = "~/Plugins/Nop.Plugin.Api/Views/Clients/Create.cshtml"; 10 | public const string AdminApiClientsEdit = "~/Plugins/Nop.Plugin.Api/Views/Clients/Edit.cshtml"; 11 | public const string AdminLayout = "_AdminLayout"; 12 | } 13 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Constants/WebHookNames.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Constants 2 | { 3 | public static class WebHookNames 4 | { 5 | public const string FiltersGetAction = "FiltersGetAction"; 6 | 7 | public const string GetWebhookByIdAction = "GetWebHookByIdAction"; 8 | 9 | public const string CustomersCreate = "customers/create"; 10 | public const string CustomersUpdate = "customers/update"; 11 | public const string CustomersDelete = "customers/delete"; 12 | 13 | public const string ProductsCreate = "products/create"; 14 | public const string ProductsUpdate = "products/update"; 15 | public const string ProductsDelete = "products/delete"; 16 | public const string ProductsUnmap = "products/unmap"; 17 | 18 | public const string CategoriesCreate = "categories/create"; 19 | public const string CategoriesUpdate = "categories/update"; 20 | public const string CategoriesDelete = "categories/delete"; 21 | public const string CategoriesUnmap = "categories/unmap"; 22 | 23 | public const string OrdersCreate = "orders/create"; 24 | public const string OrdersUpdate = "orders/update"; 25 | public const string OrdersDelete = "orders/delete"; 26 | 27 | public const string ProductCategoryMapsCreate = "product_category_maps/create"; 28 | public const string ProductCategoryMapsUpdate = "product_category_maps/update"; 29 | public const string ProductCategoryMapsDelete = "product_category_maps/delete"; 30 | 31 | public const string StoresUpdate = "stores/update"; 32 | 33 | public const string LanguagesCreate = "languages/create"; 34 | public const string LanguagesUpdate = "languages/update"; 35 | public const string LanguagesDelete = "languages/delete"; 36 | 37 | public const string NewsLetterSubscriptionCreate = "news_letter_subscription/create"; 38 | public const string NewsLetterSubscriptionUpdate = "news_letter_subscription/update"; 39 | public const string NewsLetterSubscriptionDelete = "news_letter_subscription/delete"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/Converters/IApiTypeConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Nop.Plugin.Api.Converters 5 | { 6 | public interface IApiTypeConverter 7 | { 8 | DateTime? ToUtcDateTimeNullable(string value); 9 | int ToInt(string value); 10 | int? ToIntNullable(string value); 11 | IList ToListOfInts(string value); 12 | bool? ToStatus(string value); 13 | object ToEnumNullable(string value, Type type); 14 | } 15 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Converters/IObjectConverter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Nop.Plugin.Api.Converters 4 | { 5 | public interface IObjectConverter 6 | { 7 | T ToObject(ICollection> source) 8 | where T : class, new(); 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Base/BaseDto.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.DTOs.Base 4 | { 5 | public abstract class BaseDto 6 | { 7 | [JsonProperty("id")] 8 | public int Id { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Categories/CategoriesCountRootObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.DTOs.Categories 4 | { 5 | public class CategoriesCountRootObject 6 | { 7 | [JsonProperty("count")] 8 | public int Count { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Categories/CategoriesRootObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.Categories 6 | { 7 | public class CategoriesRootObject : ISerializableObject 8 | { 9 | public CategoriesRootObject() 10 | { 11 | Categories = new List(); 12 | } 13 | 14 | [JsonProperty("categories")] 15 | public IList Categories { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "categories"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof (CategoryDto); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/CustomerRoles/CustomerRolesRootObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.CustomerRoles 6 | { 7 | public class CustomerRolesRootObject : ISerializableObject 8 | { 9 | public CustomerRolesRootObject() 10 | { 11 | CustomerRoles = new List(); 12 | } 13 | 14 | [JsonProperty("customer_roles")] 15 | public IList CustomerRoles { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "customer_roles"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof(CustomerRoleDto); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Customers/CustomerAttributeMappingDto.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Common; 2 | using Nop.Core.Domain.Customers; 3 | 4 | namespace Nop.Plugin.Api.DTOs.Customers 5 | { 6 | public class CustomerAttributeMappingDto 7 | { 8 | public Customer Customer { get; set; } 9 | public GenericAttribute Attribute { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Customers/CustomerDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Nop.Plugin.Api.Attributes; 4 | using Nop.Plugin.Api.DTOs.ShoppingCarts; 5 | using Nop.Plugin.Api.Validators; 6 | 7 | namespace Nop.Plugin.Api.DTOs.Customers 8 | { 9 | [JsonObject(Title = "customer")] 10 | public class CustomerDto : BaseCustomerDto 11 | { 12 | private ICollection _shoppingCartItems; 13 | private ICollection _addresses; 14 | 15 | [JsonIgnore] 16 | [JsonProperty("password")] 17 | public string Password { get; set; } 18 | 19 | #region Navigation properties 20 | 21 | /// 22 | /// Gets or sets shopping cart items 23 | /// 24 | [JsonProperty("shopping_cart_items")] 25 | [DoNotMap] 26 | public ICollection ShoppingCartItems 27 | { 28 | get 29 | { 30 | if (_shoppingCartItems == null) 31 | { 32 | _shoppingCartItems = new List(); 33 | } 34 | 35 | return _shoppingCartItems; 36 | } 37 | set { _shoppingCartItems = value; } 38 | } 39 | 40 | /// 41 | /// Default billing address 42 | /// 43 | [JsonProperty("billing_address")] 44 | public AddressDto BillingAddress { get; set; } 45 | 46 | /// 47 | /// Default shipping address 48 | /// 49 | [JsonProperty("shipping_address")] 50 | public AddressDto ShippingAddress { get; set; } 51 | 52 | /// 53 | /// Gets or sets customer addresses 54 | /// 55 | [JsonProperty("addresses")] 56 | public ICollection Addresses 57 | { 58 | get 59 | { 60 | if (_addresses == null) 61 | { 62 | _addresses = new List(); 63 | } 64 | 65 | return _addresses; 66 | } 67 | set { _addresses = value; } 68 | } 69 | #endregion 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Customers/CustomerForShoppingCartItemDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace Nop.Plugin.Api.DTOs.Customers 5 | { 6 | // We need this DTO object to avoid loop in the entity to dto mappings. The difference is the missing ShoppingCartItems collection. 7 | [JsonObject(Title = "customers")] 8 | public class CustomerForShoppingCartItemDto : BaseCustomerDto 9 | { 10 | private ICollection _addresses; 11 | 12 | #region Navigation properties 13 | 14 | /// 15 | /// Default billing address 16 | /// 17 | [JsonProperty("billing_address")] 18 | public AddressDto BillingAddress { get; set; } 19 | 20 | /// 21 | /// Default shipping address 22 | /// 23 | [JsonProperty("shipping_address")] 24 | public AddressDto ShippingAddress { get; set; } 25 | 26 | /// 27 | /// Gets or sets customer addresses 28 | /// 29 | [JsonProperty("addresses")] 30 | public ICollection Addresses 31 | { 32 | get { return _addresses; } 33 | set { _addresses = value; } 34 | } 35 | #endregion 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Customers/CustomersCountRootObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.DTOs.Customers 4 | { 5 | public class CustomersCountRootObject 6 | { 7 | [JsonProperty("count")] 8 | public int Count { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Customers/CustomersRootObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.Customers 6 | { 7 | public class CustomersRootObject : ISerializableObject 8 | { 9 | public CustomersRootObject() 10 | { 11 | Customers = new List(); 12 | } 13 | 14 | [JsonProperty("customers")] 15 | public IList Customers { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "customers"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof (CustomerDto); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Customers/OrderCustomerDto.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.DTOs.Customers 2 | { 3 | public class OrderCustomerDto : BaseCustomerDto 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Errors/ErrorsRootObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.Errors 6 | { 7 | public class ErrorsRootObject : ISerializableObject 8 | { 9 | [JsonProperty("errors")] 10 | public Dictionary> Errors { get; set; } 11 | 12 | public string GetPrimaryPropertyName() 13 | { 14 | return "errors"; 15 | } 16 | 17 | public Type GetPrimaryPropertyType() 18 | { 19 | return Errors.GetType(); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/ISerializableObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Nop.Plugin.Api.DTOs 4 | { 5 | public interface ISerializableObject 6 | { 7 | string GetPrimaryPropertyName(); 8 | Type GetPrimaryPropertyType(); 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Images/ImageDto.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Nop.Plugin.Api.Attributes; 3 | 4 | namespace Nop.Plugin.Api.DTOs.Images 5 | { 6 | [ImageValidation] 7 | public class ImageDto 8 | { 9 | [JsonProperty("src")] 10 | public string Src { get; set; } 11 | 12 | [JsonProperty("attachment")] 13 | public string Attachment { get; set; } 14 | 15 | [JsonIgnore] 16 | public byte[] Binary { get; set; } 17 | 18 | [JsonIgnore] 19 | public string MimeType { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Images/ImageMappingDto.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Nop.Plugin.Api.Attributes; 3 | 4 | namespace Nop.Plugin.Api.DTOs.Images 5 | { 6 | [ImageValidation] 7 | public class ImageMappingDto : ImageDto 8 | { 9 | [JsonProperty("id")] 10 | public int Id { get; set; } 11 | 12 | [JsonProperty("picture_id")] 13 | public int PictureId { get; set; } 14 | 15 | [JsonProperty("position")] 16 | public int Position { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Languages/LanguagesRootObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.Languages 6 | { 7 | public class LanguagesRootObject : ISerializableObject 8 | { 9 | public LanguagesRootObject() 10 | { 11 | Languages = new List(); 12 | } 13 | 14 | [JsonProperty("languages")] 15 | public IList Languages { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "languages"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof(LanguageDto); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Languages/LocalizedNameDto.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.DTOs.Languages 4 | { 5 | public class LocalizedNameDto 6 | { 7 | /// 8 | /// Gets or sets the language identifier 9 | /// 10 | [JsonProperty("language_id")] 11 | public int? LanguageId { get; set; } 12 | 13 | /// 14 | /// Gets or sets the localized name 15 | /// 16 | [JsonProperty("localized_name")] 17 | public string LocalizedName { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Manufacturers/DiscountManufacturerMappingDto.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Nop.Core.Domain.Catalog; 3 | using Nop.Core.Domain.Discounts; 4 | using Nop.Plugin.Api.DTOs.Base; 5 | 6 | namespace Nop.Plugin.Api.DTOs.Manufacturers 7 | { 8 | [JsonObject(Title = "discount")] 9 | //[Validator(typeof(ProductDtoValidator))] 10 | public class DiscountManufacturerMappingDto : BaseDto 11 | { 12 | /// 13 | /// Gets or sets the discount identifier 14 | /// 15 | [JsonProperty("discount_id")] 16 | public int DiscountId { get; set; } 17 | 18 | 19 | [JsonProperty("discount_name")] 20 | public string DiscountName { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Manufacturers/ManufacturersCountRootObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.DTOs.Manufacturers 4 | { 5 | public class ManufacturersCountRootObject 6 | { 7 | [JsonProperty("count")] 8 | public int Count { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Manufacturers/ManufacturersRootObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace Nop.Plugin.Api.DTOs.Manufacturers 6 | { 7 | public class ManufacturersRootObject : ISerializableObject 8 | { 9 | public ManufacturersRootObject() 10 | { 11 | Manufacturers = new List(); 12 | } 13 | 14 | [JsonProperty("manufacturers")] 15 | public IList Manufacturers { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "manufacturers"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof(ManufacturerDto); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/NewsLetterSubscriptions/NewsLetterSubscriptionDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | using Nop.Plugin.Api.DTOs.Base; 4 | 5 | namespace Nop.Plugin.Api.DTOs.Categories 6 | { 7 | [JsonObject(Title = "news_letter_subscription")] 8 | public class NewsLetterSubscriptionDto : BaseDto 9 | { 10 | /// 11 | /// Gets or sets the email 12 | /// 13 | [JsonProperty("email")] 14 | public string Email { get; set; } 15 | 16 | /// 17 | /// Gets or sets whether the subscription is active 18 | /// 19 | [JsonProperty("active")] 20 | public bool Active { get; set; } 21 | 22 | /// 23 | /// Gets or sets whether the subscription is active 24 | /// 25 | [JsonProperty("store_id")] 26 | public int StoreId { get; set; } 27 | 28 | /// 29 | /// Gets or sets created on utc date 30 | /// 31 | [JsonProperty("created_on_utc")] 32 | public DateTime? CreatedOnUtc { get; set; } 33 | } 34 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/NewsLetterSubscriptions/NewsLetterSubscriptionsRootObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.Categories 6 | { 7 | public class NewsLetterSubscriptionsRootObject : ISerializableObject 8 | { 9 | public NewsLetterSubscriptionsRootObject() 10 | { 11 | NewsLetterSubscriptions = new List(); 12 | } 13 | 14 | [JsonProperty("news_letter_subscriptions")] 15 | public IList NewsLetterSubscriptions { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "news_letter_subscriptions"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof (NewsLetterSubscriptionDto); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/OrderItems/OrderItemsCountRootObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.DTOs.OrderItems 4 | { 5 | public class OrderItemsCountRootObject 6 | { 7 | [JsonProperty("count")] 8 | public int Count { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/OrderItems/OrderItemsRootObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.OrderItems 6 | { 7 | public class OrderItemsRootObject : ISerializableObject 8 | { 9 | public OrderItemsRootObject() 10 | { 11 | OrderItems = new List(); 12 | } 13 | 14 | [JsonProperty("order_items")] 15 | public IList OrderItems { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "order_items"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof(OrderItemDto); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Orders/OrdersCountRootObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.DTOs.Orders 4 | { 5 | public class OrdersCountRootObject 6 | { 7 | [JsonProperty("count")] 8 | public int Count { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Orders/OrdersRootObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.Orders 6 | { 7 | public class OrdersRootObject : ISerializableObject 8 | { 9 | public OrdersRootObject() 10 | { 11 | Orders = new List(); 12 | } 13 | 14 | [JsonProperty("orders")] 15 | public IList Orders { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "orders"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof (OrderDto); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Orders/SingleOrderRootObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.DTOs.Orders 4 | { 5 | public class SingleOrderRootObject 6 | { 7 | [JsonProperty("order")] 8 | public OrderDto Order { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/ProductAttributes/ProductAttributeDto.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Nop.Plugin.Api.DTOs.Base; 3 | 4 | namespace Nop.Plugin.Api.DTOs.ProductAttributes 5 | { 6 | [JsonObject(Title = "product_attribute")] 7 | public class ProductAttributeDto : BaseDto 8 | { 9 | /// 10 | /// Gets or sets the name 11 | /// 12 | [JsonProperty("name")] 13 | public string Name { get; set; } 14 | 15 | ///// 16 | ///// Gets or sets the localized names 17 | ///// 18 | //[JsonProperty("localized_names")] 19 | //public List LocalizedNames 20 | //{ 21 | // get 22 | // { 23 | // return _localizedNames; 24 | // } 25 | // set 26 | // { 27 | // _localizedNames = value; 28 | // } 29 | //} 30 | 31 | /// 32 | /// Gets or sets the description 33 | /// 34 | [JsonProperty("description")] 35 | public string Description { get; set; } 36 | } 37 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/ProductAttributes/ProductAttributesCountRootObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.DTOs.ProductAttributes 4 | { 5 | public class ProductAttributesCountRootObject 6 | { 7 | [JsonProperty("count")] 8 | public int Count { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/ProductAttributes/ProductAttributesRootObjectDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.ProductAttributes 6 | { 7 | public class ProductAttributesRootObjectDto : ISerializableObject 8 | { 9 | public ProductAttributesRootObjectDto() 10 | { 11 | ProductAttributes = new List(); 12 | } 13 | 14 | [JsonProperty("product_attributes")] 15 | public IList ProductAttributes { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "product_attributes"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof (ProductAttributeDto); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/ProductCategoryMappings/ProductCategoryMappingsCountRootObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.DTOs.ProductCategoryMappings 4 | { 5 | public class ProductCategoryMappingsCountRootObject 6 | { 7 | [JsonProperty("count")] 8 | public int Count { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/ProductCategoryMappings/ProductCategoryMappingsDto.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Nop.Plugin.Api.DTOs.Base; 3 | 4 | namespace Nop.Plugin.Api.DTOs.ProductCategoryMappings 5 | { 6 | [JsonObject(Title = "product_category_mapping")] 7 | public class ProductCategoryMappingDto : BaseDto 8 | { 9 | /// 10 | /// Gets or sets the product identifier 11 | /// 12 | [JsonProperty("product_id")] 13 | public int? ProductId { get; set; } 14 | 15 | /// 16 | /// Gets or sets the category identifier 17 | /// 18 | [JsonProperty("category_id")] 19 | public int? CategoryId { get; set; } 20 | 21 | /// 22 | /// Gets or sets a value indicating whether the product is featured 23 | /// 24 | [JsonProperty("is_featured_product")] 25 | public bool? IsFeaturedProduct { get; set; } 26 | 27 | /// 28 | /// Gets or sets the display order 29 | /// 30 | [JsonProperty("display_order")] 31 | public int? DisplayOrder { get; set; } 32 | } 33 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/ProductCategoryMappings/ProductCategoryMappingsRootObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.ProductCategoryMappings 6 | { 7 | public class ProductCategoryMappingsRootObject : ISerializableObject 8 | { 9 | public ProductCategoryMappingsRootObject() 10 | { 11 | ProductCategoryMappingDtos = new List(); 12 | } 13 | 14 | [JsonProperty("product_category_mappings")] 15 | public IList ProductCategoryMappingDtos { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "product_category_mappings"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof (ProductCategoryMappingDto); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/ProductItemAttributeDto.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Nop.Plugin.Api.DTOs.Base; 3 | 4 | namespace Nop.Plugin.Api.DTOs 5 | { 6 | [JsonObject(Title = "attribute")] 7 | public class ProductItemAttributeDto : BaseDto 8 | { 9 | [JsonProperty("value")] 10 | public string Value { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/ProductManufacturerMappings/ProductManufacturerMappingsCountRootObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.DTOs.ProductManufacturerMappings 4 | { 5 | public class ProductManufacturerMappingsCountRootObject 6 | { 7 | [JsonProperty("count")] 8 | public int Count { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/ProductManufacturerMappings/ProductManufacturerMappingsDto.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Nop.Plugin.Api.DTOs.Base; 3 | using Nop.Plugin.Api.Validators; 4 | 5 | namespace Nop.Plugin.Api.DTOs.ProductManufacturerMappings 6 | { 7 | [JsonObject(Title = "product_manufacturer_mapping")] 8 | public class ProductManufacturerMappingsDto : BaseDto 9 | { 10 | /// 11 | /// Gets or sets the product identifier 12 | /// 13 | [JsonProperty("product_id")] 14 | public int? ProductId { get; set; } 15 | 16 | /// 17 | /// Gets or sets the manufacturer identifier 18 | /// 19 | [JsonProperty("manufacturer_id")] 20 | public int? ManufacturerId { get; set; } 21 | 22 | /// 23 | /// Gets or sets a value indicating whether the product is featured 24 | /// 25 | [JsonProperty("is_featured_product")] 26 | public bool? IsFeaturedProduct { get; set; } 27 | 28 | /// 29 | /// Gets or sets the display order 30 | /// 31 | [JsonProperty("display_order")] 32 | public int? DisplayOrder { get; set; } 33 | } 34 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/ProductManufacturerMappings/ProductManufacturerMappingsRootObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace Nop.Plugin.Api.DTOs.ProductManufacturerMappings 6 | { 7 | public class ProductManufacturerMappingsRootObject : ISerializableObject 8 | { 9 | public ProductManufacturerMappingsRootObject() 10 | { 11 | ProductManufacturerMappingsDtos = new List(); 12 | } 13 | 14 | [JsonProperty("product_manufacturer_mappings")] 15 | public IList ProductManufacturerMappingsDtos { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "product_manufacturer_mappings"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof (ProductManufacturerMappingsDto); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Products/ProductAttributeCombinationDto.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Nop.Plugin.Api.DTOs.Base; 3 | using Nop.Plugin.Api.Validators; 4 | 5 | namespace Nop.Plugin.Api.DTOs.Products 6 | { 7 | [JsonObject(Title = "product_attribute_combination")] 8 | public class ProductAttributeCombinationDto : BaseDto 9 | { 10 | /// 11 | /// Gets or sets the product identifier 12 | /// 13 | [JsonProperty("product_id")] 14 | public int ProductId { get; set; } 15 | 16 | /// 17 | /// Gets or sets the attributes 18 | /// 19 | [JsonProperty("attributes_xml")] 20 | public string AttributesXml { get; set; } 21 | 22 | /// 23 | /// Gets or sets the stock quantity 24 | /// 25 | [JsonProperty("stock_quantity")] 26 | public int StockQuantity { get; set; } 27 | 28 | /// 29 | /// Gets or sets the SKU 30 | /// 31 | [JsonProperty("sku")] 32 | public string Sku { get; set; } 33 | 34 | /// 35 | /// Gets or sets the manufacturer part number 36 | /// 37 | [JsonProperty("manufacturer_part_number")] 38 | public string ManufacturerPartNumber { get; set; } 39 | 40 | /// 41 | /// Gets or sets the Global Trade Item Number (GTIN). These identifiers include UPC (in North America), EAN (in Europe), JAN (in Japan), and ISBN (for books). 42 | /// 43 | [JsonProperty("gtin")] 44 | public string Gtin { get; set; } 45 | 46 | /// 47 | /// Gets or sets the attribute combination price. This way a store owner can override the default product price when this attribute combination is added to the cart. For example, you can give a discount this way. 48 | /// 49 | [JsonProperty("overridden_price")] 50 | public decimal? OverriddenPrice { get; set; } 51 | 52 | /// 53 | /// Gets or sets the identifier of picture associated with this combination 54 | /// 55 | [JsonProperty("picture_id")] 56 | public int PictureId { get; set; } 57 | } 58 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Products/ProductsCountRootObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.DTOs.Products 4 | { 5 | public class ProductsCountRootObject 6 | { 7 | [JsonProperty("count")] 8 | public int Count { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Products/ProductsRootObjectDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.Products 6 | { 7 | public class ProductsRootObjectDto : ISerializableObject 8 | { 9 | public ProductsRootObjectDto() 10 | { 11 | Products = new List(); 12 | } 13 | 14 | [JsonProperty("products")] 15 | public IList Products { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "products"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof (ProductDto); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/ShoppingCarts/ShoppingCartItemsRootObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.ShoppingCarts 6 | { 7 | public class ShoppingCartItemsRootObject : ISerializableObject 8 | { 9 | public ShoppingCartItemsRootObject() 10 | { 11 | ShoppingCartItems = new List(); 12 | } 13 | 14 | [JsonProperty("shopping_carts")] 15 | public IList ShoppingCartItems { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "shopping_carts"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof (ShoppingCartItemDto); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/SpecificationAttributes/ProductSpecificationAttributesCountRootObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.DTOs.SpecificationAttributes 4 | { 5 | public class ProductSpecificationAttributesCountRootObject 6 | { 7 | [JsonProperty("count")] 8 | public int Count { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/SpecificationAttributes/ProductSpecificationAttributesRootObjectDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.SpecificationAttributes 6 | { 7 | public class ProductSpecificationAttributesRootObjectDto : ISerializableObject 8 | { 9 | public ProductSpecificationAttributesRootObjectDto() 10 | { 11 | ProductSpecificationAttributes = new List(); 12 | } 13 | 14 | [JsonProperty("product_specification_attributes")] 15 | public IList ProductSpecificationAttributes { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "product_specification_attributes"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof (ProductSpecificationAttributeDto); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/SpecificationAttributes/SpecificationAttributeDto.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Nop.Plugin.Api.Validators; 3 | using System.Collections.Generic; 4 | 5 | namespace Nop.Plugin.Api.DTOs.SpecificationAttributes 6 | { 7 | [JsonObject(Title = "specification_attribute")] 8 | public class SpecificationAttributeDto 9 | { 10 | /// 11 | /// Gets or sets the id 12 | /// 13 | [JsonProperty("id")] 14 | public int Id { get; set; } 15 | 16 | /// 17 | /// Gets or sets the name 18 | /// 19 | [JsonProperty("name")] 20 | public string Name { get; set; } 21 | 22 | /// 23 | /// Gets or sets the display order 24 | /// 25 | [JsonProperty("display_order")] 26 | public int DisplayOrder { get; set; } 27 | 28 | /// 29 | /// Gets or sets the specification attribute options 30 | /// 31 | [JsonProperty("specification_attribute_options")] 32 | public List SpecificationAttributeOptions { get; set; } 33 | } 34 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/SpecificationAttributes/SpecificationAttributeOptionDto.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Nop.Plugin.Api.Validators; 3 | 4 | namespace Nop.Plugin.Api.DTOs.SpecificationAttributes 5 | { 6 | [JsonObject(Title = "specification_attribute_option")] 7 | public class SpecificationAttributeOptionDto 8 | { 9 | /// 10 | /// Gets or sets the id 11 | /// 12 | [JsonProperty("id")] 13 | public int Id { get; set; } 14 | 15 | /// 16 | /// Gets or sets the specification attribute identifier 17 | /// 18 | [JsonProperty("specification_attribute_id")] 19 | public int SpecificationAttributeId { get; set; } 20 | 21 | /// 22 | /// Gets or sets the name 23 | /// 24 | [JsonProperty("name")] 25 | public string Name { get; set; } 26 | 27 | /// 28 | /// Gets or sets the color RGB value (used when you want to display "Color squares" instead of text) 29 | /// 30 | [JsonProperty("color_squares_rgb")] 31 | public string ColorSquaresRgb { get; set; } 32 | 33 | /// 34 | /// Gets or sets the display order 35 | /// 36 | [JsonProperty("display_order")] 37 | public int DisplayOrder { get; set; } 38 | } 39 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/SpecificationAttributes/SpecificationAttributesCountRootObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.DTOs.SpecificationAttributes 4 | { 5 | public class SpecificationAttributesCountRootObject 6 | { 7 | [JsonProperty("count")] 8 | public int Count { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/SpecificationAttributes/SpecificationAttributesRootObjectDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.SpecificationAttributes 6 | { 7 | public class SpecificationAttributesRootObjectDto : ISerializableObject 8 | { 9 | public SpecificationAttributesRootObjectDto() 10 | { 11 | SpecificationAttributes = new List(); 12 | } 13 | 14 | [JsonProperty("specification_attributes")] 15 | public IList SpecificationAttributes { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "specification_attributes"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof (SpecificationAttributeDto); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/DTOs/Stores/StoresRootObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.DTOs.Stores 6 | { 7 | public class StoresRootObject : ISerializableObject 8 | { 9 | public StoresRootObject() 10 | { 11 | Stores = new List(); 12 | } 13 | 14 | [JsonProperty("stores")] 15 | public IList Stores { get; set; } 16 | 17 | public string GetPrimaryPropertyName() 18 | { 19 | return "stores"; 20 | } 21 | 22 | public Type GetPrimaryPropertyType() 23 | { 24 | return typeof(StoreDto); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/DataMappings/WebHooksMap.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 3 | using Nop.Data.Mapping; 4 | 5 | namespace Nop.Plugin.Api.DataMappings 6 | { 7 | public class WebHooksMap : NopEntityTypeConfiguration 8 | { 9 | public override void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("WebHooks", "WebHooks"); 12 | builder.HasKey(wh => new { wh.User, wh.Id }); 13 | 14 | builder.Property(wh => wh.ProtectedData).IsRequired(); 15 | builder.Property(wh => wh.RowVer).IsRowVersion(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/DataStructures/ApiList.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace Nop.Plugin.Api.DataStructures 5 | { 6 | public class ApiList : List 7 | { 8 | public int PageIndex { get; private set; } 9 | public int PageSize { get; private set; } 10 | 11 | public ApiList(IQueryable source, int pageIndex, int pageSize) 12 | { 13 | PageSize = pageSize; 14 | PageIndex = pageIndex; 15 | AddRange(source.Skip(pageIndex * pageSize).Take(pageSize).ToList()); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Domain/ApiSettings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Configuration; 2 | 3 | namespace Nop.Plugin.Api.Domain 4 | { 5 | public class ApiSettings : ISettings 6 | { 7 | public bool EnableApi { get; set; } 8 | public bool AllowRequestsFromSwagger { get; set; } 9 | public bool EnableLogging { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Domain/WebHooks.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Nop.Core; 7 | 8 | namespace Nop.Plugin.Api.Domain 9 | { 10 | public class WebHooks : BaseEntity 11 | { 12 | public string User { get; set; } 13 | 14 | public string Id { get; set; } 15 | 16 | public string ProtectedData { get; set; } 17 | 18 | public Byte[] RowVer { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/Factories/AddressFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nop.Core.Domain.Common; 3 | 4 | namespace Nop.Plugin.Api.Factories 5 | { 6 | public class AddressFactory : IFactory
7 | { 8 | public Address Initialize() 9 | { 10 | var address = new Address() 11 | { 12 | CreatedOnUtc = DateTime.UtcNow 13 | }; 14 | 15 | return address; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Factories/CategoryFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Nop.Core.Domain.Catalog; 4 | using Nop.Services.Catalog; 5 | 6 | namespace Nop.Plugin.Api.Factories 7 | { 8 | public class CategoryFactory : IFactory 9 | { 10 | private readonly ICategoryTemplateService _categoryTemplateService; 11 | private readonly CatalogSettings _catalogSettings; 12 | 13 | public CategoryFactory(ICategoryTemplateService categoryTemplateService, CatalogSettings catalogSettings) 14 | { 15 | _categoryTemplateService = categoryTemplateService; 16 | _catalogSettings = catalogSettings; 17 | } 18 | 19 | public Category Initialize() 20 | { 21 | // TODO: cache the default entity. 22 | var defaultCategory = new Category(); 23 | 24 | // Set the first template as the default one. 25 | var firstTemplate = _categoryTemplateService.GetAllCategoryTemplates().FirstOrDefault(); 26 | 27 | if (firstTemplate != null) 28 | { 29 | defaultCategory.CategoryTemplateId = firstTemplate.Id; 30 | } 31 | 32 | //default values 33 | defaultCategory.PageSize = _catalogSettings.DefaultCategoryPageSize; 34 | defaultCategory.PageSizeOptions = _catalogSettings.DefaultCategoryPageSizeOptions; 35 | defaultCategory.Published = true; 36 | defaultCategory.IncludeInTopMenu = true; 37 | defaultCategory.AllowCustomersToSelectPageSize = true; 38 | 39 | defaultCategory.CreatedOnUtc = DateTime.UtcNow; 40 | defaultCategory.UpdatedOnUtc = DateTime.UtcNow; 41 | 42 | return defaultCategory; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Factories/CustomerFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nop.Core.Domain.Customers; 3 | 4 | namespace Nop.Plugin.Api.Factories 5 | { 6 | public class CustomerFactory : IFactory 7 | { 8 | public Customer Initialize() 9 | { 10 | var defaultCustomer = new Customer() 11 | { 12 | CustomerGuid = Guid.NewGuid(), 13 | CreatedOnUtc = DateTime.UtcNow, 14 | LastActivityDateUtc = DateTime.UtcNow, 15 | Active = true 16 | }; 17 | 18 | return defaultCustomer; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Factories/IFactory.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Factories 2 | { 3 | public interface IFactory 4 | { 5 | T Initialize(); 6 | } 7 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Factories/ManufacturerFactory.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Catalog; 2 | using System; 3 | 4 | namespace Nop.Plugin.Api.Factories 5 | { 6 | public class ManufacturerFactory : IFactory 7 | { 8 | private readonly CatalogSettings _catalogSettings; 9 | 10 | public ManufacturerFactory(CatalogSettings catalogSettings) 11 | { 12 | _catalogSettings = catalogSettings; 13 | } 14 | 15 | public Manufacturer Initialize() 16 | { 17 | // TODO: cache the default entity. 18 | var defaultManufacturer = new Manufacturer(); 19 | 20 | //default values 21 | defaultManufacturer.PageSize = _catalogSettings.DefaultManufacturerPageSize; 22 | defaultManufacturer.PageSizeOptions = _catalogSettings.DefaultManufacturerPageSizeOptions; 23 | defaultManufacturer.Published = true; 24 | defaultManufacturer.AllowCustomersToSelectPageSize = true; 25 | 26 | defaultManufacturer.CreatedOnUtc = DateTime.UtcNow; 27 | defaultManufacturer.UpdatedOnUtc = DateTime.UtcNow; 28 | 29 | return defaultManufacturer; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Factories/OrderFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nop.Core.Domain.Orders; 3 | using Nop.Core.Domain.Payments; 4 | using Nop.Core.Domain.Shipping; 5 | 6 | namespace Nop.Plugin.Api.Factories 7 | { 8 | public class OrderFactory : IFactory 9 | { 10 | public Order Initialize() 11 | { 12 | var order = new Order(); 13 | 14 | order.CreatedOnUtc = DateTime.UtcNow; 15 | order.OrderGuid = new Guid(); 16 | order.PaymentStatus = PaymentStatus.Pending; 17 | order.ShippingStatus = ShippingStatus.NotYetShipped; 18 | order.OrderStatus = OrderStatus.Pending; 19 | 20 | return order; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Factories/ProductFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nop.Core.Domain.Catalog; 3 | using Nop.Core.Domain.Directory; 4 | using Nop.Services.Directory; 5 | 6 | namespace Nop.Plugin.Api.Factories 7 | { 8 | public class ProductFactory : IFactory 9 | { 10 | private readonly IMeasureService _measureService; 11 | private readonly MeasureSettings _measureSettings; 12 | 13 | public ProductFactory(IMeasureService measureService, MeasureSettings measureSettings) 14 | { 15 | _measureService = measureService; 16 | _measureSettings = measureSettings; 17 | } 18 | 19 | public Product Initialize() 20 | { 21 | var defaultProduct = new Product(); 22 | 23 | defaultProduct.Weight = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId).Ratio; 24 | 25 | defaultProduct.CreatedOnUtc = DateTime.UtcNow; 26 | defaultProduct.UpdatedOnUtc = DateTime.UtcNow; 27 | 28 | defaultProduct.ProductType = ProductType.SimpleProduct; 29 | 30 | defaultProduct.MaximumCustomerEnteredPrice = 1000; 31 | defaultProduct.MaxNumberOfDownloads = 10; 32 | defaultProduct.RecurringCycleLength = 100; 33 | defaultProduct.RecurringTotalCycles = 10; 34 | defaultProduct.RentalPriceLength = 1; 35 | defaultProduct.StockQuantity = 10000; 36 | defaultProduct.NotifyAdminForQuantityBelow = 1; 37 | defaultProduct.OrderMinimumQuantity = 1; 38 | defaultProduct.OrderMaximumQuantity = 10000; 39 | 40 | defaultProduct.UnlimitedDownloads = true; 41 | defaultProduct.IsShipEnabled = true; 42 | defaultProduct.AllowCustomerReviews = true; 43 | defaultProduct.Published = true; 44 | defaultProduct.VisibleIndividually = true; 45 | 46 | return defaultProduct; 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Factories/ShoppingCartItemFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Nop.Core.Domain.Orders; 3 | 4 | namespace Nop.Plugin.Api.Factories 5 | { 6 | public class ShoppingCartItemFactory : IFactory 7 | { 8 | public ShoppingCartItem Initialize() 9 | { 10 | var newShoppingCartItem = new ShoppingCartItem(); 11 | 12 | newShoppingCartItem.CreatedOnUtc = DateTime.UtcNow; 13 | newShoppingCartItem.UpdatedOnUtc = DateTime.UtcNow; 14 | 15 | return newShoppingCartItem; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Helpers/CustomerRolesHelper.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Caching; 2 | using Nop.Core.Domain.Customers; 3 | using Nop.Services.Customers; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace Nop.Plugin.Api.Helpers 8 | { 9 | public class CustomerRolesHelper : ICustomerRolesHelper 10 | { 11 | private const string CUSTOMERROLES_ALL_BASE_KEY = "Nop.customerrole.all"; 12 | private const string CUSTOMERROLES_ALL_KEY = CUSTOMERROLES_ALL_BASE_KEY + "-{0}"; 13 | 14 | private readonly ICustomerService _customerService; 15 | private readonly ICacheManager _cacheManager; 16 | 17 | public CustomerRolesHelper(ICustomerService customerService, ICacheManager cacheManager) 18 | { 19 | _customerService = customerService; 20 | _cacheManager = cacheManager; 21 | } 22 | 23 | public IList GetValidCustomerRoles(List roleIds) 24 | { 25 | // This is needed because the caching messeup the entity framework context 26 | // and when you try to send something TO the database it throws an exeption. 27 | _cacheManager.RemoveByPrefix(CUSTOMERROLES_ALL_BASE_KEY); 28 | 29 | var allCustomerRoles = _customerService.GetAllCustomerRoles(true); 30 | var newCustomerRoles = new List(); 31 | foreach (var customerRole in allCustomerRoles) 32 | { 33 | if (roleIds != null && roleIds.Contains(customerRole.Id)) 34 | { 35 | newCustomerRoles.Add(customerRole); 36 | } 37 | } 38 | 39 | return newCustomerRoles; 40 | } 41 | 42 | public bool IsInGuestsRole(IList customerRoles) 43 | { 44 | return customerRoles.FirstOrDefault(cr => cr.SystemName == NopCustomerDefaults.GuestsRoleName) != null; 45 | } 46 | 47 | public bool IsInRegisteredRole(IList customerRoles) 48 | { 49 | return customerRoles.FirstOrDefault(cr => cr.SystemName == NopCustomerDefaults.RegisteredRoleName) != null; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Helpers/IConfigManаgerHelper.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Data; 2 | 3 | namespace Nop.Plugin.Api.Helpers 4 | { 5 | public interface IConfigManagerHelper 6 | { 7 | void AddBindingRedirects(); 8 | void AddConnectionString(); 9 | DataSettings DataSettings { get; } 10 | } 11 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Helpers/ICustomerRolesHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Nop.Core.Domain.Customers; 3 | 4 | namespace Nop.Plugin.Api.Helpers 5 | { 6 | public interface ICustomerRolesHelper 7 | { 8 | IList GetValidCustomerRoles(List roleIds); 9 | bool IsInGuestsRole(IList customerRoles); 10 | bool IsInRegisteredRole(IList customerRoles); 11 | } 12 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Helpers/IDTOHelper.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Catalog; 2 | using Nop.Core.Domain.Localization; 3 | using Nop.Core.Domain.Orders; 4 | using Nop.Core.Domain.Stores; 5 | using Nop.Plugin.Api.DTOs.Categories; 6 | using Nop.Plugin.Api.DTOs.Languages; 7 | using Nop.Plugin.Api.DTOs.Manufacturers; 8 | using Nop.Plugin.Api.DTOs.OrderItems; 9 | using Nop.Plugin.Api.DTOs.Orders; 10 | using Nop.Plugin.Api.DTOs.ProductAttributes; 11 | using Nop.Plugin.Api.DTOs.Products; 12 | using Nop.Plugin.Api.DTOs.ShoppingCarts; 13 | using Nop.Plugin.Api.DTOs.SpecificationAttributes; 14 | using Nop.Plugin.Api.DTOs.Stores; 15 | 16 | namespace Nop.Plugin.Api.Helpers 17 | { 18 | public interface IDTOHelper 19 | { 20 | ProductDto PrepareProductDTO(Product product); 21 | CategoryDto PrepareCategoryDTO(Category category); 22 | OrderDto PrepareOrderDTO(Order order); 23 | ShoppingCartItemDto PrepareShoppingCartItemDTO(ShoppingCartItem shoppingCartItem); 24 | OrderItemDto PrepareOrderItemDTO(OrderItem orderItem); 25 | StoreDto PrepareStoreDTO(Store store); 26 | LanguageDto PrepateLanguageDto(Language language); 27 | ProductAttributeDto PrepareProductAttributeDTO(ProductAttribute productAttribute); 28 | ProductSpecificationAttributeDto PrepareProductSpecificationAttributeDto(ProductSpecificationAttribute productSpecificationAttribute); 29 | SpecificationAttributeDto PrepareSpecificationAttributeDto(SpecificationAttribute specificationAttribute); 30 | ManufacturerDto PrepareManufacturerDto(Manufacturer manufacturer); 31 | } 32 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Helpers/IJsonHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | 5 | namespace Nop.Plugin.Api.Helpers 6 | { 7 | public interface IJsonHelper 8 | { 9 | Dictionary GetRequestJsonDictionaryFromStream(Stream stream, bool rewindStream); 10 | string GetRootPropertyName() where T : class, new(); 11 | } 12 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Helpers/IMappingHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Nop.Plugin.Api.Helpers 5 | { 6 | public interface IMappingHelper 7 | { 8 | void SetValues(Dictionary propertyNameValuePairs, object objectToBeUpdated, Type objectToBeUpdatedType, Dictionary objectPropertyNameValuePairs, bool handleComplexTypeCollections = false); 9 | void Merge(object source, object destination); 10 | } 11 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Helpers/ReflectionHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using Newtonsoft.Json; 4 | 5 | namespace Nop.Plugin.Api.Helpers 6 | { 7 | public static class ReflectionHelper 8 | { 9 | public static bool HasProperty(string propertyName, Type type) 10 | { 11 | return type.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance) != null; 12 | } 13 | 14 | public static JsonObjectAttribute GetJsonObjectAttribute(Type objectType) 15 | { 16 | var jsonObject = objectType.GetCustomAttribute(typeof(JsonObjectAttribute)) as JsonObjectAttribute; 17 | 18 | return jsonObject; 19 | } 20 | 21 | public static Type GetGenericElementType(Type type) 22 | => type.HasElementType ? type.GetElementType() : type.GetTypeInfo().GenericTypeArguments[0]; 23 | } 24 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/IdentityServer/Endpoints/AuthorizeEndpoint.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.IdentityServer.Endpoints 2 | { 3 | using System.Collections.Specialized; 4 | using System.Net; 5 | using System.Threading.Tasks; 6 | using IdentityServer4.Endpoints.Results; 7 | using IdentityServer4.Hosting; 8 | using IdentityServer4.ResponseHandling; 9 | using IdentityServer4.Services; 10 | using IdentityServer4.Validation; 11 | using Microsoft.AspNetCore.Http; 12 | 13 | public class AuthorizeEndpoint : AuthorizeEndpointBase 14 | { 15 | public AuthorizeEndpoint( 16 | IEventService events, 17 | IAuthorizeRequestValidator validator, 18 | IAuthorizeInteractionResponseGenerator interactionGenerator, 19 | IAuthorizeResponseGenerator authorizeResponseGenerator, 20 | IUserSession userSession) 21 | : base(events, userSession, validator, authorizeResponseGenerator, interactionGenerator) 22 | { 23 | } 24 | 25 | public override async Task ProcessAsync(HttpContext context) 26 | { 27 | NameValueCollection values; 28 | 29 | if (context.Request.Method == "GET") 30 | { 31 | values = context.Request.Query.AsNameValueCollection(); 32 | } 33 | else if (context.Request.Method == "POST") 34 | { 35 | if (!context.Request.HasFormContentType) 36 | { 37 | return new StatusCodeResult(HttpStatusCode.UnsupportedMediaType); 38 | } 39 | 40 | values = context.Request.Form.AsNameValueCollection(); 41 | } 42 | else 43 | { 44 | return new StatusCodeResult(HttpStatusCode.MethodNotAllowed); 45 | } 46 | 47 | var user = await UserSession.GetUserAsync(); 48 | var result = await ProcessAuthorizeRequestAsync(values, user, null); 49 | 50 | return result; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/IdentityServer/Endpoints/AuthorizeResponseExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.IdentityServer.Endpoints 2 | { 3 | using IdentityServer4.ResponseHandling; 4 | using System.Collections.Specialized; 5 | using Nop.Plugin.Api.IdentityServer.Extensions; 6 | 7 | public static class AuthorizeResponseExtensions 8 | { 9 | public static NameValueCollection ToNameValueCollection(this AuthorizeResponse response) 10 | { 11 | var collection = new NameValueCollection(); 12 | 13 | if (response.IsError) 14 | { 15 | if (response.Error.IsPresent()) 16 | { 17 | collection.Add("error", response.Error); 18 | } 19 | if (response.ErrorDescription.IsPresent()) 20 | { 21 | collection.Add("error_description", response.ErrorDescription); 22 | } 23 | } 24 | else 25 | { 26 | if (response.Code.IsPresent()) 27 | { 28 | collection.Add("code", response.Code); 29 | } 30 | 31 | if (response.IdentityToken.IsPresent()) 32 | { 33 | collection.Add("id_token", response.IdentityToken); 34 | } 35 | 36 | if (response.AccessToken.IsPresent()) 37 | { 38 | collection.Add("access_token", response.AccessToken); 39 | collection.Add("token_type", "Bearer"); 40 | collection.Add("expires_in", response.AccessTokenLifetime.ToString()); 41 | } 42 | 43 | if (response.Scope.IsPresent()) 44 | { 45 | collection.Add("scope", response.Scope); 46 | } 47 | } 48 | 49 | if (response.State.IsPresent()) 50 | { 51 | collection.Add("state", response.State); 52 | } 53 | 54 | if (response.SessionState.IsPresent()) 55 | { 56 | collection.Add("session_state", response.SessionState); 57 | } 58 | 59 | return collection; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/IdentityServer/Endpoints/TokenErrorResult.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.IdentityServer.Endpoints 2 | { 3 | using System; 4 | using System.Threading.Tasks; 5 | using IdentityServer4.Extensions; 6 | using IdentityServer4.Hosting; 7 | using IdentityServer4.ResponseHandling; 8 | using Microsoft.AspNetCore.Http; 9 | using Nop.Plugin.Api.IdentityServer.Extensions; 10 | using Nop.Plugin.Api.IdentityServer.Infrastructure; 11 | 12 | public class TokenErrorResult : IEndpointResult 13 | { 14 | public TokenErrorResponse Response { get; } 15 | 16 | public TokenErrorResult(TokenErrorResponse error) 17 | { 18 | if (error.Error.IsMissing()) throw new ArgumentNullException("Error must be set", nameof(error.Error)); 19 | 20 | Response = error; 21 | } 22 | 23 | public async Task ExecuteAsync(HttpContext context) 24 | { 25 | context.Response.StatusCode = 400; 26 | context.Response.SetNoCache(); 27 | 28 | var dto = new ResultDto 29 | { 30 | error = Response.Error, 31 | error_description = Response.ErrorDescription 32 | }; 33 | 34 | if (Response.Custom.IsNullOrEmpty()) 35 | { 36 | await context.Response.WriteJsonAsync(dto); 37 | } 38 | else 39 | { 40 | var jobject = ObjectSerializer.ToJObject(dto); 41 | jobject.AddDictionary(Response.Custom); 42 | 43 | await context.Response.WriteJsonAsync(jobject); 44 | } 45 | } 46 | 47 | internal class ResultDto 48 | { 49 | public string error { get; set; } 50 | public string error_description { get; set; } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/IdentityServer/Endpoints/TokenResult.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.IdentityServer.Endpoints 2 | { 3 | using System; 4 | using System.Threading.Tasks; 5 | using IdentityModel; 6 | using IdentityServer4.Extensions; 7 | using IdentityServer4.Hosting; 8 | using IdentityServer4.ResponseHandling; 9 | using Microsoft.AspNetCore.Http; 10 | using Nop.Plugin.Api.IdentityServer.Infrastructure; 11 | 12 | public class TokenResult : IEndpointResult 13 | { 14 | public TokenResponse Response { get; set; } 15 | 16 | public TokenResult(TokenResponse response) 17 | { 18 | if (response == null) throw new ArgumentNullException(nameof(response)); 19 | 20 | Response = response; 21 | } 22 | 23 | public async Task ExecuteAsync(HttpContext context) 24 | { 25 | context.Response.SetNoCache(); 26 | 27 | var dto = new ResultDto 28 | { 29 | id_token = Response.IdentityToken, 30 | access_token = Response.AccessToken, 31 | refresh_token = Response.RefreshToken, 32 | expires_in = Response.AccessTokenLifetime, 33 | token_type = OidcConstants.TokenResponse.BearerTokenType 34 | }; 35 | 36 | if (Response.Custom.IsNullOrEmpty()) 37 | { 38 | await context.Response.WriteJsonAsync(dto); 39 | } 40 | else 41 | { 42 | var jobject = ObjectSerializer.ToJObject(dto); 43 | jobject.AddDictionary(Response.Custom); 44 | 45 | await context.Response.WriteJsonAsync(jobject); 46 | } 47 | } 48 | 49 | internal class ResultDto 50 | { 51 | public string id_token { get; set; } 52 | public string access_token { get; set; } 53 | public int expires_in { get; set; } 54 | public string token_type { get; set; } 55 | public string refresh_token { get; set; } 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/IdentityServer/Infrastructure/ObjectSerializer.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.IdentityServer.Infrastructure 2 | { 3 | using IdentityServer4.Infrastructure; 4 | using Newtonsoft.Json; 5 | using Newtonsoft.Json.Linq; 6 | 7 | public class ObjectSerializer 8 | { 9 | private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings 10 | { 11 | DefaultValueHandling = DefaultValueHandling.Ignore, 12 | NullValueHandling = NullValueHandling.Ignore 13 | }; 14 | 15 | private static readonly JsonSerializer Serializer = new JsonSerializer 16 | { 17 | DefaultValueHandling = DefaultValueHandling.Ignore, 18 | NullValueHandling = NullValueHandling.Ignore 19 | }; 20 | 21 | static ObjectSerializer() 22 | { 23 | Settings.Converters.Add(new NameValueCollectionConverter()); 24 | } 25 | 26 | public static string ToString(object o) 27 | { 28 | return JsonConvert.SerializeObject(o, Settings); 29 | } 30 | 31 | public static T FromString(string value) 32 | { 33 | return JsonConvert.DeserializeObject(value, Settings); 34 | } 35 | 36 | public static JObject ToJObject(object o) 37 | { 38 | return JObject.FromObject(o, Serializer); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/IdentityServer/Services/ProfileService.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.IdentityServer.Services 2 | { 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using IdentityServer4.Models; 6 | using IdentityServer4.Services; 7 | using Nop.Plugin.Api.Services; 8 | 9 | public class ProfileService : IProfileService 10 | { 11 | private readonly IClientService _clientService; 12 | 13 | public ProfileService(IClientService clientService) 14 | { 15 | _clientService = clientService; 16 | } 17 | 18 | // TODO: test this 19 | public Task GetProfileDataAsync(ProfileDataRequestContext context) 20 | { 21 | var sub = context.Subject.Claims.FirstOrDefault(x => x.Type == "sub"); 22 | 23 | var userId = 0; 24 | 25 | if (int.TryParse(sub?.Value, out userId)) 26 | { 27 | // TODO: do we need claims?? 28 | //IdentityServer4.EntityFramework.Entities.Client client = _clientService.GetClientByClientId(userId.ToString()); 29 | //context.IssuedClaims = context.Subject.Claims.ToList(); 30 | //context.IssuedClaims.Add(new Claim(type: ClaimTypes.NameIdentifier, value: client.Id.ToString())); 31 | //context.IssuedClaims.Add(new Claim(type: ClaimTypes.Name, value: client.ClientName)); 32 | } 33 | 34 | return Task.CompletedTask; 35 | } 36 | 37 | public Task IsActiveAsync(IsActiveContext context) 38 | { 39 | return Task.CompletedTask; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/JSON/ActionResults/ErrorActionResult.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Threading.Tasks; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace Nop.Plugin.Api.JSON.ActionResults 6 | { 7 | using System; 8 | using System.IO; 9 | using System.Text; 10 | using Microsoft.AspNetCore.WebUtilities; 11 | 12 | public class ErrorActionResult : IActionResult 13 | { 14 | private readonly string _jsonString; 15 | private readonly HttpStatusCode _statusCode; 16 | 17 | public ErrorActionResult(string jsonString, HttpStatusCode statusCode) 18 | { 19 | _jsonString = jsonString; 20 | _statusCode = statusCode; 21 | } 22 | 23 | public Task ExecuteResultAsync(ActionContext context) 24 | { 25 | if (context == null) 26 | throw new ArgumentNullException(nameof(context)); 27 | 28 | var response = context.HttpContext.Response; 29 | 30 | response.StatusCode = (int)_statusCode; 31 | response.ContentType = "application/json"; 32 | 33 | using (TextWriter writer = new HttpResponseStreamWriter(response.Body, Encoding.UTF8)) 34 | { 35 | writer.Write(_jsonString); 36 | } 37 | 38 | return Task.CompletedTask; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/JSON/ActionResults/RawJsonActionResult.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Microsoft.AspNetCore.Mvc; 3 | 4 | namespace Nop.Plugin.Api.JSON.ActionResults 5 | { 6 | using System; 7 | using System.IO; 8 | using System.Text; 9 | using Microsoft.AspNetCore.WebUtilities; 10 | 11 | // TODO: Move to BaseApiController as method. 12 | public class RawJsonActionResult : IActionResult 13 | { 14 | private readonly string _jsonString; 15 | 16 | public RawJsonActionResult(object value) 17 | { 18 | if (value != null) 19 | { 20 | _jsonString = value.ToString(); 21 | } 22 | } 23 | 24 | public Task ExecuteResultAsync(ActionContext context) 25 | { 26 | if (context == null) 27 | throw new ArgumentNullException(nameof(context)); 28 | 29 | var response = context.HttpContext.Response; 30 | 31 | response.StatusCode = 200; 32 | response.ContentType = "application/json"; 33 | 34 | using (TextWriter writer = new HttpResponseStreamWriter(response.Body, Encoding.UTF8)) 35 | { 36 | writer.Write(_jsonString); 37 | } 38 | 39 | return Task.CompletedTask; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/JSON/Serializers/IJsonFieldsSerializer.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.JSON.Serializers 2 | { 3 | using Nop.Plugin.Api.DTOs; 4 | 5 | public interface IJsonFieldsSerializer 6 | { 7 | string Serialize(ISerializableObject objectToSerialize, string fields); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/JSON/Serializers/JsonFieldsSerializer.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.JSON.Serializers 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using Newtonsoft.Json.Linq; 7 | using Nop.Plugin.Api.DTOs; 8 | using Nop.Plugin.Api.Helpers; 9 | 10 | public class JsonFieldsSerializer : IJsonFieldsSerializer 11 | { 12 | public string Serialize(ISerializableObject objectToSerialize, string jsonFields) 13 | { 14 | if (objectToSerialize == null) 15 | { 16 | throw new ArgumentNullException(nameof(objectToSerialize)); 17 | } 18 | 19 | IList fieldsList = null; 20 | 21 | if (!string.IsNullOrEmpty(jsonFields)) 22 | { 23 | var primaryPropertyName = objectToSerialize.GetPrimaryPropertyName(); 24 | 25 | fieldsList = GetPropertiesIntoList(jsonFields); 26 | 27 | // Always add the root manually 28 | fieldsList.Add(primaryPropertyName); 29 | } 30 | 31 | var json = Serialize(objectToSerialize, fieldsList); 32 | 33 | return json; 34 | } 35 | 36 | private string Serialize(object objectToSerialize, IList jsonFields = null) 37 | { 38 | var jToken = JToken.FromObject(objectToSerialize); 39 | 40 | if (jsonFields != null) 41 | { 42 | jToken = jToken.RemoveEmptyChildrenAndFilterByFields(jsonFields); 43 | } 44 | 45 | var jTokenResult = jToken.ToString(); 46 | 47 | return jTokenResult; 48 | } 49 | 50 | private IList GetPropertiesIntoList(string fields) 51 | { 52 | IList properties = fields.ToLowerInvariant() 53 | .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) 54 | .Select(x => x.Trim()) 55 | .Distinct() 56 | .ToList(); 57 | 58 | return properties; 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/KendoUI/DataSourceRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Kendoui 2 | { 3 | /// 4 | /// DataSource request 5 | /// 6 | public class DataSourceRequest 7 | { 8 | /// 9 | /// Ctor 10 | /// 11 | public DataSourceRequest() 12 | { 13 | Page = 1; 14 | PageSize = 10; 15 | } 16 | 17 | /// 18 | /// Page number 19 | /// 20 | public int Page { get; set; } 21 | 22 | /// 23 | /// Page size 24 | /// 25 | public int PageSize { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/KendoUI/DataSourceResult.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | 3 | namespace Nop.Plugin.Api.Kendoui 4 | { 5 | /// 6 | /// DataSource result 7 | /// 8 | public class DataSourceResult 9 | { 10 | /// 11 | /// Extra data 12 | /// 13 | public object ExtraData { get; set; } 14 | 15 | /// 16 | /// Data 17 | /// 18 | public IEnumerable Data { get; set; } 19 | 20 | /// 21 | /// Errors 22 | /// 23 | public object Errors { get; set; } 24 | 25 | /// 26 | /// Total records 27 | /// 28 | public int Total { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/AddressDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Common; 2 | using Nop.Plugin.Api.AutoMapper; 3 | using Nop.Plugin.Api.DTOs; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class AddressDtoMappings 8 | { 9 | public static AddressDto ToDto(this Address address) 10 | { 11 | return address.MapTo(); 12 | } 13 | 14 | public static Address ToEntity(this AddressDto addressDto) 15 | { 16 | return addressDto.MapTo(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/BaseMapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using AutoMapper; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class BaseMapping 8 | { 9 | public static IMappingExpression IgnoreAllNonExisting(this IMappingExpression expression) 10 | { 11 | var flags = BindingFlags.Public | BindingFlags.Instance; 12 | var sourceType = typeof(TSource); 13 | var destinationProperties = typeof(TDestination).GetProperties(flags); 14 | 15 | foreach (var property in destinationProperties) 16 | { 17 | if (sourceType.GetProperty(property.Name, flags) == null) 18 | { 19 | expression.ForMember(property.Name, opt => opt.Ignore()); 20 | } 21 | } 22 | return expression; 23 | } 24 | 25 | public static TResult GetWithDefault(this TSource instance, 26 | Func getter, 27 | TResult defaultValue = default(TResult)) 28 | where TSource : class 29 | { 30 | return instance != null ? getter(instance) : defaultValue; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/CategoryDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Catalog; 2 | using Nop.Plugin.Api.AutoMapper; 3 | using Nop.Plugin.Api.DTOs.Categories; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class CategoryDtoMappings 8 | { 9 | public static CategoryDto ToDto(this Category category) 10 | { 11 | return category.MapTo(); 12 | } 13 | 14 | public static Category ToEntity(this CategoryDto categoryDto) 15 | { 16 | return categoryDto.MapTo(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/ClientMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.AutoMapper; 2 | 3 | namespace Nop.Plugin.Api.MappingExtensions 4 | { 5 | using IdentityServer4.EntityFramework.Entities; 6 | using Nop.Plugin.Api.Models; 7 | 8 | public static class ClientMappings 9 | { 10 | public static ClientApiModel ToApiModel(this Client client) 11 | { 12 | return client.MapTo(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/ConfigurationMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.AutoMapper; 2 | using Nop.Plugin.Api.Domain; 3 | using Nop.Plugin.Api.Models; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class ConfigurationMappings 8 | { 9 | public static ConfigurationModel ToModel(this ApiSettings apiSettings) 10 | { 11 | return apiSettings.MapTo(); 12 | } 13 | 14 | public static ApiSettings ToEntity(this ConfigurationModel apiSettingsModel) 15 | { 16 | return apiSettingsModel.MapTo(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/CustomerDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.AutoMapper; 2 | using Nop.Core.Domain.Customers; 3 | using Nop.Plugin.Api.DTOs.Customers; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class CustomerDtoMappings 8 | { 9 | public static CustomerDto ToDto(this Customer customer) 10 | { 11 | return customer.MapTo(); 12 | } 13 | 14 | public static OrderCustomerDto ToOrderCustomerDto(this Customer customer) 15 | { 16 | return customer.MapTo(); 17 | } 18 | 19 | public static OrderCustomerDto ToOrderCustomerDto(this CustomerDto customerDto) 20 | { 21 | return customerDto.MapTo(); 22 | } 23 | 24 | public static CustomerForShoppingCartItemDto ToCustomerForShoppingCartItemDto(this Customer customer) 25 | { 26 | return customer.MapTo(); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/CustomerRoleDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.AutoMapper; 2 | using Nop.Core.Domain.Customers; 3 | using Nop.Plugin.Api.DTOs.CustomerRoles; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class CustomerRoleDtoMappings 8 | { 9 | public static CustomerRoleDto ToDto(this CustomerRole customerRole) 10 | { 11 | return customerRole.MapTo(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/LanguageDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Localization; 2 | using Nop.Plugin.Api.AutoMapper; 3 | using Nop.Plugin.Api.DTOs.Languages; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class LanguageDtoMappings 8 | { 9 | public static LanguageDto ToDto(this Language language) 10 | { 11 | return language.MapTo(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/ManufacturerDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Catalog; 2 | using Nop.Plugin.Api.AutoMapper; 3 | using Nop.Plugin.Api.DTOs.Manufacturers; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class ManufacturerDtoMappings 8 | { 9 | public static ManufacturerDto ToDto(this Manufacturer manufacturer) 10 | { 11 | return manufacturer.MapTo(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/NewsLetterSubscriptoonDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Messages; 2 | using Nop.Plugin.Api.AutoMapper; 3 | using Nop.Plugin.Api.DTOs.Categories; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class NewsLetterSubscriptoonDtoMappings 8 | { 9 | public static NewsLetterSubscriptionDto ToDto(this NewsLetterSubscription newsLetterSubscription) 10 | { 11 | return newsLetterSubscription.MapTo(); 12 | } 13 | 14 | public static NewsLetterSubscription ToEntity(this NewsLetterSubscriptionDto newsLetterSubscriptionDto) 15 | { 16 | return newsLetterSubscriptionDto.MapTo(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/OrderDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Orders; 2 | using Nop.Plugin.Api.AutoMapper; 3 | using Nop.Plugin.Api.DTOs.Orders; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class OrderDtoMappings 8 | { 9 | public static OrderDto ToDto(this Order order) 10 | { 11 | return order.MapTo(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/OrderItemDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Orders; 2 | using Nop.Plugin.Api.AutoMapper; 3 | using Nop.Plugin.Api.DTOs.OrderItems; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class OrderItemDtoMappings 8 | { 9 | public static OrderItemDto ToDto(this OrderItem orderItem) 10 | { 11 | return orderItem.MapTo(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/ProductAttributeCombinationDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Catalog; 2 | using Nop.Plugin.Api.AutoMapper; 3 | using Nop.Plugin.Api.DTOs.Products; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class ProductAttributeCombinationDtoMappings 8 | { 9 | public static ProductAttributeCombinationDto ToDto(this ProductAttributeCombination productAttributeCombination) 10 | { 11 | return productAttributeCombination.MapTo(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/ProductAttributeDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Catalog; 2 | using Nop.Plugin.Api.AutoMapper; 3 | using Nop.Plugin.Api.DTOs.ProductAttributes; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class ProductAttributeDtoMappings 8 | { 9 | public static ProductAttributeDto ToDto(this ProductAttribute productAttribute) 10 | { 11 | return productAttribute.MapTo(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/ProductCategoryMappingDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.AutoMapper; 2 | using Nop.Core.Domain.Catalog; 3 | using Nop.Plugin.Api.DTOs.ProductCategoryMappings; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class ProductCategoryMappingDtoMappings 8 | { 9 | public static ProductCategoryMappingDto ToDto(this ProductCategory mapping) 10 | { 11 | return mapping.MapTo(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/ProductDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.AutoMapper; 2 | using Nop.Core.Domain.Catalog; 3 | using Nop.Plugin.Api.DTOs.Products; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class ProductDtoMappings 8 | { 9 | public static ProductDto ToDto(this Product product) 10 | { 11 | return product.MapTo(); 12 | } 13 | 14 | public static ProductAttributeValueDto ToDto(this ProductAttributeValue productAttributeValue) 15 | { 16 | return productAttributeValue.MapTo(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/ProductManufacturerMappingDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Catalog; 2 | using Nop.Plugin.Api.AutoMapper; 3 | using Nop.Plugin.Api.DTOs.ProductManufacturerMappings; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class ProductManufacturerMappingDtoMappings 8 | { 9 | public static ProductManufacturerMappingsDto ToDto(this ProductManufacturer mapping) 10 | { 11 | return mapping.MapTo(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/ShoppingCartItemDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.AutoMapper; 2 | using Nop.Core.Domain.Orders; 3 | using Nop.Plugin.Api.DTOs.ShoppingCarts; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class ShoppingCartItemDtoMappings 8 | { 9 | public static ShoppingCartItemDto ToDto(this ShoppingCartItem shoppingCartItem) 10 | { 11 | return shoppingCartItem.MapTo(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/SpecificationAttributeDtoMapping.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Catalog; 2 | using Nop.Plugin.Api.AutoMapper; 3 | using Nop.Plugin.Api.DTOs.SpecificationAttributes; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class SpecificationAttributeDtoMappings 8 | { 9 | public static ProductSpecificationAttributeDto ToDto(this ProductSpecificationAttribute productSpecificationAttribute) 10 | { 11 | return productSpecificationAttribute.MapTo(); 12 | } 13 | 14 | public static SpecificationAttributeDto ToDto(this SpecificationAttribute specificationAttribute) 15 | { 16 | return specificationAttribute.MapTo(); 17 | } 18 | 19 | public static SpecificationAttributeOptionDto ToDto(this SpecificationAttributeOption specificationAttributeOption) 20 | { 21 | return specificationAttributeOption.MapTo(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/MappingExtensions/StoreDtoMappings.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Stores; 2 | using Nop.Plugin.Api.AutoMapper; 3 | using Nop.Plugin.Api.DTOs.Stores; 4 | 5 | namespace Nop.Plugin.Api.MappingExtensions 6 | { 7 | public static class StoreDtoMappings 8 | { 9 | public static StoreDto ToDto(this Store store) 10 | { 11 | return store.MapTo(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/Maps/IJsonPropertyMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Nop.Plugin.Api.Maps 5 | { 6 | public interface IJsonPropertyMapper 7 | { 8 | Dictionary> GetMap(Type type); 9 | } 10 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Migrations/IdentityServer/PersistedGrantDb/20170319181710_Grants.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Migrations.IdentityServer.PersitedGrantDb 2 | { 3 | using System; 4 | using IdentityServer4.EntityFramework.DbContexts; 5 | using Microsoft.EntityFrameworkCore; 6 | using Microsoft.EntityFrameworkCore.Infrastructure; 7 | using Microsoft.EntityFrameworkCore.Metadata; 8 | using Microsoft.EntityFrameworkCore.Migrations; 9 | 10 | [DbContext(typeof(PersistedGrantDbContext))] 11 | [Migration("20170319181710_Grants")] 12 | partial class Grants 13 | { 14 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 15 | { 16 | modelBuilder 17 | .HasAnnotation("ProductVersion", "1.1.1") 18 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 19 | 20 | modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.PersistedGrant", b => 21 | { 22 | b.Property("Key") 23 | .HasMaxLength(200); 24 | 25 | b.Property("ClientId") 26 | .IsRequired() 27 | .HasMaxLength(200); 28 | 29 | b.Property("CreationTime"); 30 | 31 | b.Property("Data") 32 | .IsRequired() 33 | .HasMaxLength(50000); 34 | 35 | b.Property("Expiration"); 36 | 37 | b.Property("SubjectId") 38 | .HasMaxLength(200); 39 | 40 | b.Property("Type") 41 | .IsRequired() 42 | .HasMaxLength(50); 43 | 44 | b.HasKey("Key"); 45 | 46 | b.HasIndex("SubjectId", "ClientId", "Type"); 47 | 48 | b.ToTable("PersistedGrants"); 49 | }); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Migrations/IdentityServer/PersistedGrantDb/20170319181710_Grants.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Migrations.IdentityServer.PersitedGrantDb 2 | { 3 | using System; 4 | using Microsoft.EntityFrameworkCore.Migrations; 5 | 6 | public partial class Grants : Migration 7 | { 8 | protected override void Up(MigrationBuilder migrationBuilder) 9 | { 10 | migrationBuilder.CreateTable( 11 | name: "PersistedGrants", 12 | columns: table => new 13 | { 14 | Key = table.Column(maxLength: 200, nullable: false), 15 | ClientId = table.Column(maxLength: 200, nullable: false), 16 | CreationTime = table.Column(nullable: false), 17 | Data = table.Column(maxLength: 50000, nullable: false), 18 | Expiration = table.Column(nullable: true), 19 | SubjectId = table.Column(maxLength: 200, nullable: true), 20 | Type = table.Column(maxLength: 50, nullable: false) 21 | }, 22 | constraints: table => 23 | { 24 | table.PrimaryKey("PK_PersistedGrants", x => x.Key); 25 | }); 26 | 27 | migrationBuilder.CreateIndex( 28 | name: "IX_PersistedGrants_SubjectId_ClientId_Type", 29 | table: "PersistedGrants", 30 | columns: new[] { "SubjectId", "ClientId", "Type" }); 31 | } 32 | 33 | protected override void Down(MigrationBuilder migrationBuilder) 34 | { 35 | migrationBuilder.DropTable( 36 | name: "PersistedGrants"); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/ModelBinders/ParametersModelBinder.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.Converters; 2 | 3 | namespace Nop.Plugin.Api.ModelBinders 4 | { 5 | using System; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | using Microsoft.AspNetCore.Mvc.ModelBinding; 9 | 10 | public class ParametersModelBinder : IModelBinder where T : class, new() 11 | { 12 | private readonly IObjectConverter _objectConverter; 13 | 14 | public ParametersModelBinder(IObjectConverter objectConverter) 15 | { 16 | _objectConverter = objectConverter; 17 | } 18 | 19 | public Task BindModelAsync(ModelBindingContext bindingContext) 20 | { 21 | if (bindingContext == null) 22 | { 23 | throw new ArgumentNullException(nameof(bindingContext)); 24 | } 25 | 26 | if (bindingContext.HttpContext.Request.QueryString.HasValue) 27 | { 28 | var queryParameters = bindingContext.HttpContext.Request.Query.ToDictionary(pair => pair.Key, pair => pair.Value.ToString()); 29 | 30 | bindingContext.Model = _objectConverter.ToObject(queryParameters); 31 | } 32 | else 33 | { 34 | bindingContext.Model = new T(); 35 | } 36 | 37 | bindingContext.Result = ModelBindingResult.Success(bindingContext.Model); 38 | 39 | // This should be true otherwise the model will be null. 40 | return Task.CompletedTask; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/CategoriesParameters/BaseCategoriesParametersModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace Nop.Plugin.Api.Models.CategoriesParameters 5 | { 6 | // JsonProperty is used only for swagger 7 | public class BaseCategoriesParametersModel 8 | { 9 | public BaseCategoriesParametersModel() 10 | { 11 | ProductId = null; 12 | CreatedAtMin = null; 13 | CreatedAtMax = null; 14 | UpdatedAtMin = null; 15 | UpdatedAtMax = null; 16 | PublishedStatus = null; 17 | } 18 | 19 | /// 20 | /// Show categories created after date (format: 2008-12-31 03:00) 21 | /// 22 | [JsonProperty("created_at_min")] 23 | public DateTime? CreatedAtMin { get; set; } 24 | 25 | /// 26 | /// Show categories created before date (format: 2008-12-31 03:00) 27 | /// 28 | [JsonProperty("created_at_max")] 29 | public DateTime? CreatedAtMax { get; set; } 30 | 31 | /// 32 | /// Show categories last updated after date (format: 2008-12-31 03:00) 33 | /// 34 | [JsonProperty("updated_at_min")] 35 | public DateTime? UpdatedAtMin { get; set; } 36 | 37 | /// 38 | /// Show categories last updated before date (format: 2008-12-31 03:00) 39 | /// 40 | [JsonProperty("updated_at_max")] 41 | public DateTime? UpdatedAtMax { get; set; } 42 | 43 | /// 44 | ///
    45 | ///
  • published - Show only published categories
  • 46 | ///
  • unpublished - Show only unpublished categories
  • 47 | ///
  • any - Show all categories(default)
  • 48 | ///
49 | ///
50 | [JsonProperty("published_status")] 51 | public bool? PublishedStatus { get; set; } 52 | 53 | /// 54 | /// Show only the categories to which the product is mapped to 55 | /// 56 | [JsonProperty("product_id")] 57 | public int? ProductId { get; set; } 58 | } 59 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/CategoriesParameters/CategoriesCountParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.ModelBinders; 2 | namespace Nop.Plugin.Api.Models.CategoriesParameters 3 | { 4 | using Microsoft.AspNetCore.Mvc; 5 | 6 | [ModelBinder(typeof(ParametersModelBinder))] 7 | public class CategoriesCountParametersModel : BaseCategoriesParametersModel 8 | { 9 | // Nothing special here, created just for clarity. 10 | } 11 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/CategoriesParameters/CategoriesParametersModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Nop.Plugin.Api.Constants; 4 | using Nop.Plugin.Api.ModelBinders; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace Nop.Plugin.Api.Models.CategoriesParameters 8 | { 9 | // JsonProperty is used only for swagger 10 | [ModelBinder(typeof(ParametersModelBinder))] 11 | public class CategoriesParametersModel : BaseCategoriesParametersModel 12 | { 13 | public CategoriesParametersModel() 14 | { 15 | Ids = null; 16 | Limit = Configurations.DefaultLimit; 17 | Page = Configurations.DefaultPageValue; 18 | SinceId = Configurations.DefaultSinceId; 19 | Fields = string.Empty; 20 | } 21 | 22 | /// 23 | /// A comma-separated list of category ids 24 | /// 25 | [JsonProperty("ids")] 26 | public List Ids { get; set; } 27 | 28 | /// 29 | /// Amount of results (default: 50) (maximum: 250) 30 | /// 31 | [JsonProperty("limit")] 32 | public int Limit { get; set; } 33 | 34 | /// 35 | /// Page to show (default: 1) 36 | /// 37 | [JsonProperty("page")] 38 | public int Page { get; set; } 39 | 40 | /// 41 | /// Restrict results to after the specified ID 42 | /// 43 | [JsonProperty("since_id")] 44 | public int SinceId { get; set; } 45 | 46 | /// 47 | /// comma-separated list of fields to include in the response 48 | /// 49 | [JsonProperty("fields")] 50 | public string Fields { get; set; } 51 | } 52 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ClientApiModel.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Models 2 | { 3 | public class ClientApiModel 4 | { 5 | 6 | public int Id { get; set; } 7 | public string ClientName { get; set; } 8 | 9 | public string ClientId 10 | { 11 | get; 12 | set; 13 | } 14 | 15 | public string ClientSecret 16 | { 17 | get; 18 | set; 19 | } 20 | 21 | public string RedirectUrl { get; set; } 22 | 23 | public int AccessTokenLifetime 24 | { 25 | get;set; 26 | } 27 | 28 | public int RefreshTokenLifetime 29 | { 30 | get;set; 31 | } 32 | 33 | public bool Enabled { get; set; } 34 | } 35 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ConfigurationModel.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Models 2 | { 3 | using Nop.Web.Framework.Mvc.ModelBinding; 4 | 5 | public class ConfigurationModel 6 | { 7 | [NopResourceDisplayName("Plugins.Api.Admin.EnableApi")] 8 | public bool EnableApi { get; set; } 9 | public bool EnableApi_OverrideForStore { get; set; } 10 | 11 | [NopResourceDisplayName("Plugins.Api.Admin.AllowRequestsFromSwagger")] 12 | public bool AllowRequestsFromSwagger { get; set; } 13 | public bool AllowRequestsFromSwagger_OverrideForStore { get; set; } 14 | 15 | [NopResourceDisplayName("Plugins.Api.Admin.EnableLogging")] 16 | public bool EnableLogging { get; set; } 17 | public bool EnableLogging_OverrideForStore { get; set; } 18 | 19 | public int ActiveStoreScopeConfiguration { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/CustomersParameters/CustomersParametersModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | using Nop.Plugin.Api.Constants; 4 | using Nop.Plugin.Api.ModelBinders; 5 | 6 | namespace Nop.Plugin.Api.Models.CustomersParameters 7 | { 8 | using Microsoft.AspNetCore.Mvc; 9 | 10 | // JsonProperty is used only for swagger 11 | [ModelBinder(typeof(ParametersModelBinder))] 12 | public class CustomersParametersModel 13 | { 14 | public CustomersParametersModel() 15 | { 16 | Limit = Configurations.DefaultLimit; 17 | Page = Configurations.DefaultPageValue; 18 | SinceId = 0; 19 | Fields = string.Empty; 20 | CreatedAtMax = null; 21 | CreatedAtMin = null; 22 | } 23 | 24 | /// 25 | /// Amount of results (default: 50) (maximum: 250) 26 | /// 27 | [JsonProperty("limit")] 28 | public int Limit { get; set; } 29 | 30 | /// 31 | /// Page to show (default: 1) 32 | /// 33 | [JsonProperty("page")] 34 | public int Page { get; set; } 35 | 36 | /// 37 | /// Restrict results to after the specified ID 38 | /// 39 | [JsonProperty("since_id")] 40 | public int SinceId { get; set; } 41 | 42 | /// 43 | /// Comma-separated list of fields to include in the response 44 | /// 45 | [JsonProperty("fields")] 46 | public string Fields { get; set; } 47 | 48 | /// 49 | /// Show customers created after date (format: 2008-12-31 03:00) 50 | /// 51 | [JsonProperty("created_at_min")] 52 | public DateTime? CreatedAtMin { get; set; } 53 | 54 | /// 55 | /// Show customers created before date (format: 2008-12-31 03:00) 56 | /// 57 | [JsonProperty("created_at_max")] 58 | public DateTime? CreatedAtMax { get; set; } 59 | } 60 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/CustomersParameters/CustomersSearchParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Nop.Plugin.Api.Constants; 3 | using Nop.Plugin.Api.ModelBinders; 4 | 5 | namespace Nop.Plugin.Api.Models.CustomersParameters 6 | { 7 | using Microsoft.AspNetCore.Mvc; 8 | 9 | // JsonProperty is used only for swagger 10 | [ModelBinder(typeof(ParametersModelBinder))] 11 | public class CustomersSearchParametersModel 12 | { 13 | public CustomersSearchParametersModel() 14 | { 15 | Order = "Id"; 16 | Query = string.Empty; 17 | Page = Configurations.DefaultPageValue; 18 | Limit = Configurations.DefaultLimit; 19 | Fields = string.Empty; 20 | } 21 | 22 | /// 23 | /// Field and direction to order results by (default: id DESC) 24 | /// 25 | [JsonProperty("order")] 26 | public string Order { get; set; } 27 | 28 | /// 29 | /// Text to search customers 30 | /// 31 | [JsonProperty("query")] 32 | public string Query { get; set; } 33 | 34 | /// 35 | /// Page to show (default: 1) 36 | /// 37 | [JsonProperty("page")] 38 | public int Page { get; set; } 39 | 40 | /// 41 | /// Amount of results (default: 50) (maximum: 250) 42 | /// 43 | [JsonProperty("limit")] 44 | public int Limit { get; set; } 45 | 46 | /// 47 | /// Comma-separated list of fields to include in the response 48 | /// 49 | [JsonProperty("fields")] 50 | public string Fields { get; set; } 51 | } 52 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/DefaultWeApiErrorsModel.cs: -------------------------------------------------------------------------------- 1 | namespace Nop.Plugin.Api.Models 2 | { 3 | public class DefaultWeApiErrorsModel 4 | { 5 | public string Message { get; set; } 6 | public string MessageDetail { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ManufacturersParameters/BaseManufacturersParametersModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace Nop.Plugin.Api.Models.ManufacturersParameters 5 | { 6 | // JsonProperty is used only for swagger 7 | public class BaseManufacturersParametersModel 8 | { 9 | public BaseManufacturersParametersModel() 10 | { 11 | ProductId = null; 12 | CreatedAtMin = null; 13 | CreatedAtMax = null; 14 | UpdatedAtMin = null; 15 | UpdatedAtMax = null; 16 | PublishedStatus = null; 17 | } 18 | 19 | /// 20 | /// Show categories created after date (format: 2008-12-31 03:00) 21 | /// 22 | [JsonProperty("created_at_min")] 23 | public DateTime? CreatedAtMin { get; set; } 24 | 25 | /// 26 | /// Show categories created before date (format: 2008-12-31 03:00) 27 | /// 28 | [JsonProperty("created_at_max")] 29 | public DateTime? CreatedAtMax { get; set; } 30 | 31 | /// 32 | /// Show categories last updated after date (format: 2008-12-31 03:00) 33 | /// 34 | [JsonProperty("updated_at_min")] 35 | public DateTime? UpdatedAtMin { get; set; } 36 | 37 | /// 38 | /// Show categories last updated before date (format: 2008-12-31 03:00) 39 | /// 40 | [JsonProperty("updated_at_max")] 41 | public DateTime? UpdatedAtMax { get; set; } 42 | 43 | /// 44 | ///
    45 | ///
  • published - Show only published categories
  • 46 | ///
  • unpublished - Show only unpublished categories
  • 47 | ///
  • any - Show all categories(default)
  • 48 | ///
49 | ///
50 | [JsonProperty("published_status")] 51 | public bool? PublishedStatus { get; set; } 52 | 53 | /// 54 | /// Show only the categories to which the product is mapped to 55 | /// 56 | [JsonProperty("product_id")] 57 | public int? ProductId { get; set; } 58 | } 59 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ManufacturersParameters/ManufacturersCountParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.ModelBinders; 2 | namespace Nop.Plugin.Api.Models.ManufacturersParameters 3 | { 4 | using Microsoft.AspNetCore.Mvc; 5 | 6 | [ModelBinder(typeof(ParametersModelBinder))] 7 | public class ManufacturersCountParametersModel : BaseManufacturersParametersModel 8 | { 9 | // Nothing special here, created just for clarity. 10 | } 11 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ManufacturersParameters/ManufacturersParametersModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Nop.Plugin.Api.Constants; 4 | using Nop.Plugin.Api.ModelBinders; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace Nop.Plugin.Api.Models.ManufacturersParameters 8 | { 9 | // JsonProperty is used only for swagger 10 | [ModelBinder(typeof(ParametersModelBinder))] 11 | public class ManufacturersParametersModel : BaseManufacturersParametersModel 12 | { 13 | public ManufacturersParametersModel() 14 | { 15 | Ids = null; 16 | Limit = Configurations.DefaultLimit; 17 | Page = Configurations.DefaultPageValue; 18 | SinceId = Configurations.DefaultSinceId; 19 | Fields = string.Empty; 20 | } 21 | 22 | /// 23 | /// A comma-separated list of manufacturer ids 24 | /// 25 | [JsonProperty("ids")] 26 | public List Ids { get; set; } 27 | 28 | /// 29 | /// Amount of results (default: 50) (maximum: 250) 30 | /// 31 | [JsonProperty("limit")] 32 | public int Limit { get; set; } 33 | 34 | /// 35 | /// Page to show (default: 1) 36 | /// 37 | [JsonProperty("page")] 38 | public int Page { get; set; } 39 | 40 | /// 41 | /// Restrict results to after the specified ID 42 | /// 43 | [JsonProperty("since_id")] 44 | public int SinceId { get; set; } 45 | 46 | /// 47 | /// comma-separated list of fields to include in the response 48 | /// 49 | [JsonProperty("fields")] 50 | public string Fields { get; set; } 51 | 52 | /// 53 | /// comma-separated list of fields to include in the response 54 | /// 55 | [JsonProperty("languageid")] 56 | public int? LanguageId { get; set; } 57 | } 58 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/OrderItemsParameters/OrderItemsParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Nop.Plugin.Api.Constants; 3 | using Nop.Plugin.Api.ModelBinders; 4 | 5 | namespace Nop.Plugin.Api.Models.OrderItemsParameters 6 | { 7 | using Microsoft.AspNetCore.Mvc; 8 | 9 | [ModelBinder(typeof(ParametersModelBinder))] 10 | public class OrderItemsParametersModel 11 | { 12 | public OrderItemsParametersModel() 13 | { 14 | Limit = Configurations.DefaultLimit; 15 | Page = Configurations.DefaultPageValue; 16 | SinceId = 0; 17 | Fields = string.Empty; 18 | } 19 | 20 | [JsonProperty("limit")] 21 | public int Limit { get; set; } 22 | 23 | [JsonProperty("page")] 24 | public int Page { get; set; } 25 | 26 | [JsonProperty("since_id")] 27 | public int SinceId { get; set; } 28 | 29 | [JsonProperty("fields")] 30 | public string Fields { get; set; } 31 | } 32 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/OrdersParameters/OrdersCountParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.ModelBinders; 2 | 3 | namespace Nop.Plugin.Api.Models.OrdersParameters 4 | { 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | [ModelBinder(typeof(ParametersModelBinder))] 8 | public class OrdersCountParametersModel : BaseOrdersParametersModel 9 | { 10 | // Nothing special here, created just for clarity. 11 | } 12 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/OrdersParameters/OrdersParametersModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Nop.Plugin.Api.Constants; 4 | using Nop.Plugin.Api.ModelBinders; 5 | 6 | namespace Nop.Plugin.Api.Models.OrdersParameters 7 | { 8 | using Microsoft.AspNetCore.Mvc; 9 | 10 | // JsonProperty is used only for swagger 11 | [ModelBinder(typeof(ParametersModelBinder))] 12 | public class OrdersParametersModel : BaseOrdersParametersModel 13 | { 14 | public OrdersParametersModel() 15 | { 16 | Ids = null; 17 | Limit = Configurations.DefaultLimit; 18 | Page = Configurations.DefaultPageValue; 19 | SinceId = Configurations.DefaultSinceId; 20 | Fields = string.Empty; 21 | } 22 | 23 | /// 24 | /// A comma-separated list of order ids 25 | /// 26 | [JsonProperty("ids")] 27 | public List Ids { get; set; } 28 | 29 | /// 30 | /// Amount of results (default: 50) (maximum: 250) 31 | /// 32 | [JsonProperty("limit")] 33 | public int Limit { get; set; } 34 | 35 | /// 36 | /// Page to show (default: 1) 37 | /// 38 | [JsonProperty("page")] 39 | public int Page { get; set; } 40 | 41 | /// 42 | /// Restrict results to after the specified ID 43 | /// 44 | [JsonProperty("since_id")] 45 | public int SinceId { get; set; } 46 | 47 | /// 48 | /// comma-separated list of fields to include in the response 49 | /// 50 | [JsonProperty("fields")] 51 | public string Fields { get; set; } 52 | } 53 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ProductAttributesParameters/ProductAttributesParametersModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Newtonsoft.Json; 4 | using Nop.Plugin.Api.Constants; 5 | using Nop.Plugin.Api.ModelBinders; 6 | 7 | namespace Nop.Plugin.Api.Models.ProductAttributes 8 | { 9 | // JsonProperty is used only for swagger 10 | [ModelBinder(typeof(ParametersModelBinder))] 11 | public class ProductAttributesParametersModel 12 | { 13 | public ProductAttributesParametersModel() 14 | { 15 | Ids = null; 16 | Limit = Configurations.DefaultLimit; 17 | Page = Configurations.DefaultPageValue; 18 | SinceId = Configurations.DefaultSinceId; 19 | Fields = string.Empty; 20 | } 21 | 22 | /// 23 | /// A comma-separated list of category ids 24 | /// 25 | [JsonProperty("ids")] 26 | public List Ids { get; set; } 27 | 28 | /// 29 | /// Amount of results (default: 50) (maximum: 250) 30 | /// 31 | [JsonProperty("limit")] 32 | public int Limit { get; set; } 33 | 34 | /// 35 | /// Page to show (default: 1) 36 | /// 37 | [JsonProperty("page")] 38 | public int Page { get; set; } 39 | 40 | /// 41 | /// Restrict results to after the specified ID 42 | /// 43 | [JsonProperty("since_id")] 44 | public int SinceId { get; set; } 45 | 46 | /// 47 | /// comma-separated list of fields to include in the response 48 | /// 49 | [JsonProperty("fields")] 50 | public string Fields { get; set; } 51 | } 52 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ProductCategoryMappingsParameters/BaseCategoryMappingsParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.Models.ProductCategoryMappingsParameters 4 | { 5 | // JsonProperty is used only for swagger 6 | public class BaseCategoryMappingsParametersModel 7 | { 8 | /// 9 | /// Show all the product-category mappings for this product 10 | /// 11 | [JsonProperty("product_id")] 12 | public int? ProductId { get; set; } 13 | 14 | /// 15 | /// Show all the product-category mappings for this category 16 | /// 17 | [JsonProperty("category_id")] 18 | public int? CategoryId { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ProductCategoryMappingsParameters/ProductCategoryMappingsCountParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.ModelBinders; 2 | 3 | namespace Nop.Plugin.Api.Models.ProductCategoryMappingsParameters 4 | { 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | [ModelBinder(typeof(ParametersModelBinder))] 8 | public class ProductCategoryMappingsCountParametersModel : BaseCategoryMappingsParametersModel 9 | { 10 | // Nothing special here, created just for clarity. 11 | } 12 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ProductCategoryMappingsParameters/ProductCategoryMappingsParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Nop.Plugin.Api.Constants; 3 | using Nop.Plugin.Api.ModelBinders; 4 | 5 | namespace Nop.Plugin.Api.Models.ProductCategoryMappingsParameters 6 | { 7 | using Microsoft.AspNetCore.Mvc; 8 | 9 | // JsonProperty is used only for swagger 10 | [ModelBinder(typeof(ParametersModelBinder))] 11 | public class ProductCategoryMappingsParametersModel : BaseCategoryMappingsParametersModel 12 | { 13 | public ProductCategoryMappingsParametersModel() 14 | { 15 | SinceId = Configurations.DefaultSinceId; 16 | Page = Configurations.DefaultPageValue; 17 | Limit = Configurations.DefaultLimit; 18 | Fields = string.Empty; 19 | } 20 | 21 | /// 22 | /// Restrict results to after the specified ID 23 | /// 24 | [JsonProperty("since_id")] 25 | public int SinceId { get; set; } 26 | 27 | /// 28 | /// Page to show (default: 1) 29 | /// 30 | [JsonProperty("page")] 31 | public int Page { get; set; } 32 | 33 | /// 34 | /// Amount of results (default: 50) (maximum: 250) 35 | /// 36 | [JsonProperty("limit")] 37 | public int Limit { get; set; } 38 | 39 | /// 40 | /// comma-separated list of fields to include in the response 41 | /// 42 | [JsonProperty("fields")] 43 | public string Fields { get; set; } 44 | } 45 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ProductManufacturerMappingsParameters/BaseManufacturerMappingsParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Nop.Plugin.Api.Models.ProductManufacturerMappingsParameters 4 | { 5 | // JsonProperty is used only for swagger 6 | public class BaseManufacturerMappingsParametersModel 7 | { 8 | /// 9 | /// Show all the product-manufacturer mappings for this product 10 | /// 11 | [JsonProperty("product_id")] 12 | public int? ProductId { get; set; } 13 | 14 | /// 15 | /// Show all the product-manufacturer mappings for this manufacturer 16 | /// 17 | [JsonProperty("manufacturer_id")] 18 | public int? ManufacturerId { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ProductManufacturerMappingsParameters/ProductManufacturerMappingsCountParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.ModelBinders; 2 | 3 | namespace Nop.Plugin.Api.Models.ProductManufacturerMappingsParameters 4 | { 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | [ModelBinder(typeof(ParametersModelBinder))] 8 | public class ProductManufacturerMappingsCountParametersModel : BaseManufacturerMappingsParametersModel 9 | { 10 | // Nothing special here, created just for clarity. 11 | } 12 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ProductManufacturerMappingsParameters/ProductManufacturerMappingsParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Nop.Plugin.Api.Constants; 3 | using Nop.Plugin.Api.ModelBinders; 4 | 5 | namespace Nop.Plugin.Api.Models.ProductManufacturerMappingsParameters 6 | { 7 | using Microsoft.AspNetCore.Mvc; 8 | 9 | // JsonProperty is used only for swagger 10 | [ModelBinder(typeof(ParametersModelBinder))] 11 | public class ProductManufacturerMappingsParametersModel : BaseManufacturerMappingsParametersModel 12 | { 13 | public ProductManufacturerMappingsParametersModel() 14 | { 15 | SinceId = Configurations.DefaultSinceId; 16 | Page = Configurations.DefaultPageValue; 17 | Limit = Configurations.DefaultLimit; 18 | Fields = string.Empty; 19 | } 20 | 21 | /// 22 | /// Restrict results to after the specified ID 23 | /// 24 | [JsonProperty("since_id")] 25 | public int SinceId { get; set; } 26 | 27 | /// 28 | /// Page to show (default: 1) 29 | /// 30 | [JsonProperty("page")] 31 | public int Page { get; set; } 32 | 33 | /// 34 | /// Amount of results (default: 50) (maximum: 250) 35 | /// 36 | [JsonProperty("limit")] 37 | public int Limit { get; set; } 38 | 39 | /// 40 | /// comma-separated list of fields to include in the response 41 | /// 42 | [JsonProperty("fields")] 43 | public string Fields { get; set; } 44 | } 45 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ProductSpecificationAttributesParameters/ProductSpecificationAttributesCountParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Newtonsoft.Json; 3 | using Nop.Plugin.Api.ModelBinders; 4 | 5 | namespace Nop.Plugin.Api.Models.ProductSpecificationAttributes 6 | { 7 | // JsonProperty is used only for swagger 8 | [ModelBinder(typeof(ParametersModelBinder))] 9 | public class ProductSpecifcationAttributesCountParametersModel 10 | { 11 | public ProductSpecifcationAttributesCountParametersModel() 12 | { 13 | 14 | } 15 | 16 | /// 17 | /// Product Id 18 | /// 19 | [JsonProperty("product_id")] 20 | public int ProductId { get; set; } 21 | 22 | /// 23 | /// Specification Attribute Option Id 24 | /// 25 | [JsonProperty("specification_attribute_option_id")] 26 | public int SpecificationAttributeOptionId { get; set; } 27 | } 28 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ProductsParameters/ProductsCountParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.ModelBinders; 2 | 3 | namespace Nop.Plugin.Api.Models.ProductsParameters 4 | { 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | [ModelBinder(typeof(ParametersModelBinder))] 8 | public class ProductsCountParametersModel : BaseProductsParametersModel 9 | { 10 | // Nothing special here, created just for clarity. 11 | } 12 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ProductsParameters/ProductsParametersModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Nop.Plugin.Api.Constants; 4 | using Nop.Plugin.Api.ModelBinders; 5 | 6 | namespace Nop.Plugin.Api.Models.ProductsParameters 7 | { 8 | using Microsoft.AspNetCore.Mvc; 9 | 10 | // JsonProperty is used only for swagger 11 | [ModelBinder(typeof(ParametersModelBinder))] 12 | public class ProductsParametersModel : BaseProductsParametersModel 13 | { 14 | public ProductsParametersModel() 15 | { 16 | Ids = null; 17 | Limit = Configurations.DefaultLimit; 18 | Page = Configurations.DefaultPageValue; 19 | SinceId = Configurations.DefaultSinceId; 20 | Fields = string.Empty; 21 | } 22 | 23 | /// 24 | /// A comma-separated list of order ids 25 | /// 26 | [JsonProperty("ids")] 27 | public List Ids { get; set; } 28 | 29 | /// 30 | /// Amount of results (default: 50) (maximum: 250) 31 | /// 32 | [JsonProperty("limit")] 33 | public int Limit { get; set; } 34 | 35 | /// 36 | /// Page to show (default: 1) 37 | /// 38 | [JsonProperty("page")] 39 | public int Page { get; set; } 40 | 41 | /// 42 | /// Restrict results to after the specified ID 43 | /// 44 | [JsonProperty("since_id")] 45 | public int SinceId { get; set; } 46 | 47 | /// 48 | /// comma-separated list of fields to include in the response 49 | /// 50 | [JsonProperty("fields")] 51 | public string Fields { get; set; } 52 | } 53 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ShoppingCartsParameters/ShoppingCartItemsForCustomerParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.ModelBinders; 2 | 3 | namespace Nop.Plugin.Api.Models.ShoppingCartsParameters 4 | { 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | [ModelBinder(typeof(ParametersModelBinder))] 8 | public class ShoppingCartItemsForCustomerParametersModel : BaseShoppingCartItemsParametersModel 9 | { 10 | // Nothing special here, created just for clarity. 11 | } 12 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/ShoppingCartsParameters/ShoppingCartItemsParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.ModelBinders; 2 | 3 | namespace Nop.Plugin.Api.Models.ShoppingCartsParameters 4 | { 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | [ModelBinder(typeof(ParametersModelBinder))] 8 | public class ShoppingCartItemsParametersModel : BaseShoppingCartItemsParametersModel 9 | { 10 | // Nothing special here, created just for clarity. 11 | } 12 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/SpecificationAttributesParameters/SpecificationAttributesCountParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Newtonsoft.Json; 3 | using Nop.Plugin.Api.ModelBinders; 4 | 5 | namespace Nop.Plugin.Api.Models.SpecificationAttributes 6 | { 7 | // JsonProperty is used only for swagger 8 | [ModelBinder(typeof(ParametersModelBinder))] 9 | public class SpecifcationAttributesCountParametersModel 10 | { 11 | public SpecifcationAttributesCountParametersModel() 12 | { 13 | 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Models/SpecificationAttributesParameters/SpecificationAttributesParametersModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Newtonsoft.Json; 3 | using Nop.Plugin.Api.Constants; 4 | using Nop.Plugin.Api.ModelBinders; 5 | 6 | namespace Nop.Plugin.Api.Models.SpecificationAttributes 7 | { 8 | [ModelBinder(typeof(ParametersModelBinder))] 9 | public class SpecifcationAttributesParametersModel 10 | { 11 | public SpecifcationAttributesParametersModel() 12 | { 13 | Limit = Configurations.DefaultLimit; 14 | Page = Configurations.DefaultPageValue; 15 | SinceId = Configurations.DefaultSinceId; 16 | } 17 | 18 | /// 19 | /// Amount of results (default: 50) (maximum: 250) 20 | /// 21 | [JsonProperty("limit")] 22 | public int Limit { get; set; } 23 | 24 | /// 25 | /// Page to show (default: 1) 26 | /// 27 | [JsonProperty("page")] 28 | public int Page { get; set; } 29 | 30 | /// 31 | /// comma-separated list of fields to include in the response 32 | /// 33 | [JsonProperty("fields")] 34 | public string Fields { get; set; } 35 | 36 | /// 37 | /// Restrict results to after the specified ID 38 | /// 39 | [JsonProperty("since_id")] 40 | public int SinceId { get; set; } 41 | } 42 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/RouteProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Routing; 2 | using Nop.Web.Framework.Mvc.Routing; 3 | 4 | namespace Nop.Plugin.Api 5 | { 6 | public class RouteProvider : IRouteProvider 7 | { 8 | public void RegisterRoutes(IRouteBuilder routeBuilder) 9 | { 10 | 11 | } 12 | 13 | public int Priority => -1; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/ICategoryApiService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Nop.Core.Domain.Catalog; 4 | using Nop.Plugin.Api.Constants; 5 | 6 | namespace Nop.Plugin.Api.Services 7 | { 8 | public interface ICategoryApiService 9 | { 10 | Category GetCategoryById(int categoryId); 11 | 12 | IList GetCategories(IList ids = null, 13 | DateTime? createdAtMin = null, DateTime? createdAtMax = null, DateTime? updatedAtMin = null, DateTime? updatedAtMax = null, 14 | int limit = Configurations.DefaultLimit, int page = Configurations.DefaultPageValue, int sinceId = Configurations.DefaultSinceId, 15 | int? productId = null, bool? publishedStatus = null); 16 | 17 | int GetCategoriesCount(DateTime? createdAtMin = null, DateTime? createdAtMax = null, DateTime? updatedAtMin = null, DateTime? updatedAtMax = null, 18 | bool? publishedStatus = null, int? productId = null); 19 | } 20 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/IClientService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Nop.Plugin.Api.Services 4 | { 5 | using Models; 6 | 7 | public interface IClientService 8 | { 9 | IList GetAllClients(); 10 | void DeleteClient(int id); 11 | int InsertClient(ClientApiModel model); 12 | void UpdateClient(ClientApiModel model); 13 | ClientApiModel FindClientByIdAsync(int id); 14 | ClientApiModel FindClientByClientId(string clientId); 15 | } 16 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/ICustomerApiService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Nop.Core.Domain.Customers; 4 | using Nop.Plugin.Api.Constants; 5 | using Nop.Plugin.Api.DTOs.Customers; 6 | 7 | namespace Nop.Plugin.Api.Services 8 | { 9 | public interface ICustomerApiService 10 | { 11 | int GetCustomersCount(); 12 | 13 | CustomerDto GetCustomerById(int id, bool showDeleted = false); 14 | 15 | Customer GetCustomerEntityById(int id); 16 | 17 | IList GetCustomersDtos(DateTime? createdAtMin = null, DateTime? createdAtMax = null, 18 | int limit = Configurations.DefaultLimit, int page = Configurations.DefaultPageValue, int sinceId = Configurations.DefaultSinceId); 19 | 20 | IList Search(string query = "", string order = Configurations.DefaultOrder, 21 | int page = Configurations.DefaultPageValue, int limit = Configurations.DefaultLimit); 22 | 23 | Dictionary GetFirstAndLastNameByCustomerId(int customerId); 24 | } 25 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/IManufacturerApiService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Nop.Core.Domain.Catalog; 4 | using Nop.Plugin.Api.Constants; 5 | 6 | namespace Nop.Plugin.Api.Services 7 | { 8 | public interface IManufacturerApiService 9 | { 10 | Manufacturer GetManufacturerById(int manufacturerId); 11 | 12 | IList GetManufacturers(IList ids = null, 13 | DateTime? createdAtMin = null, DateTime? createdAtMax = null, DateTime? updatedAtMin = null, DateTime? updatedAtMax = null, 14 | int limit = Configurations.DefaultLimit, int page = Configurations.DefaultPageValue, int sinceId = Configurations.DefaultSinceId, 15 | int? productId = null, bool? publishedStatus = null, int? languageId = null); 16 | 17 | int GetManufacturersCount(DateTime? createdAtMin = null, DateTime? createdAtMax = null, DateTime? updatedAtMin = null, DateTime? updatedAtMax = null, 18 | bool? publishedStatus = null, int? productId = null); 19 | } 20 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/INewsLetterSubscriptionApiService.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Messages; 2 | using Nop.Plugin.Api.Constants; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace Nop.Plugin.Api.Services 7 | { 8 | public interface INewsLetterSubscriptionApiService 9 | { 10 | List GetNewsLetterSubscriptions(DateTime? createdAtMin = null, DateTime? createdAtMax = null, 11 | int limit = Configurations.DefaultLimit, int page = Configurations.DefaultPageValue, int sinceId = Configurations.DefaultSinceId, 12 | bool? onlyActive = true); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/IOrderApiService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Nop.Core.Domain.Orders; 4 | using Nop.Core.Domain.Payments; 5 | using Nop.Core.Domain.Shipping; 6 | using Nop.Plugin.Api.Constants; 7 | 8 | namespace Nop.Plugin.Api.Services 9 | { 10 | public interface IOrderApiService 11 | { 12 | IList GetOrdersByCustomerId(int customerId); 13 | 14 | IList GetOrders(IList ids = null, DateTime? createdAtMin = null, DateTime? createdAtMax = null, 15 | int limit = Configurations.DefaultLimit, int page = Configurations.DefaultPageValue, 16 | int sinceId = Configurations.DefaultSinceId, OrderStatus? status = null, PaymentStatus? paymentStatus = null, 17 | ShippingStatus? shippingStatus = null, int? customerId = null, int? storeId = null); 18 | 19 | Order GetOrderById(int orderId); 20 | 21 | int GetOrdersCount(DateTime? createdAtMin = null, DateTime? createdAtMax = null, OrderStatus? status = null, 22 | PaymentStatus? paymentStatus = null, ShippingStatus? shippingStatus = null, 23 | int? customerId = null, int? storeId = null); 24 | } 25 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/IOrderItemApiService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Nop.Core.Domain.Orders; 3 | 4 | namespace Nop.Plugin.Api.Services 5 | { 6 | public interface IOrderItemApiService 7 | { 8 | IList GetOrderItemsForOrder(Order order, int limit, int page, int sinceId); 9 | int GetOrderItemsCount(Order order); 10 | } 11 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/IProductApiService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Nop.Core.Domain.Catalog; 4 | using Nop.Plugin.Api.Constants; 5 | 6 | namespace Nop.Plugin.Api.Services 7 | { 8 | public interface IProductApiService 9 | { 10 | IList GetProducts(IList ids = null, 11 | DateTime? createdAtMin = null, DateTime? createdAtMax = null, DateTime? updatedAtMin = null, DateTime? updatedAtMax = null, 12 | int limit = Configurations.DefaultLimit, int page = Configurations.DefaultPageValue, int sinceId = Configurations.DefaultSinceId, 13 | int? categoryId = null, string vendorName = null, bool? publishedStatus = null); 14 | 15 | int GetProductsCount(DateTime? createdAtMin = null, DateTime? createdAtMax = null, 16 | DateTime? updatedAtMin = null, DateTime? updatedAtMax = null, bool? publishedStatus = null, 17 | string vendorName = null, int? categoryId = null); 18 | 19 | Product GetProductById(int productId); 20 | 21 | Product GetProductByIdNoTracking(int productId); 22 | } 23 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/IProductAttributeConverter.cs: -------------------------------------------------------------------------------- 1 | using Nop.Plugin.Api.DTOs; 2 | using System.Collections.Generic; 3 | 4 | namespace Nop.Plugin.Api.Services 5 | { 6 | public interface IProductAttributeConverter 7 | { 8 | List Parse(string attributesXml); 9 | string ConvertToXml(List attributeDtos, int productId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/IProductAttributesApiService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Nop.Core.Domain.Catalog; 3 | using Nop.Plugin.Api.Constants; 4 | 5 | namespace Nop.Plugin.Api.Services 6 | { 7 | public interface IProductAttributesApiService 8 | { 9 | IList GetProductAttributes(int limit = Configurations.DefaultLimit, 10 | int page = Configurations.DefaultPageValue, int sinceId = Configurations.DefaultSinceId); 11 | 12 | int GetProductAttributesCount(); 13 | 14 | ProductAttribute GetById(int id); 15 | } 16 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/IProductCategoryMappingsApiService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Nop.Core.Domain.Catalog; 3 | using Nop.Plugin.Api.Constants; 4 | 5 | namespace Nop.Plugin.Api.Services 6 | { 7 | public interface IProductCategoryMappingsApiService 8 | { 9 | IList GetMappings(int? productId = null, int? categoryId = null, int limit = Configurations.DefaultLimit, 10 | int page = Configurations.DefaultPageValue, int sinceId = Configurations.DefaultSinceId); 11 | 12 | int GetMappingsCount(int? productId = null, int? categoryId = null); 13 | 14 | ProductCategory GetById(int id); 15 | } 16 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/IProductManufacturerMappingsApiService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Nop.Core.Domain.Catalog; 3 | using Nop.Plugin.Api.Constants; 4 | 5 | namespace Nop.Plugin.Api.Services 6 | { 7 | public interface IProductManufacturerMappingsApiService 8 | { 9 | IList GetMappings(int? productId = null, int? manufacturerId = null, int limit = Configurations.DefaultLimit, 10 | int page = Configurations.DefaultPageValue, int sinceId = Configurations.DefaultSinceId); 11 | 12 | int GetMappingsCount(int? productId = null, int? manufacturerId = null); 13 | 14 | ProductManufacturer GetById(int id); 15 | } 16 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/IProductPictureService.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Catalog; 2 | 3 | namespace Nop.Plugin.Api.Services 4 | { 5 | public interface IProductPictureService 6 | { 7 | ProductPicture GetProductPictureByPictureId(int pictureId); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/IShoppingCartItemApiService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Nop.Core.Domain.Orders; 4 | using Nop.Plugin.Api.Constants; 5 | 6 | namespace Nop.Plugin.Api.Services 7 | { 8 | public interface IShoppingCartItemApiService 9 | { 10 | List GetShoppingCartItems(int? customerId = null, DateTime? createdAtMin = null, DateTime? createdAtMax = null, 11 | DateTime? updatedAtMin = null, DateTime? updatedAtMax = null, int limit = Configurations.DefaultLimit, 12 | int page = Configurations.DefaultPageValue); 13 | 14 | ShoppingCartItem GetShoppingCartItem(int id); 15 | } 16 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/ISpecificationAttributeApiService.cs: -------------------------------------------------------------------------------- 1 | using Nop.Core.Domain.Catalog; 2 | using Nop.Plugin.Api.Constants; 3 | using System.Collections.Generic; 4 | 5 | namespace Nop.Plugin.Api.Services 6 | { 7 | public interface ISpecificationAttributeApiService 8 | { 9 | IList GetProductSpecificationAttributes(int? productId = null, int? specificationAttributeOptionId = null, bool? allowFiltering = null, bool? showOnProductPage = null, int limit = Configurations.DefaultLimit, int page = Configurations.DefaultPageValue, int sinceId = Configurations.DefaultSinceId); 10 | IList GetSpecificationAttributes(int limit = Configurations.DefaultLimit, int page = Configurations.DefaultPageValue, int sinceId = Configurations.DefaultSinceId); 11 | } 12 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/IWebHookService.cs: -------------------------------------------------------------------------------- 1 | //namespace Nop.Plugin.Api.Services 2 | //{ 3 | // using Microsoft.AspNet.WebHooks; 4 | 5 | // public interface IWebHookService 6 | // { 7 | // IWebHookManager GetWebHookManager(); 8 | // IWebHookSender GetWebHookSender(); 9 | // IWebHookStore GetWebHookStore(); 10 | // IWebHookFilterManager GetWebHookFilterManager(); 11 | // } 12 | //} 13 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/OrderItemApiService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Nop.Core.Domain.Orders; 4 | using Nop.Plugin.Api.DataStructures; 5 | 6 | namespace Nop.Plugin.Api.Services 7 | { 8 | public class OrderItemApiService : IOrderItemApiService 9 | { 10 | public IList GetOrderItemsForOrder(Order order, int limit, int page, int sinceId) 11 | { 12 | var orderItems = order.OrderItems.AsQueryable(); 13 | 14 | return new ApiList(orderItems, page - 1, limit); 15 | } 16 | 17 | public int GetOrderItemsCount(Order order) 18 | { 19 | var orderItemsCount = order.OrderItems.Count(); 20 | 21 | return orderItemsCount; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/ProductAttributesApiService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Nop.Core.Data; 4 | using Nop.Core.Domain.Catalog; 5 | using Nop.Plugin.Api.Constants; 6 | using Nop.Plugin.Api.DataStructures; 7 | 8 | namespace Nop.Plugin.Api.Services 9 | { 10 | public class ProductAttributesApiService : IProductAttributesApiService 11 | { 12 | private readonly IRepository _productAttributesRepository; 13 | 14 | public ProductAttributesApiService(IRepository productAttributesRepository) 15 | { 16 | _productAttributesRepository = productAttributesRepository; 17 | } 18 | 19 | public IList GetProductAttributes(int limit = Configurations.DefaultLimit, 20 | int page = Configurations.DefaultPageValue, int sinceId = Configurations.DefaultSinceId) 21 | { 22 | var query = GetProductAttributesQuery(sinceId); 23 | 24 | return new ApiList(query, page - 1, limit); 25 | } 26 | 27 | public int GetProductAttributesCount() 28 | { 29 | return GetProductAttributesQuery().Count(); 30 | } 31 | 32 | ProductAttribute IProductAttributesApiService.GetById(int id) 33 | { 34 | if (id <= 0) 35 | return null; 36 | 37 | return _productAttributesRepository.GetById(id); 38 | } 39 | 40 | private IQueryable GetProductAttributesQuery(int sinceId = Configurations.DefaultSinceId) 41 | { 42 | var query = _productAttributesRepository.Table; 43 | 44 | if (sinceId > 0) 45 | { 46 | query = query.Where(productAttribute => productAttribute.Id > sinceId); 47 | } 48 | 49 | query = query.OrderBy(productAttribute => productAttribute.Id); 50 | 51 | return query; 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Services/ProductPictureService.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Nop.Core.Data; 3 | using Nop.Core.Domain.Catalog; 4 | 5 | namespace Nop.Plugin.Api.Services 6 | { 7 | public class ProductPictureService : IProductPictureService 8 | { 9 | private readonly IRepository _productPictureRepository; 10 | 11 | public ProductPictureService(IRepository productPictureRepository) 12 | { 13 | _productPictureRepository = productPictureRepository; 14 | } 15 | 16 | public ProductPicture GetProductPictureByPictureId(int pictureId) 17 | { 18 | if (pictureId == 0) 19 | return null; 20 | 21 | var query = from pp in _productPictureRepository.Table 22 | where pp.PictureId == pictureId 23 | select pp; 24 | 25 | var productPictures = query.ToList(); 26 | 27 | return productPictures.FirstOrDefault(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/Validators/CategoryDtoValidator.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Nop.Plugin.Api.DTOs.Categories; 3 | using Nop.Plugin.Api.Helpers; 4 | using System.Collections.Generic; 5 | 6 | namespace Nop.Plugin.Api.Validators 7 | { 8 | public class CategoryDtoValidator : BaseDtoValidator 9 | { 10 | 11 | #region Constructors 12 | 13 | public CategoryDtoValidator(IHttpContextAccessor httpContextAccessor, IJsonHelper jsonHelper, Dictionary requestJsonDictionary) : base(httpContextAccessor, jsonHelper, requestJsonDictionary) 14 | { 15 | SetNameRule(); 16 | } 17 | 18 | #endregion 19 | 20 | #region Private Methods 21 | 22 | private void SetNameRule() 23 | { 24 | SetNotNullOrEmptyCreateOrUpdateRule(c => c.Name, "invalid name", "name"); 25 | } 26 | 27 | #endregion 28 | 29 | } 30 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Validators/ClientValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | using Nop.Services.Localization; 3 | 4 | namespace Nop.Plugin.Api.Validators 5 | { 6 | using IdentityServer4.Models; 7 | 8 | public class ClientValidator : AbstractValidator 9 | { 10 | public ClientValidator(ILocalizationService localizationService) 11 | { 12 | RuleFor(x => x.ClientName).NotEmpty().WithMessage(localizationService.GetResource("Plugins.Api.Admin.Entities.Client.FieldValidationMessages.Name")); 13 | RuleFor(x => x.ClientId).NotEmpty().WithMessage(localizationService.GetResource("Plugins.Api.Admin.Entities.Client.FieldValidationMessages.ClientId")); 14 | RuleFor(x => x.ClientSecrets).NotEmpty().WithMessage(localizationService.GetResource("Plugins.Api.Admin.Entities.Client.FieldValidationMessages.ClientSecret")); 15 | RuleFor(x => x.RedirectUris).NotEmpty().WithMessage(localizationService.GetResource("Plugins.Api.Admin.Entities.Client.FieldValidationMessages.CallbackUrl")); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Validators/FieldsValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | 6 | namespace Nop.Plugin.Api.Validators 7 | { 8 | public class FieldsValidator : IFieldsValidator 9 | { 10 | private static IEnumerable GetPropertiesIntoList(string fields) 11 | { 12 | var properties = fields.ToLowerInvariant() 13 | .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) 14 | .Select(x => x.Trim()) 15 | .Distinct() 16 | .ToList(); 17 | 18 | return properties; 19 | } 20 | 21 | public Dictionary GetValidFields(string fields, Type type) 22 | { 23 | // This check ensures that the fields won't be null, because it can couse exception. 24 | fields = fields ?? string.Empty; 25 | // This is needed in case you pass the fields as you see them in the json representation of the objects. 26 | // By specification if the property consists of several words, each word should be separetate from the others with underscore. 27 | fields = fields.Replace("_", string.Empty); 28 | 29 | var validFields = new Dictionary(); 30 | var fieldsAsList = GetPropertiesIntoList(fields); 31 | 32 | foreach (var field in fieldsAsList) 33 | { 34 | var propertyExists = type.GetProperty(field, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance) != null; 35 | 36 | if (propertyExists) 37 | { 38 | validFields.Add(field, true); 39 | } 40 | } 41 | 42 | return validFields; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Validators/IFieldsValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Nop.Plugin.Api.Validators 5 | { 6 | public interface IFieldsValidator 7 | { 8 | //TODO: Why this needs to be dictionary??? 9 | Dictionary GetValidFields(string fields, Type type); 10 | } 11 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Validators/ManufacturerDtoValidator.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Nop.Plugin.Api.Helpers; 3 | using System.Collections.Generic; 4 | using Nop.Plugin.Api.DTOs.Manufacturers; 5 | 6 | namespace Nop.Plugin.Api.Validators 7 | { 8 | public class ManufacturerDtoValidator : BaseDtoValidator 9 | { 10 | 11 | #region Constructors 12 | 13 | public ManufacturerDtoValidator(IHttpContextAccessor httpContextAccessor, IJsonHelper jsonHelper, Dictionary requestJsonDictionary) : base(httpContextAccessor, jsonHelper, requestJsonDictionary) 14 | { 15 | SetNameRule(); 16 | } 17 | 18 | #endregion 19 | 20 | #region Private Methods 21 | 22 | private void SetNameRule() 23 | { 24 | SetNotNullOrEmptyCreateOrUpdateRule(m => m.Name, "invalid name", "name"); 25 | } 26 | 27 | #endregion 28 | 29 | } 30 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Validators/OrderItemDtoValidator.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Nop.Plugin.Api.DTOs.OrderItems; 3 | using Nop.Plugin.Api.Helpers; 4 | using System.Collections.Generic; 5 | 6 | namespace Nop.Plugin.Api.Validators 7 | { 8 | public class OrderItemDtoValidator : BaseDtoValidator 9 | { 10 | 11 | #region Constructors 12 | 13 | public OrderItemDtoValidator(IHttpContextAccessor httpContextAccessor, IJsonHelper jsonHelper, Dictionary requestJsonDictionary) : base(httpContextAccessor, jsonHelper, requestJsonDictionary) 14 | { 15 | SetProductIdRule(); 16 | SetQuantityRule(); 17 | } 18 | 19 | #endregion 20 | 21 | #region Private Methods 22 | 23 | private void SetProductIdRule() 24 | { 25 | SetGreaterThanZeroCreateOrUpdateRule(o => o.ProductId, "invalid product_id", "product_id"); 26 | } 27 | 28 | private void SetQuantityRule() 29 | { 30 | SetGreaterThanZeroCreateOrUpdateRule(o => o.Quantity, "invalid quanitty", "quantity"); 31 | } 32 | 33 | #endregion 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Validators/ProductAttributeCombinationDtoValidator.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Nop.Plugin.Api.DTOs.Products; 3 | using Nop.Plugin.Api.Helpers; 4 | using System.Collections.Generic; 5 | 6 | namespace Nop.Plugin.Api.Validators 7 | { 8 | public class ProductAttributeCombinationDtoValidator : BaseDtoValidator 9 | { 10 | 11 | #region Constructors 12 | 13 | public ProductAttributeCombinationDtoValidator(IHttpContextAccessor httpContextAccessor, IJsonHelper jsonHelper, Dictionary requestJsonDictionary) : base(httpContextAccessor, jsonHelper, requestJsonDictionary) 14 | { 15 | SetAttributesXmlRule(); 16 | SetProductIdRule(); 17 | } 18 | 19 | #endregion 20 | 21 | #region Private Methods 22 | 23 | private void SetAttributesXmlRule() 24 | { 25 | SetNotNullOrEmptyCreateOrUpdateRule(p => p.AttributesXml, "invalid attributes xml", "attributes_xml"); 26 | } 27 | 28 | private void SetProductIdRule() 29 | { 30 | SetGreaterThanZeroCreateOrUpdateRule(p => p.ProductId, "invalid product id", "product_id"); 31 | } 32 | 33 | #endregion 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Validators/ProductAttributeDtoValidator.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Nop.Plugin.Api.DTOs.ProductAttributes; 3 | using Nop.Plugin.Api.Helpers; 4 | using System.Collections.Generic; 5 | 6 | namespace Nop.Plugin.Api.Validators 7 | { 8 | public class ProductAttributeDtoValidator : BaseDtoValidator 9 | { 10 | 11 | #region Constructors 12 | 13 | public ProductAttributeDtoValidator(IHttpContextAccessor httpContextAccessor, IJsonHelper jsonHelper, Dictionary requestJsonDictionary) : base(httpContextAccessor, jsonHelper, requestJsonDictionary) 14 | { 15 | SetNameRule(); 16 | } 17 | 18 | #endregion 19 | 20 | #region Private Methods 21 | 22 | private void SetNameRule() 23 | { 24 | SetNotNullOrEmptyCreateOrUpdateRule(p => p.Name, "invalid name", "name"); 25 | } 26 | 27 | #endregion 28 | 29 | } 30 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Validators/ProductCategoryMappingDtoValidator.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Nop.Plugin.Api.DTOs.ProductCategoryMappings; 3 | using Nop.Plugin.Api.Helpers; 4 | using System.Collections.Generic; 5 | 6 | namespace Nop.Plugin.Api.Validators 7 | { 8 | public class ProductCategoryMappingDtoValidator : BaseDtoValidator 9 | { 10 | 11 | #region Constructors 12 | 13 | public ProductCategoryMappingDtoValidator(IHttpContextAccessor httpContextAccessor, IJsonHelper jsonHelper, Dictionary requestJsonDictionary) : base(httpContextAccessor, jsonHelper, requestJsonDictionary) 14 | { 15 | SetCategoryIdRule(); 16 | SetProductIdRule(); 17 | } 18 | 19 | #endregion 20 | 21 | #region Private Methods 22 | 23 | private void SetCategoryIdRule() 24 | { 25 | SetGreaterThanZeroCreateOrUpdateRule(p => p.CategoryId, "invalid category_id", "category_id"); 26 | } 27 | 28 | private void SetProductIdRule() 29 | { 30 | SetGreaterThanZeroCreateOrUpdateRule(p => p.ProductId, "invalid product_id", "product_id"); 31 | } 32 | 33 | #endregion 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Validators/ProductDtoValidator.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Nop.Plugin.Api.DTOs.Products; 3 | using Nop.Plugin.Api.Helpers; 4 | using System.Collections.Generic; 5 | 6 | namespace Nop.Plugin.Api.Validators 7 | { 8 | public class ProductDtoValidator : BaseDtoValidator 9 | { 10 | 11 | #region Constructors 12 | 13 | public ProductDtoValidator(IHttpContextAccessor httpContextAccessor, IJsonHelper jsonHelper, Dictionary requestJsonDictionary) : base(httpContextAccessor, jsonHelper, requestJsonDictionary) 14 | { 15 | SetNameRule(); 16 | } 17 | 18 | #endregion 19 | 20 | #region Private Methods 21 | 22 | private void SetNameRule() 23 | { 24 | SetNotNullOrEmptyCreateOrUpdateRule(p => p.Name, "invalid name", "name"); 25 | } 26 | 27 | #endregion 28 | 29 | } 30 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Validators/ProductManufacturerMappingDtoValidator.cs: -------------------------------------------------------------------------------- 1 |  2 | using Microsoft.AspNetCore.Http; 3 | using Nop.Plugin.Api.DTOs.ProductManufacturerMappings; 4 | using Nop.Plugin.Api.Helpers; 5 | using System.Collections.Generic; 6 | 7 | namespace Nop.Plugin.Api.Validators 8 | { 9 | public class ProductManufacturerMappingDtoValidator : BaseDtoValidator 10 | { 11 | 12 | #region Constructors 13 | 14 | public ProductManufacturerMappingDtoValidator(IHttpContextAccessor httpContextAccessor, IJsonHelper jsonHelper, Dictionary requestJsonDictionary) : base(httpContextAccessor, jsonHelper, requestJsonDictionary) 15 | { 16 | SetManufacturerIdRule(); 17 | SetProductIdRule(); 18 | } 19 | 20 | #endregion 21 | 22 | #region Private Methods 23 | 24 | private void SetManufacturerIdRule() 25 | { 26 | SetGreaterThanZeroCreateOrUpdateRule(p => p.ManufacturerId, "invalid manufacturer_id", "manufacturer_id"); 27 | } 28 | 29 | private void SetProductIdRule() 30 | { 31 | SetGreaterThanZeroCreateOrUpdateRule(p => p.ProductId, "invalid product_id", "product_id"); 32 | } 33 | 34 | #endregion 35 | 36 | } 37 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Validators/SpecificationAttributeDtoValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | using Nop.Plugin.Api.DTOs.SpecificationAttributes; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace Nop.Plugin.Api.Validators 7 | { 8 | public class SpecificationAttributeDtoValidator : AbstractValidator 9 | { 10 | public SpecificationAttributeDtoValidator(string httpMethod, Dictionary passedPropertyValuePaires) 11 | { 12 | if (string.IsNullOrEmpty(httpMethod) || httpMethod.Equals("post", StringComparison.InvariantCultureIgnoreCase)) 13 | { 14 | //apply "create" rules 15 | RuleFor(x => x.Id).Equal(0).WithMessage("id must be zero or null for new records"); 16 | 17 | ApplyNameRule(); 18 | } 19 | else if (httpMethod.Equals("put", StringComparison.InvariantCultureIgnoreCase)) 20 | { 21 | //apply "update" rules 22 | RuleFor(x => x.Id).GreaterThan(0).WithMessage("invalid id"); 23 | ApplyNameRule(); 24 | } 25 | } 26 | 27 | private void ApplyNameRule() 28 | { 29 | RuleFor(x => x.Name).NotEmpty().WithMessage("invalid name"); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Validators/SpecificationAttributeOptionDtoValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | using Nop.Plugin.Api.DTOs.SpecificationAttributes; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace Nop.Plugin.Api.Validators 7 | { 8 | public class SpecificationAttributeOptionDtoValidator : AbstractValidator 9 | { 10 | public SpecificationAttributeOptionDtoValidator(string httpMethod, Dictionary passedPropertyValuePaires) 11 | { 12 | if (string.IsNullOrEmpty(httpMethod) || httpMethod.Equals("post", StringComparison.InvariantCultureIgnoreCase)) 13 | { 14 | //apply "create" rules 15 | RuleFor(x => x.Id).Equal(0).WithMessage("id must be zero or null for new records"); 16 | 17 | ApplyNameRule(); 18 | ApplySpecificationAttributeIdRule(); 19 | } 20 | else if (httpMethod.Equals("put", StringComparison.InvariantCultureIgnoreCase)) 21 | { 22 | //apply "update" rules 23 | RuleFor(x => x.Id).GreaterThan(0).WithMessage("invalid id"); 24 | 25 | if (passedPropertyValuePaires.ContainsKey("name")) 26 | { 27 | ApplyNameRule(); 28 | } 29 | 30 | if (passedPropertyValuePaires.ContainsKey("specification_attribute_id")) 31 | { 32 | ApplySpecificationAttributeIdRule(); 33 | } 34 | } 35 | } 36 | 37 | private void ApplyNameRule() 38 | { 39 | RuleFor(x => x.Name).NotEmpty().WithMessage("invalid name"); 40 | } 41 | 42 | private void ApplySpecificationAttributeIdRule() 43 | { 44 | RuleFor(x => x.SpecificationAttributeId).GreaterThan(0).WithMessage("invalid specification attribute id"); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Nop.Plugin.Api/Views/Clients/Create.cshtml: -------------------------------------------------------------------------------- 1 | @model ClientApiModel 2 | 3 | @{ 4 | Layout = ViewNames.AdminLayout; 5 | 6 | //page title 7 | ViewBag.Title = T("Plugins.Api.Admin.Page.Clients.Create.Title").Text; 8 | //active menu item (system name) 9 | Html.SetActiveMenuItemSystemName("Api-Clients-Menu"); 10 | } 11 | 12 |
13 | @Html.AntiForgeryToken() 14 | 15 |
16 |

17 | @T("Plugins.Api.Admin.Page.Clients.Create.Title") 18 | @Html.ActionLink(T("Plugins.Api.Admin.Client.BackToList").Text, "List") 19 |

20 |
21 | 25 | 29 |
30 |
31 | 32 | @await Html.PartialAsync(ViewNames.AdminApiClientsCreateOrUpdate, Model) 33 |
-------------------------------------------------------------------------------- /Nop.Plugin.Api/Views/Clients/CreateOrUpdate.cshtml: -------------------------------------------------------------------------------- 1 | @model ClientApiModel 2 | 3 |
4 |
5 | @await Html.PartialAsync(ViewNames.AdminApiClientsSettings, Model) 6 |
7 |
8 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/Views/Clients/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @model ClientApiModel 2 | 3 | @{ 4 | Layout = ViewNames.AdminLayout; 5 | 6 | //page title 7 | ViewBag.Title = T("Plugins.Api.Admin.Page.Clients.Edit.Title").Text; 8 | //active menu item (system name) 9 | Html.SetActiveMenuItemSystemName("Api-Clients-Menu"); 10 | } 11 | 12 |
13 | @Html.HiddenFor(model => model.Id) 14 | @Html.AntiForgeryToken() 15 | 16 |
17 |

18 | @T("Plugins.Api.Admin.Page.Clients.Edit.Title") - @Model.ClientName 19 | @Html.ActionLink(T("Plugins.Api.Admin.Client.BackToList").Text, "List") 20 |

21 |
22 | 26 | 30 | 31 | 32 | @T("Admin.Common.Delete") 33 | 34 |
35 |
36 | 37 | @await Html.PartialAsync(ViewNames.AdminApiClientsCreateOrUpdate, Model) 38 | 39 |
40 | 41 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @inherits Nop.Web.Framework.Mvc.Razor.NopRazorPage 2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 3 | @addTagHelper *, Nop.Web.Framework 4 | 5 | @using Nop.Plugin.Api.Constants 6 | @using Nop.Web.Framework.UI 7 | @using Nop.Plugin.Api.Models; 8 | @using IdentityServer4.Models; -------------------------------------------------------------------------------- /Nop.Plugin.Api/WebHooks/ApiWebHookSender.cs: -------------------------------------------------------------------------------- 1 | //using System.Collections.Generic; 2 | //using Newtonsoft.Json.Linq; 3 | 4 | //namespace Nop.Plugin.Api.WebHooks 5 | //{ 6 | // using Microsoft.AspNet.WebHooks; 7 | // using Microsoft.AspNet.WebHooks.Diagnostics; 8 | 9 | // public class ApiWebHookSender : DataflowWebHookSender 10 | // { 11 | // private const string WebHookIdKey = "WebHookId"; 12 | 13 | // public ApiWebHookSender(ILogger logger) : base(logger) 14 | // { 15 | // } 16 | 17 | // /// 18 | // protected override JObject CreateWebHookRequestBody(WebHookWorkItem workItem) 19 | // { 20 | // JObject data = base.CreateWebHookRequestBody(workItem); 21 | 22 | // Dictionary body = data.ToObject>(); 23 | 24 | // // The web hook id is added to the web hook body. 25 | // // This is required in order to properly validate the web hook. 26 | // // When a web hook is created, it is created with a Secred field. 27 | // // The web hook id and the secret can be stored in the client's database, so that when a web hook is received 28 | // // it can be validated with the secret in the database. 29 | // // This ensures that the web hook is send from the proper location and that it's content were not tampered with. 30 | // body[WebHookIdKey] = workItem.WebHook.Id; 31 | 32 | // return JObject.FromObject(body); 33 | // } 34 | // } 35 | //} 36 | -------------------------------------------------------------------------------- /Nop.Plugin.Api/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevenSpikes/api-plugin-for-nopcommerce/aeb7c073f4c4016eaab23b116dd76c718b5e1bb5/Nop.Plugin.Api/logo.jpg -------------------------------------------------------------------------------- /Nop.Plugin.Api/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "Group": "Api", 3 | "FriendlyName": "Api plugin", 4 | "SystemName": "Nop.Plugin.Api", 5 | "Version": "4.2.0", 6 | "SupportedVersions": [ "4.20" ], 7 | "Author": "Nop-Templates team", 8 | "DisplayOrder": -1, 9 | "FileName": "Nop.Plugin.Api.dll", 10 | "Description": "This plugin is Restfull API for nopCommerce" 11 | } -------------------------------------------------------------------------------- /OrderItems.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Orders.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ProductCategoryMappings.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # API plugin for nopCommerce 2 | 3 | This plugin provides a RESTful API for managing resources in nopCommerce. 4 | 5 | ## What is a RESTful API? 6 | 7 | 8 | HTTP requests are often the way that you interact with a RESTful API. 9 | A client makes an HTTP request to a server and the server responds with an HTTP response. 10 | 11 | In a HTTP request, you need to define the type of action that you want to perform against a resource. There are four primary actions associated with any HTTP request (commonly referred to as CRUD): 12 | 13 | **POST** (Create) 14 | 15 | **GET** (Retrieve) 16 | 17 | **PUT** (Update) 18 | 19 | **DELETE** (Delete) 20 | 21 | A resource is a data object that can be accessed via an HTTP request. The API allows you to “access your nopCommerce site’s data (resources) through an easy-to-use HTTP REST API”. In the case of the most recent version of the API (nopCommerce version 3.80), the resources include the following 7 nopCommerce objects: 22 | 23 | [**Customers**](Customers.md) 24 | 25 | [**Products**](Products.md) 26 | 27 | [**Categories**](Categories.md) 28 | 29 | [**ProductCategoryMappings**](ProductCategoryMappings.md) 30 | 31 | [**Orders**](Orders.md) 32 | 33 | [**OrderItems**](OrderItems.md) 34 | 35 | [**ShoppingCartItems**](ShoppingCartItems.md) 36 | 37 | With the nopCommerce API, you can perform any of the four CRUD actions against any of your nopCommerce site’s resources listed above. For example, you can use the API to create a product, retrieve a product, update a product or delete a product associated with your nopCommerce website. 38 | 39 | ## What about security? 40 | 41 | The API plugin currently supports OAuth 2.0 Authorization Code grant type flow. So in order to access the resource endpoints you need to provide a valid AccessToken. To understand how the authorization code grant flow works please refer to the [**Sample Application**](https://github.com/SevenSpikes/nopCommerce-Api-SampleApplication). 42 | -------------------------------------------------------------------------------- /ShoppingCartItems.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /uploadedItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Type": "Plugin", 4 | "SupportedVersion": "4.00", 5 | "DirectoryPath": "Nop.Plugin.Api", 6 | "SystemName": "Nop.Plugin.Api" 7 | } 8 | ] --------------------------------------------------------------------------------