You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fineract.apache.org by Ippezrobert <gi...@git.apache.org> on 2017/02/16 07:49:29 UTC

[GitHub] incubator-fineract pull request #288: Email campaign Feature

GitHub user Ippezrobert opened a pull request:

    https://github.com/apache/incubator-fineract/pull/288

    Email campaign Feature

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/Ippezrobert/incubator-fineract email_campaign

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-fineract/pull/288.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #288
    
----
commit 1b5e0ec7c615cc9116345c178dc7ae40fc6292c0
Author: Ippez Robert <ip...@gmail.com>
Date:   2016-11-12T05:56:11Z

    API for Email Campaign feature implementation

commit dcb53344219865736c74eb49867595dc0f1be3c4
Author: Ippez Robert <ip...@gmail.com>
Date:   2017-02-16T07:40:04Z

    API for Email Campaign feature implementation

----


---
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.
---

[GitHub] incubator-fineract pull request #288: Email campaign Feature

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/288#discussion_r104357966
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/email/api/EmailApiResource.java ---
    @@ -0,0 +1,189 @@
    +/**
    + * 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.core.service.SearchParameters;
    +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("/email")
    +@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 retrieveAllCampaigns(@Context final UriInfo uriInfo) {
    --- End diff --
    
    This method should be renamed to retrieveAllEmails?


---
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.
---

[GitHub] incubator-fineract pull request #288: Email campaign Feature

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/288#discussion_r104363617
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/email/data/EmailCampaignValidator.java ---
    @@ -0,0 +1,256 @@
    +/**
    + * 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.data;
    +
    +import com.google.gson.JsonElement;
    +import com.google.gson.reflect.TypeToken;
    +import org.apache.commons.lang.StringUtils;
    +import org.joda.time.LocalDate;
    +import org.apache.fineract.infrastructure.core.data.ApiParameterError;
    +import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
    +import org.apache.fineract.infrastructure.core.exception.InvalidJsonException;
    +import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
    +import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
    +import org.apache.fineract.infrastructure.campaigns.email.domain.EmailCampaignType;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Component;
    +
    +import java.lang.reflect.Type;
    +import java.util.*;
    +
    +@Component
    +public class EmailCampaignValidator {
    +
    +   
    +
    +    public static final String RESOURCE_NAME = "email";
    +    public static final String campaignName  = "campaignName";
    +    public static final String campaignType = "campaignType";
    +    public static final String businessRuleId = "businessRuleId";
    +    public static final String stretchyReportId = "stretchyReportId";
    +    public static final String stretchyReportParamMap = "stretchyReportParamMap";
    +    public static final String paramValue = "paramValue";
    +    public static final String emailSubject = "emailSubject";
    +    public static final String emailMessage   = "emailMessage";
    +    public static final String emailAttachmentFileFormatId = "emailAttachmentFileFormatId";
    +    public static final String activationDateParamName = "activationDate";
    +    public static final String recurrenceStartDate = "recurrenceStartDate";
    +    public static final String submittedOnDateParamName = "submittedOnDate";
    +    public static final String closureDateParamName = "closureDate";
    +    public static final String recurrenceParamName = "recurrence";
    +    public static final String statusParamName = "status";
    +
    +    public static final String localeParamName = "locale";
    +    public static final String dateFormatParamName = "dateFormat";
    +
    +
    +    private final FromJsonHelper fromApiJsonHelper;
    +
    +
    +    public static final Set<String> supportedParams = new HashSet<String>(Arrays.asList(campaignName, campaignType,localeParamName,dateFormatParamName,
    +            businessRuleId,paramValue,emailMessage,recurrenceStartDate,activationDateParamName,submittedOnDateParamName,closureDateParamName,recurrenceParamName,
    +            emailSubject,stretchyReportId,stretchyReportParamMap,emailAttachmentFileFormatId));
    +
    +    public static final Set<String> supportedParamsForUpdate = new HashSet<>(Arrays.asList(campaignName, campaignType,localeParamName,dateFormatParamName,
    +            businessRuleId,paramValue,emailMessage,recurrenceStartDate,activationDateParamName,recurrenceParamName));
    +
    +    public static final Set<String> ACTIVATION_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(localeParamName,
    +            dateFormatParamName, activationDateParamName));
    +
    +    public static final Set<String> CLOSE_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(localeParamName,
    +            dateFormatParamName, closureDateParamName));
    +
    +    public static final Set<String> PREVIEW_REQUEST_DATA_PARAMETERS= new HashSet<String>(Arrays.asList(paramValue,emailMessage));
    +
    +    @Autowired
    +    public EmailCampaignValidator(FromJsonHelper fromApiJsonHelper) {
    +        this.fromApiJsonHelper = fromApiJsonHelper;
    +    }
    +
    +
    +    public void validateCreate(String json){
    +        if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
    +
    +        final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
    +        this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, EmailCampaignValidator.supportedParams);
    +        
    +        final JsonElement element = this.fromApiJsonHelper.parse(json);
    +
    +        final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
    +
    +        final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
    +                .resource(EmailCampaignValidator.RESOURCE_NAME);
    +        
    +        final String campaignName =  this.fromApiJsonHelper.extractStringNamed(EmailCampaignValidator.campaignName,element);
    +        baseDataValidator.reset().parameter(EmailCampaignValidator.campaignName).value(campaignName).notBlank().notExceedingLengthOf(100);
    +        
    +        
    +        final Long campaignType = this.fromApiJsonHelper.extractLongNamed(EmailCampaignValidator.campaignType,element);
    +        baseDataValidator.reset().parameter(EmailCampaignValidator.campaignType).value(campaignType).notNull().integerGreaterThanZero();
    +
    +        if(campaignType.intValue() == EmailCampaignType.SCHEDULE.getValue()){
    +            final String recurrenceParamName =  this.fromApiJsonHelper.extractStringNamed(EmailCampaignValidator.recurrenceParamName, element);
    +            baseDataValidator.reset().parameter(EmailCampaignValidator.recurrenceParamName).value(recurrenceParamName).notBlank();
    +
    +            final String recurrenceStartDate =  this.fromApiJsonHelper.extractStringNamed(EmailCampaignValidator.recurrenceStartDate, element);
    +            baseDataValidator.reset().parameter(EmailCampaignValidator.recurrenceStartDate).value(recurrenceStartDate).notBlank();
    +        }
    +
    +        final Long businessRuleId = this.fromApiJsonHelper.extractLongNamed(EmailCampaignValidator.businessRuleId,element);
    +        baseDataValidator.reset().parameter(EmailCampaignValidator.businessRuleId).value(businessRuleId).notNull().integerGreaterThanZero();
    +
    +        final String emailMessage = this.fromApiJsonHelper.extractStringNamed(EmailCampaignValidator.emailMessage, element);
    --- End diff --
    
    Email Subject Line is not considered? 


---
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.
---

[GitHub] incubator-fineract pull request #288: Email campaign Feature

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/288#discussion_r104358201
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/email/api/EmailApiResource.java ---
    @@ -0,0 +1,189 @@
    +/**
    + * 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.core.service.SearchParameters;
    +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("/email")
    +@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 retrieveAllCampaigns(@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) {
    --- End diff --
    
    This method should implement by using paginator? 


---
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.
---

[GitHub] incubator-fineract pull request #288: Email campaign Feature

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/288#discussion_r104358630
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/email/api/EmailApiResource.java ---
    @@ -0,0 +1,189 @@
    +/**
    + * 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.core.service.SearchParameters;
    +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("/email")
    +@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 retrieveAllCampaigns(@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 --
    
    This method should be implemented with paginator?


---
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.
---

[GitHub] incubator-fineract pull request #288: Email campaign Feature

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/288#discussion_r104357452
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java ---
    @@ -2868,4 +2868,82 @@ public CommandWrapperBuilder deleteSmsCampaign(final Long resourceId) {
             this.href = "/smscampaigns/"+resourceId;
             return this;
         }
    +	
    +    public CommandWrapperBuilder createEmail() {
    +        this.actionName = "CREATE";
    +        this.entityName = "EMAIL";
    +        this.entityId = null;
    +        this.href = "/emailcampaigns/template";
    +        return this;
    +    }
    +
    +    public CommandWrapperBuilder updateEmail(final Long resourceId) {
    +        this.actionName = "UPDATE";
    +        this.entityName = "EMAIL";
    +        this.entityId = resourceId;
    +        this.href = "/emailcampaigns/" + resourceId;
    +        return this;
    +    }
    +
    +    public CommandWrapperBuilder deleteEmail(final Long resourceId) {
    +        this.actionName = "DELETE";
    +        this.entityName = "EMAIL";
    +        this.entityId = resourceId;
    +        this.href = "/emailcampaigns/" + resourceId;
    --- End diff --
    
    deleteEmail has href as "/emailcampaigns/" + resourceId is this corrrect?


---
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.
---

[GitHub] incubator-fineract pull request #288: Email campaign Feature

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/288#discussion_r104358228
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/email/api/EmailApiResource.java ---
    @@ -0,0 +1,189 @@
    +/**
    + * 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.core.service.SearchParameters;
    +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("/email")
    +@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 retrieveAllCampaigns(@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) {
    --- End diff --
    
    This method should be implemented by paginator? 


---
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.
---

[GitHub] incubator-fineract pull request #288: Email campaign Feature

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/288#discussion_r104357303
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java ---
    @@ -2868,4 +2868,82 @@ public CommandWrapperBuilder deleteSmsCampaign(final Long resourceId) {
             this.href = "/smscampaigns/"+resourceId;
             return this;
         }
    +	
    +    public CommandWrapperBuilder createEmail() {
    +        this.actionName = "CREATE";
    +        this.entityName = "EMAIL";
    +        this.entityId = null;
    +        this.href = "/emailcampaigns/template";
    --- End diff --
    
    createEmail have href as 'emailcampaigns/template' is this correct?


---
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.
---

[GitHub] incubator-fineract pull request #288: Email campaign Feature

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/288#discussion_r104359356
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/email/api/EmailCampaignApiResource.java ---
    @@ -0,0 +1,230 @@
    +/**
    + * 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 com.google.gson.JsonElement;
    +import org.apache.commons.lang.StringUtils;
    +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.api.JsonQuery;
    +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.serialization.FromJsonHelper;
    +import org.apache.fineract.infrastructure.core.service.Page;
    +import org.apache.fineract.infrastructure.core.service.SearchParameters;
    +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
    +import org.apache.fineract.infrastructure.campaigns.email.data.PreviewCampaignMessage;
    +import org.apache.fineract.infrastructure.campaigns.email.data.EmailBusinessRulesData;
    +import org.apache.fineract.infrastructure.campaigns.email.data.EmailCampaignData;
    +import org.apache.fineract.infrastructure.campaigns.email.service.EmailCampaignReadPlatformService;
    +import org.apache.fineract.infrastructure.campaigns.email.service.EmailCampaignWritePlatformService;
    +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.HashSet;
    +
    +/**
    + * Created with IntelliJ IDEA.
    + * User: andrew
    + * Date: 19-5-14
    + * Time: 15:17
    + * To change this template use File | Settings | File Templates.
    + */
    +@Path("/email/campaign")
    +@Consumes({ MediaType.APPLICATION_JSON })
    +@Produces({ MediaType.APPLICATION_JSON })
    +@Component
    +@Scope("singleton")
    +public class EmailCampaignApiResource {
    +
    +
    +    //change name to email campaign
    +    private final String resourceNameForPermissions = "EMAIL_CAMPAIGN";
    +
    +    private final PlatformSecurityContext context;
    +
    +    private final DefaultToApiJsonSerializer<EmailBusinessRulesData> toApiJsonSerializer;
    +
    +    private final ApiRequestParameterHelper apiRequestParameterHelper;
    +
    +    private final EmailCampaignReadPlatformService emailCampaignReadPlatformService;
    +    private final FromJsonHelper fromJsonHelper;
    +
    +
    +    private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
    +    private final DefaultToApiJsonSerializer<EmailCampaignData> emailCampaignDataDefaultToApiJsonSerializer;
    +    private final EmailCampaignWritePlatformService emailCampaignWritePlatformService;
    +
    +    private final DefaultToApiJsonSerializer<PreviewCampaignMessage> previewCampaignMessageDefaultToApiJsonSerializer;
    +
    +
    +    @Autowired
    +    public EmailCampaignApiResource(final PlatformSecurityContext context,final DefaultToApiJsonSerializer<EmailBusinessRulesData> toApiJsonSerializer, final ApiRequestParameterHelper apiRequestParameterHelper,
    +                                  final EmailCampaignReadPlatformService emailCampaignReadPlatformService, final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
    +                                  final DefaultToApiJsonSerializer<EmailCampaignData> emailCampaignDataDefaultToApiJsonSerializer,
    +                                  final FromJsonHelper fromJsonHelper, final EmailCampaignWritePlatformService emailCampaignWritePlatformService,
    +                                  final DefaultToApiJsonSerializer<PreviewCampaignMessage> previewCampaignMessageDefaultToApiJsonSerializer) {
    +        this.context = context;
    +        this.toApiJsonSerializer = toApiJsonSerializer;
    +        this.apiRequestParameterHelper = apiRequestParameterHelper;
    +        this.emailCampaignReadPlatformService = emailCampaignReadPlatformService;
    +        this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
    +        this.emailCampaignDataDefaultToApiJsonSerializer = emailCampaignDataDefaultToApiJsonSerializer;
    +        this.fromJsonHelper = fromJsonHelper;
    +        this.emailCampaignWritePlatformService = emailCampaignWritePlatformService;
    +        this.previewCampaignMessageDefaultToApiJsonSerializer = previewCampaignMessageDefaultToApiJsonSerializer;
    +    }
    +
    +
    +    @GET
    +    @Path("{resourceId}")
    +    @Produces({ MediaType.APPLICATION_JSON })
    +    public String retrieveOneCampaign(@PathParam("resourceId") final Long resourceId,@Context final UriInfo uriInfo){
    +        this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
    +
    +        EmailCampaignData emailCampaignData = this.emailCampaignReadPlatformService.retrieveOne(resourceId);
    +        final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
    +        return this.emailCampaignDataDefaultToApiJsonSerializer.serialize(settings,emailCampaignData);
    +
    +    }
    +
    +    @GET
    +    @Produces({ MediaType.APPLICATION_JSON })
    +    public String retrieveAllCampaign(@Context final UriInfo uriInfo) {
    +
    +        this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
    +
    +        final Collection<EmailCampaignData> emailCampaignDataCollection = this.emailCampaignReadPlatformService.retrieveAllCampaign();
    +
    +        final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
    +        return this.emailCampaignDataDefaultToApiJsonSerializer.serialize(settings,emailCampaignDataCollection);
    +    }
    +
    +    @POST
    +    @Consumes({ MediaType.APPLICATION_JSON })
    +    @Produces({ MediaType.APPLICATION_JSON })
    +    public String createCampaign(final String apiRequestBodyAsJson,@Context final UriInfo uriInfo){
    +
    +        final CommandWrapper commandRequest = new CommandWrapperBuilder().createEmailCampaign().withJson(apiRequestBodyAsJson).build();
    +
    +        final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    +
    +        return this.toApiJsonSerializer.serialize(result);
    +    }
    +
    +    @PUT
    +    @Path("{resourceId}")
    +    @Consumes({ MediaType.APPLICATION_JSON })
    +    @Produces({ MediaType.APPLICATION_JSON })
    +    public String updateCampaign(@PathParam("resourceId") final Long campaignId,final String apiRequestBodyAsJson,@Context final UriInfo uriInfo){
    +
    +        final CommandWrapper commandRequest = new CommandWrapperBuilder().updateEmailCampaign(campaignId).withJson(apiRequestBodyAsJson).build();
    +
    +        final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    +
    +        return this.toApiJsonSerializer.serialize(result);
    +    }
    +
    +    @POST
    +    @Path("{resourceId}")
    +    @Consumes({ MediaType.APPLICATION_JSON })
    +    @Produces({ MediaType.APPLICATION_JSON })
    +    public String activate(@PathParam("resourceId") final Long campaignId, @QueryParam("command") final String commandParam,
    +                           final String apiRequestBodyAsJson){
    +        final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson);
    +
    +        CommandProcessingResult result = null;
    +        CommandWrapper commandRequest = null;
    +        if (is(commandParam, "activate")) {
    +            commandRequest = builder.activateEmailCampaign(campaignId).build();
    +            result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    +        }else if (is(commandParam, "close")){
    +            commandRequest = builder.closeEmailCampaign(campaignId).build();
    +            result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    +        }else if (is(commandParam,"reactivate")){
    +            commandRequest = builder.reactivateEmailCampaign(campaignId).build();
    +            result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    +        }
    +        return this.toApiJsonSerializer.serialize(result);
    --- End diff --
    
    There is a chance of null pointer if command passed is not in listed. 


---
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.
---

[GitHub] incubator-fineract pull request #288: Email campaign Feature

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/288#discussion_r104358508
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/email/api/EmailApiResource.java ---
    @@ -0,0 +1,189 @@
    +/**
    + * 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.core.service.SearchParameters;
    +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("/email")
    +@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 retrieveAllCampaigns(@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,
    --- End diff --
    
    I believe offset also required to work pagination properly


---
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.
---

[GitHub] incubator-fineract pull request #288: Email campaign Feature

Posted by Ippezrobert <gi...@git.apache.org>.
Github user Ippezrobert closed the pull request at:

    https://github.com/apache/incubator-fineract/pull/288


---
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.
---

[GitHub] incubator-fineract pull request #288: Email campaign Feature

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/288#discussion_r104357368
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java ---
    @@ -2868,4 +2868,82 @@ public CommandWrapperBuilder deleteSmsCampaign(final Long resourceId) {
             this.href = "/smscampaigns/"+resourceId;
             return this;
         }
    +	
    +    public CommandWrapperBuilder createEmail() {
    +        this.actionName = "CREATE";
    +        this.entityName = "EMAIL";
    +        this.entityId = null;
    +        this.href = "/emailcampaigns/template";
    +        return this;
    +    }
    +
    +    public CommandWrapperBuilder updateEmail(final Long resourceId) {
    +        this.actionName = "UPDATE";
    +        this.entityName = "EMAIL";
    +        this.entityId = resourceId;
    +        this.href = "/emailcampaigns/" + resourceId;
    --- End diff --
    
    updateEmail have href as '/emailcampaigns/ + resourceId' is this correct?


---
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.
---