fineract-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nazeer1100126 <...@git.apache.org>
Subject [GitHub] incubator-fineract pull request #239: API for Email Campaign feature impleme...
Date Tue, 22 Nov 2016 09:08:13 GMT
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/239#discussion_r88860871
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/email/api/EmailApiResource.java
---
    @@ -0,0 +1,188 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.fineract.infrastructure.campaigns.email.api;
    +
    +import org.apache.fineract.accounting.journalentry.api.DateParam;
    +import org.apache.fineract.commands.domain.CommandWrapper;
    +import org.apache.fineract.commands.service.CommandWrapperBuilder;
    +import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
    +import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
    +import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
    +import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
    +import org.apache.fineract.infrastructure.core.service.Page;
    +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
    +import org.apache.fineract.infrastructure.campaigns.email.data.EmailConfigurationData;
    +import org.apache.fineract.infrastructure.campaigns.email.data.EmailData;
    +import org.apache.fineract.infrastructure.campaigns.email.service.EmailConfigurationReadPlatformService;
    +import org.apache.fineract.infrastructure.campaigns.email.service.EmailReadPlatformService;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.context.annotation.Scope;
    +import org.springframework.stereotype.Component;
    +
    +import javax.ws.rs.*;
    +import javax.ws.rs.core.Context;
    +import javax.ws.rs.core.MediaType;
    +import javax.ws.rs.core.UriInfo;
    +import java.util.Collection;
    +import java.util.Date;
    +import java.util.HashMap;
    +import java.util.Map;
    +
    +@Path("/emailcampaign")
    +@Consumes({ MediaType.APPLICATION_JSON })
    +@Produces({ MediaType.APPLICATION_JSON })
    +@Component
    +@Scope("singleton")
    +public class EmailApiResource {
    +
    +    private final String resourceNameForPermissions = "Email";
    +    private final PlatformSecurityContext context;
    +    private final EmailReadPlatformService readPlatformService;
    +    private final DefaultToApiJsonSerializer<EmailData> toApiJsonSerializer;
    +    private final ApiRequestParameterHelper apiRequestParameterHelper;
    +    private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
    +    private final EmailConfigurationReadPlatformService emailConfigurationReadPlatformService;
    +
    +    @Autowired
    +    public EmailApiResource(final PlatformSecurityContext context, final EmailReadPlatformService
readPlatformService,
    +            final DefaultToApiJsonSerializer<EmailData> toApiJsonSerializer, final
ApiRequestParameterHelper apiRequestParameterHelper,
    +            final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
    +            EmailConfigurationReadPlatformService emailConfigurationReadPlatformService)
{
    +        this.context = context;
    +        this.readPlatformService = readPlatformService;
    +        this.toApiJsonSerializer = toApiJsonSerializer;
    +        this.apiRequestParameterHelper = apiRequestParameterHelper;
    +        this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
    +        this.emailConfigurationReadPlatformService = emailConfigurationReadPlatformService;
    +    }
    +
    +    @GET
    +    public String retrieveAll(@Context final UriInfo uriInfo) {
    +
    +        this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
    +
    +        final Collection<EmailData> emailMessages = this.readPlatformService.retrieveAll();
    +
    +        final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
    +        return this.toApiJsonSerializer.serialize(settings, emailMessages);
    +    }
    +
    +    @GET
    +    @Path("pendingEmail")
    +    public String retrievePendingEmail(@Context final UriInfo uriInfo,@QueryParam("limit")
final Long limit) {
    +
    +        this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
    +
    +        final Collection<EmailData> emailMessages = this.readPlatformService.retrieveAllPending(limit.intValue());
    +
    +        final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
    +        return this.toApiJsonSerializer.serialize(settings, emailMessages);
    +    }
    +    
    +    @GET
    +    @Path("sentEmail")
    +    public String retrieveSentEmail(@Context final UriInfo uriInfo, @QueryParam("limit")
final Long limit) {
    +
    +        this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
    +
    +        final Collection<EmailData> emailMessages = this.readPlatformService.retrieveAllSent(limit.intValue());
    +
    +        final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
    +        return this.toApiJsonSerializer.serialize(settings, emailMessages);
    +    }
    +
    +
    +    @GET
    +    @Path("messageByStatus")
    +    public String retrieveAllEmailByStatus(@Context final UriInfo uriInfo, @QueryParam("limit")
final Long limit,@QueryParam("status") final Long status,
    +                                         @QueryParam("fromDate") final DateParam fromDateParam,
@QueryParam("toDate") final DateParam toDateParam,
    +                                         @QueryParam("locale") final String locale, @QueryParam("dateFormat")
final String dateFormat) {
    +
    +        this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
    +        Date fromDate = null;
    +        if (fromDateParam != null) {
    +            fromDate = fromDateParam.getDate("fromDate", dateFormat, locale);
    +        }
    +        Date toDate = null;
    +        if (toDateParam != null) {
    +            toDate = toDateParam.getDate("toDate", dateFormat, locale);
    +        }
    +
    +        final Page<EmailData> emailMessages = this.readPlatformService.retrieveEmailByStatus(limit.intValue(),status.intValue(),fromDate,toDate);
    +
    +        final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
    +        return this.toApiJsonSerializer.serialize(settings, emailMessages);
    +    }
    +    
    +    @GET
    +    @Path("failedEmail")
    +    public String retrieveFailedEmail(@Context final UriInfo uriInfo, @QueryParam("limit")
final Long limit) {
    --- End diff --
    
    emails by status API is sufficient. Is this API required? if yes please provide offset
and limit params for pagination


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message