Search in sources :

Example 26 with IntegrationConfiguration

use of com.salesmanager.core.model.system.IntegrationConfiguration in project shopizer by shopizer-ecommerce.

the class PaymentApi method paymentModule.

/**
 * Get merchant payment module details
 *
 * @param code
 * @param merchantStore
 * @param language
 * @return
 */
@GetMapping("/private/modules/payment/{code}")
@ApiOperation(httpMethod = "GET", value = "Payment module by code", produces = "application/json", response = List.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "string", defaultValue = "DEFAULT") })
public IntegrationModuleConfiguration paymentModule(@PathVariable String code, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
    try {
        // get module
        IntegrationModule integrationModule = paymentService.getPaymentMethodByCode(merchantStore, code);
        if (integrationModule == null) {
            throw new ResourceNotFoundException("Payment module [" + code + "] not found");
        }
        IntegrationModuleConfiguration returnConfig = new IntegrationModuleConfiguration();
        returnConfig.setConfigurable(integrationModule.getConfigurable());
        returnConfig.setActive(false);
        returnConfig.setDefaultSelected(false);
        returnConfig.setCode(code);
        // configured modules
        IntegrationConfiguration config = paymentService.getPaymentConfiguration(code, merchantStore);
        if (config == null) {
            return returnConfig;
        }
        /**
         * Build return object for now this is a read copy
         */
        returnConfig.setActive(config.isActive());
        returnConfig.setDefaultSelected(config.isDefaultSelected());
        returnConfig.setCode(code);
        returnConfig.setIntegrationKeys(config.getIntegrationKeys());
        returnConfig.setIntegrationOptions(config.getIntegrationOptions());
        return returnConfig;
    } catch (ServiceException e) {
        LOGGER.error("Error getting payment module [" + code + "]", e);
        throw new ServiceRuntimeException("Error getting payment module [" + code + "]", e);
    }
}
Also used : IntegrationModuleConfiguration(com.salesmanager.shop.model.system.IntegrationModuleConfiguration) ServiceException(com.salesmanager.core.business.exception.ServiceException) IntegrationConfiguration(com.salesmanager.core.model.system.IntegrationConfiguration) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) 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 27 with IntegrationConfiguration

use of com.salesmanager.core.model.system.IntegrationConfiguration 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

IntegrationConfiguration (com.salesmanager.core.model.system.IntegrationConfiguration)27 ServiceException (com.salesmanager.core.business.exception.ServiceException)20 IntegrationModule (com.salesmanager.core.model.system.IntegrationModule)16 IntegrationException (com.salesmanager.core.modules.integration.IntegrationException)10 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)9 List (java.util.List)9 Language (com.salesmanager.core.model.reference.language.Language)8 BigDecimal (java.math.BigDecimal)8 Map (java.util.Map)8 CustomIntegrationConfiguration (com.salesmanager.core.model.system.CustomIntegrationConfiguration)7 PaymentModule (com.salesmanager.core.modules.integration.payment.model.PaymentModule)7 Logger (org.slf4j.Logger)7 LoggerFactory (org.slf4j.LoggerFactory)7 PackageDetails (com.salesmanager.core.model.shipping.PackageDetails)6 MerchantConfiguration (com.salesmanager.core.model.system.MerchantConfiguration)6 IntegrationModuleConfiguration (com.salesmanager.shop.model.system.IntegrationModuleConfiguration)6 IntegrationModuleSummaryEntity (com.salesmanager.shop.model.system.IntegrationModuleSummaryEntity)6 ResourceNotFoundException (com.salesmanager.shop.store.api.exception.ResourceNotFoundException)6 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)6 ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)6