Search in sources :

Example 1 with IntegrationModuleSummaryEntity

use of com.salesmanager.shop.model.system.IntegrationModuleSummaryEntity in project shopizer by shopizer-ecommerce.

the class ShippingConfigurationApi method integrationModule.

private IntegrationModuleSummaryEntity integrationModule(IntegrationModule module, Map<String, IntegrationConfiguration> configuredModules) {
    IntegrationModuleSummaryEntity readable = null;
    readable = new IntegrationModuleSummaryEntity();
    readable.setCode(module.getCode());
    readable.setImage(module.getImage());
    if (configuredModules.containsKey(module.getCode())) {
        IntegrationConfiguration conf = configuredModules.get(module.getCode());
        readable.setConfigured(true);
        if (conf.isActive()) {
            readable.setActive(true);
        }
    }
    return readable;
}
Also used : IntegrationModuleSummaryEntity(com.salesmanager.shop.model.system.IntegrationModuleSummaryEntity) IntegrationConfiguration(com.salesmanager.core.model.system.IntegrationConfiguration)

Example 2 with IntegrationModuleSummaryEntity

use of com.salesmanager.shop.model.system.IntegrationModuleSummaryEntity in project shopizer by shopizer-ecommerce.

the class ShippingConfigurationApi method shippingModules.

/**
 * Get available shipping modules
 *
 * @param merchantStore
 * @param language
 * @return
 */
@GetMapping("/private/modules/shipping")
@ApiOperation(httpMethod = "GET", value = "List list of shipping modules", notes = "Requires administration access", produces = "application/json", response = List.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "string", defaultValue = "DEFAULT") })
public List<IntegrationModuleSummaryEntity> shippingModules(@ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
    try {
        List<IntegrationModule> modules = shippingService.getShippingMethods(merchantStore);
        // configured modules
        Map<String, IntegrationConfiguration> configuredModules = shippingService.getShippingModulesConfigured(merchantStore);
        return modules.stream().map(m -> integrationModule(m, configuredModules)).collect(Collectors.toList());
    } catch (ServiceException e) {
        LOGGER.error("Error getting shipping modules", e);
        throw new ServiceRuntimeException("Error getting shipping modules", e);
    }
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) IntegrationModuleConfiguration(com.salesmanager.shop.model.system.IntegrationModuleConfiguration) ShippingFacade(com.salesmanager.shop.store.controller.shipping.facade.ShippingFacade) Constants(com.salesmanager.shop.constants.Constants) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ServiceException(com.salesmanager.core.business.exception.ServiceException) RequestBody(org.springframework.web.bind.annotation.RequestBody) Language(com.salesmanager.core.model.reference.language.Language) ApiOperation(io.swagger.annotations.ApiOperation) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) AuthorizationUtils(com.salesmanager.shop.utils.AuthorizationUtils) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) Map(java.util.Map) GetMapping(org.springframework.web.bind.annotation.GetMapping) IntegrationModule(com.salesmanager.core.model.system.IntegrationModule) Api(io.swagger.annotations.Api) Tag(io.swagger.annotations.Tag) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ShippingService(com.salesmanager.core.business.services.shipping.ShippingService) PostMapping(org.springframework.web.bind.annotation.PostMapping) Logger(org.slf4j.Logger) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) IntegrationModuleSummaryEntity(com.salesmanager.shop.model.system.IntegrationModuleSummaryEntity) ApiIgnore(springfox.documentation.annotations.ApiIgnore) HttpStatus(org.springframework.http.HttpStatus) List(java.util.List) Stream(java.util.stream.Stream) PackageDetails(com.salesmanager.core.model.shipping.PackageDetails) IntegrationConfiguration(com.salesmanager.core.model.system.IntegrationConfiguration) SwaggerDefinition(io.swagger.annotations.SwaggerDefinition) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) Optional(java.util.Optional) PersistableAddress(com.salesmanager.shop.model.references.PersistableAddress) ReadableAddress(com.salesmanager.shop.model.references.ReadableAddress) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ServiceException(com.salesmanager.core.business.exception.ServiceException) IntegrationConfiguration(com.salesmanager.core.model.system.IntegrationConfiguration) IntegrationModule(com.salesmanager.core.model.system.IntegrationModule) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with IntegrationModuleSummaryEntity

use of com.salesmanager.shop.model.system.IntegrationModuleSummaryEntity in project shopizer by shopizer-ecommerce.

the class PaymentApi method integrationModule.

private IntegrationModuleSummaryEntity integrationModule(IntegrationModule module, Map<String, IntegrationConfiguration> configuredModules) {
    IntegrationModuleSummaryEntity readable = null;
    readable = new IntegrationModuleSummaryEntity();
    readable.setCode(module.getCode());
    readable.setImage(module.getImage());
    readable.setBinaryImage(module.getBinaryImage());
    // readable.setRequiredKeys(module.getConfigurables());
    readable.setConfigurable(module.getConfigurable());
    if (configuredModules.containsKey(module.getCode())) {
        readable.setConfigured(true);
        if (configuredModules.get(module.getCode()).isActive()) {
            readable.setActive(true);
        }
    }
    return readable;
}
Also used : IntegrationModuleSummaryEntity(com.salesmanager.shop.model.system.IntegrationModuleSummaryEntity)

Example 4 with IntegrationModuleSummaryEntity

use of com.salesmanager.shop.model.system.IntegrationModuleSummaryEntity in project shopizer by shopizer-ecommerce.

the class PaymentApi method paymentModules.

/**
 * Get available payment modules
 *
 * @param merchantStore
 * @param language
 * @return
 */
@GetMapping("/private/modules/payment")
@ApiOperation(httpMethod = "GET", value = "List list of payment modules", notes = "Requires administration access", produces = "application/json", response = List.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "string", defaultValue = "DEFAULT") })
public List<IntegrationModuleSummaryEntity> paymentModules(@ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
    try {
        List<IntegrationModule> modules = paymentService.getPaymentMethods(merchantStore);
        // configured modules
        Map<String, IntegrationConfiguration> configuredModules = paymentService.getPaymentModulesConfigured(merchantStore);
        return modules.stream().map(m -> integrationModule(m, configuredModules)).collect(Collectors.toList());
    } catch (ServiceException e) {
        LOGGER.error("Error getting payment modules", e);
        throw new ServiceRuntimeException("Error getting payment modules", e);
    }
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) IntegrationModuleConfiguration(com.salesmanager.shop.model.system.IntegrationModuleConfiguration) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ServiceException(com.salesmanager.core.business.exception.ServiceException) RequestBody(org.springframework.web.bind.annotation.RequestBody) Language(com.salesmanager.core.model.reference.language.Language) ApiOperation(io.swagger.annotations.ApiOperation) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) Map(java.util.Map) GetMapping(org.springframework.web.bind.annotation.GetMapping) IntegrationModule(com.salesmanager.core.model.system.IntegrationModule) Api(io.swagger.annotations.Api) Tag(io.swagger.annotations.Tag) PostMapping(org.springframework.web.bind.annotation.PostMapping) Logger(org.slf4j.Logger) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) PaymentService(com.salesmanager.core.business.services.payments.PaymentService) IntegrationModuleSummaryEntity(com.salesmanager.shop.model.system.IntegrationModuleSummaryEntity) ApiIgnore(springfox.documentation.annotations.ApiIgnore) List(java.util.List) IntegrationConfiguration(com.salesmanager.core.model.system.IntegrationConfiguration) SwaggerDefinition(io.swagger.annotations.SwaggerDefinition) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ServiceException(com.salesmanager.core.business.exception.ServiceException) IntegrationConfiguration(com.salesmanager.core.model.system.IntegrationConfiguration) IntegrationModule(com.salesmanager.core.model.system.IntegrationModule) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

IntegrationModuleSummaryEntity (com.salesmanager.shop.model.system.IntegrationModuleSummaryEntity)4 IntegrationConfiguration (com.salesmanager.core.model.system.IntegrationConfiguration)3 ServiceException (com.salesmanager.core.business.exception.ServiceException)2 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)2 Language (com.salesmanager.core.model.reference.language.Language)2 IntegrationModule (com.salesmanager.core.model.system.IntegrationModule)2 IntegrationModuleConfiguration (com.salesmanager.shop.model.system.IntegrationModuleConfiguration)2 ResourceNotFoundException (com.salesmanager.shop.store.api.exception.ResourceNotFoundException)2 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)2 Api (io.swagger.annotations.Api)2 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)2 ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)2 ApiOperation (io.swagger.annotations.ApiOperation)2 SwaggerDefinition (io.swagger.annotations.SwaggerDefinition)2 Tag (io.swagger.annotations.Tag)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2