Search in sources :

Example 1 with CommandWrapperBuilder

use of org.apache.fineract.commands.service.CommandWrapperBuilder in project fineract by apache.

the class ThitsaWorksCreditBureauIntegrationWritePlatformServiceImpl method createToken.

@Transactional
@Override
public CreditBureauToken createToken(Long bureauID) {
    CreditBureauToken creditBureauToken = this.tokenRepositoryWrapper.getToken();
    // check the expiry date of the previous token.
    if (creditBureauToken != null) {
        Date current = new Date();
        Date getExpiryDate = creditBureauToken.getTokenExpiryDate();
        if (getExpiryDate.before(current)) {
            this.tokenRepositoryWrapper.delete(creditBureauToken);
            creditBureauToken = null;
        }
    }
    if (creditBureauToken != null) {
        creditBureauToken = this.tokenRepositoryWrapper.getToken();
    }
    String userName = getCreditBureauConfiguration(bureauID.intValue(), CreditBureauConfigurations.USERNAME.toString());
    String password = getCreditBureauConfiguration(bureauID.intValue(), CreditBureauConfigurations.PASSWORD.toString());
    String subscriptionId = getCreditBureauConfiguration(bureauID.intValue(), CreditBureauConfigurations.SUBSCRIPTIONID.toString());
    String subscriptionKey = getCreditBureauConfiguration(bureauID.intValue(), CreditBureauConfigurations.SUBSCRIPTIONKEY.toString());
    if (creditBureauToken == null) {
        String url = getCreditBureauConfiguration(bureauID.intValue(), CreditBureauConfigurations.TOKENURL.toString());
        String process = "token";
        String nrcId = null;
        Long uniqueID = 0L;
        String result = this.okHttpConnectionMethod(userName, password, subscriptionKey, subscriptionId, url, null, null, null, uniqueID, nrcId, process);
        // created token will be storing it into database
        final CommandWrapper wrapper = new CommandWrapperBuilder().withJson(result).build();
        final String json = wrapper.getJson();
        JsonCommand apicommand = null;
        final JsonElement parsedCommand = this.fromApiJsonHelper.parse(json);
        apicommand = JsonCommand.from(json, parsedCommand, this.fromApiJsonHelper, wrapper.getEntityName(), wrapper.getEntityId(), wrapper.getSubentityId(), wrapper.getGroupId(), wrapper.getClientId(), wrapper.getLoanId(), wrapper.getSavingsId(), wrapper.getTransactionId(), wrapper.getHref(), wrapper.getProductId(), wrapper.getCreditBureauId(), wrapper.getOrganisationCreditBureauId());
        this.fromApiJsonDeserializer.validateForCreate(apicommand.json());
        final CreditBureauToken generatedtoken = CreditBureauToken.fromJson(apicommand);
        final CreditBureauToken credittoken = this.tokenRepositoryWrapper.getToken();
        if (credittoken != null) {
            this.tokenRepositoryWrapper.delete(credittoken);
        }
        this.tokenRepositoryWrapper.save(generatedtoken);
        creditBureauToken = this.tokenRepositoryWrapper.getToken();
    }
    return creditBureauToken;
}
Also used : CommandWrapperBuilder(org.apache.fineract.commands.service.CommandWrapperBuilder) JsonCommand(org.apache.fineract.infrastructure.core.api.JsonCommand) JsonElement(com.google.gson.JsonElement) CommandWrapper(org.apache.fineract.commands.domain.CommandWrapper) CreditBureauToken(org.apache.fineract.infrastructure.creditbureau.domain.CreditBureauToken) Date(java.util.Date) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with CommandWrapperBuilder

use of org.apache.fineract.commands.service.CommandWrapperBuilder in project fineract by apache.

the class SmsCampaignApiResource method delete.

@DELETE
@Path("{campaignId}")
@Operation(summary = "Delete a SMS Campaign", description = "Note: Only closed SMS Campaigns can be deleted")
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CommandProcessingResult.class)))
public String delete(@PathParam("campaignId") final Long campaignId) {
    final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteSmsCampaign(campaignId).build();
    final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    return this.toApiJsonSerializer.serialize(result);
}
Also used : CommandWrapperBuilder(org.apache.fineract.commands.service.CommandWrapperBuilder) CommandWrapper(org.apache.fineract.commands.domain.CommandWrapper) CommandProcessingResult(org.apache.fineract.infrastructure.core.data.CommandProcessingResult) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse)

Example 3 with CommandWrapperBuilder

use of org.apache.fineract.commands.service.CommandWrapperBuilder in project fineract by apache.

the class SmsCampaignApiResource method createCampaign.

@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Create a SMS Campaign", description = "Mandatory Fields\n" + "campaignName, campaignType, triggerType, providerId, runReportId, message\n" + "\n" + "Mandatory Fields for Cash based on selected report id\n" + "paramValue in json format")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = CommandWrapper.class)))
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CommandProcessingResult.class)))
public String createCampaign(@Parameter(hidden = true) final String apiRequestBodyAsJson) {
    this.platformSecurityContext.authenticatedUser();
    final CommandWrapper commandRequest = new CommandWrapperBuilder().createSmsCampaign().withJson(apiRequestBodyAsJson).build();
    final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    return this.toApiJsonSerializer.serialize(result);
}
Also used : CommandWrapperBuilder(org.apache.fineract.commands.service.CommandWrapperBuilder) CommandWrapper(org.apache.fineract.commands.domain.CommandWrapper) CommandProcessingResult(org.apache.fineract.infrastructure.core.data.CommandProcessingResult) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse) RequestBody(io.swagger.v3.oas.annotations.parameters.RequestBody)

Example 4 with CommandWrapperBuilder

use of org.apache.fineract.commands.service.CommandWrapperBuilder in project fineract by apache.

the class SmsCampaignApiResource method handleCommands.

@POST
@Path("{campaignId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "SMS Campaign", description = "Activates | Deactivates | Reactivates")
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CommandProcessingResult.class)))
public String handleCommands(@PathParam("campaignId") final Long campaignId, @QueryParam("command") final String commandParam, @Parameter(hidden = true) final String apiRequestBodyAsJson) {
    final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson);
    CommandProcessingResult result = null;
    CommandWrapper commandRequest = null;
    if (is(commandParam, "activate")) {
        commandRequest = builder.activateSmsCampaign(campaignId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "close")) {
        commandRequest = builder.closeSmsCampaign(campaignId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "reactivate")) {
        commandRequest = builder.reactivateSmsCampaign(campaignId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    }
    return this.toApiJsonSerializer.serialize(result);
}
Also used : CommandWrapperBuilder(org.apache.fineract.commands.service.CommandWrapperBuilder) CommandProcessingResult(org.apache.fineract.infrastructure.core.data.CommandProcessingResult) CommandWrapper(org.apache.fineract.commands.domain.CommandWrapper) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse)

Example 5 with CommandWrapperBuilder

use of org.apache.fineract.commands.service.CommandWrapperBuilder in project fineract by apache.

the class CreditBureauConfigurationAPI method createCreditBureauLoanProductMapping.

@POST
@Path("/mappings/{organisationCreditBureauId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String createCreditBureauLoanProductMapping(@PathParam("organisationCreditBureauId") final Long organisationCreditBureauId, final String apiRequestBodyAsJson) {
    final CommandWrapper commandRequest = new CommandWrapperBuilder().createCreditBureauLoanProductMapping(organisationCreditBureauId).withJson(apiRequestBodyAsJson).build();
    final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    return this.toApiJsonSerializer.serialize(result);
}
Also used : CommandWrapperBuilder(org.apache.fineract.commands.service.CommandWrapperBuilder) CommandWrapper(org.apache.fineract.commands.domain.CommandWrapper) CommandProcessingResult(org.apache.fineract.infrastructure.core.data.CommandProcessingResult) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Aggregations

CommandWrapperBuilder (org.apache.fineract.commands.service.CommandWrapperBuilder)309 CommandWrapper (org.apache.fineract.commands.domain.CommandWrapper)307 CommandProcessingResult (org.apache.fineract.infrastructure.core.data.CommandProcessingResult)299 Produces (javax.ws.rs.Produces)253 Consumes (javax.ws.rs.Consumes)251 Operation (io.swagger.v3.oas.annotations.Operation)199 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)193 Path (javax.ws.rs.Path)184 RequestBody (io.swagger.v3.oas.annotations.parameters.RequestBody)152 POST (javax.ws.rs.POST)121 PUT (javax.ws.rs.PUT)89 DELETE (javax.ws.rs.DELETE)61 GsonBuilder (com.google.gson.GsonBuilder)31 DateSerializer (org.apache.fineract.infrastructure.bulkimport.importhandler.helper.DateSerializer)30 UnrecognizedQueryParamException (org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException)28 Cell (org.apache.poi.ss.usermodel.Cell)13 Sheet (org.apache.poi.ss.usermodel.Sheet)13 JsonObject (com.google.gson.JsonObject)11 JsonElement (com.google.gson.JsonElement)10 ApiRequestJsonSerializationSettings (org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings)7