Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create accounts event #107

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d8bbd14
Added create event controller, services and lib changes
Raj-Shah1 Aug 23, 2023
e611e5a
Added logs and renamed Event Controller file
Raj-Shah1 Aug 23, 2023
48d3589
Merge branch 'master' into create-accounts-event
Raj-Shah1 Sep 14, 2023
0b554d7
Added create account event api changes
Raj-Shah1 Sep 14, 2023
247fc4e
Added create account event test case
Raj-Shah1 Sep 14, 2023
cfb274e
Removed unnecessary dependency
Raj-Shah1 Sep 15, 2023
22069f4
Added get events list api changes
Raj-Shah1 Sep 15, 2023
7c8a60a
Renamed variables
Raj-Shah1 Sep 15, 2023
7431e47
Added delete note api
Raj-Shah1 Sep 15, 2023
4ae9de9
Added delete account event test
Raj-Shah1 Sep 18, 2023
ba8eb88
Merge branch 'master' into create-accounts-event
Raj-Shah1 Sep 18, 2023
3f0eda1
Merge branch 'master' into create-accounts-event
Raj-Shah1 Sep 22, 2023
e0b2112
Added changes for event suggestion
Raj-Shah1 Sep 25, 2023
6c402e6
Added update account event api
Raj-Shah1 Sep 26, 2023
107102f
Added event id invalid check for update event
Raj-Shah1 Sep 26, 2023
30fdd4e
Added update event test case
Raj-Shah1 Sep 26, 2023
434b045
Added get event details api and update task api
Raj-Shah1 Sep 28, 2023
dd09f36
Updated success status for updateEvent to 204
Raj-Shah1 Sep 28, 2023
68c043b
Updated success status for updateTask to 204
Raj-Shah1 Sep 28, 2023
1f462bf
Added update task and get task details api
Raj-Shah1 Oct 4, 2023
3a8c91b
Added update note api
Raj-Shah1 Oct 5, 2023
01c317a
Added update note test cases
Raj-Shah1 Oct 6, 2023
b7b693c
Updated security config
Raj-Shah1 Oct 9, 2023
621ff2b
Reverted back security change
Raj-Shah1 Oct 9, 2023
25dde2f
Added changelog file for 0.3.0
Raj-Shah1 Oct 9, 2023
1794d18
Updated version in pom.xml
Raj-Shah1 Oct 9, 2023
999b80b
Added html decode for note content response
Raj-Shah1 Oct 10, 2023
fd579bd
Added code test changes
Raj-Shah1 Oct 11, 2023
1504725
Updated open ai prompt
Raj-Shah1 Oct 11, 2023
b3a76a9
Added TODO for payload of opan ai
Raj-Shah1 Oct 16, 2023
53801c2
Added null check for getTrimmedString
Raj-Shah1 Oct 16, 2023
1bcc072
Changed getTrimmedString to static method
Raj-Shah1 Oct 16, 2023
a93296b
Added TODO to use Slf4j instead of logger
Raj-Shah1 Oct 16, 2023
39922f5
Renamed Files
Raj-Shah1 Oct 16, 2023
b2ccfcb
Changed util methods to static
Raj-Shah1 Oct 16, 2023
be534d0
Changed all logger to static final
Raj-Shah1 Oct 16, 2023
491cff0
Removed Owner class from SalesforceGetEventsListDto
Raj-Shah1 Oct 16, 2023
32264e6
Removed extra semicolons
Raj-Shah1 Oct 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>com.salessparrow</groupId>
<artifactId>salessparrow-api</artifactId>
<version>0.2.3</version>
<version>0.3.0</version>
<name>api</name>
<description>Salessparrow apis</description>

Expand Down
14 changes: 14 additions & 0 deletions repo-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# SalesSparrow APIs

## 0.3.0

### New Features and Enhancements:

- API - Edit Note Endpoint [#18](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/18)
- API - Get a list of Events in an account [#29](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/29)
- API - Create Event for an Account [#30](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/30)
- API - Edit Event in an Account Endpoint [#31](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/31)
- API - Delete Event in an Account Endpoint [#32](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/32)
- API - Edit Task in an Account Endpoint [#36](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/36)
- API - Get Event By Id Endpoint [#101](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/101)
- API - Get Task By Id Endpoint [#102](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/102)
- Add Event Suggestion Prompt [#103](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/103)

## 0.2.3

### Enhancements:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package com.salessparrow.api.controllers;

import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.salessparrow.api.dto.formatter.CreateEventFormatterDto;
import com.salessparrow.api.dto.formatter.GetEventDetailsFormatterDto;
import com.salessparrow.api.dto.formatter.GetEventsListFormatterDto;
import com.salessparrow.api.dto.requestMapper.CreateAccountEventDto;
import com.salessparrow.api.dto.requestMapper.UpdateAccountEventDto;
import com.salessparrow.api.services.accountEvents.CreateAccountEventService;
import com.salessparrow.api.services.accountEvents.DeleteAccountEventService;
import com.salessparrow.api.services.accountEvents.GetAccountEventDetailsService;
import com.salessparrow.api.services.accountEvents.GetAccountEventsListService;
import com.salessparrow.api.services.accountEvents.UpdateAccountEventService;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;

@RestController
@RequestMapping("/api/v1/accounts/{account_id}/events")
@Validated
Raj-Shah1 marked this conversation as resolved.
Show resolved Hide resolved
public class AccountEventController {

private Logger logger = org.slf4j.LoggerFactory.getLogger(AccountEventController.class);
Raj-Shah1 marked this conversation as resolved.
Show resolved Hide resolved

@Autowired
private CreateAccountEventService createEventService;

@Autowired
private GetAccountEventsListService getAccountEventsListService;

@Autowired
private DeleteAccountEventService deleteEventService;

@Autowired
private UpdateAccountEventService updateEventService;

@Autowired
private GetAccountEventDetailsService getAccountEventDetailsService;
Raj-Shah1 marked this conversation as resolved.
Show resolved Hide resolved

@PostMapping("")
public ResponseEntity<CreateEventFormatterDto> createEvent(HttpServletRequest request,
@PathVariable("account_id") String accountId, @Valid @RequestBody CreateAccountEventDto createEventDto) {
logger.info("Create Event Request received");

CreateEventFormatterDto createEventFormatterDto = createEventService.createEvent(request, accountId,
createEventDto);

return ResponseEntity.status(HttpStatus.CREATED).body(createEventFormatterDto);
}

@GetMapping("")
public ResponseEntity<GetEventsListFormatterDto> getEventsList(HttpServletRequest request,
@PathVariable("account_id") String accountId) {
logger.info("Get events list request received");

GetEventsListFormatterDto getEventsListFormatterDto = getAccountEventsListService.getAccountEventsList(request,
accountId);
return ResponseEntity.status(HttpStatus.OK).body(getEventsListFormatterDto);
}

@DeleteMapping("/{event_id}")
public ResponseEntity<Void> deleteEvent(HttpServletRequest request, @PathVariable("account_id") String accountId,
@PathVariable("event_id") String eventId) {
logger.info("Delete event request received");

deleteEventService.deleteAccountEvent(request, accountId, eventId);

return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}

@PutMapping("/{event_id}")
public ResponseEntity<Void> updateEvent(HttpServletRequest request, @PathVariable("account_id") String accountId,
@PathVariable("event_id") String eventId, @Valid @RequestBody UpdateAccountEventDto updateEventDto) {
logger.info("Update event request received");

updateEventService.updateAccountEvent(request, accountId, eventId, updateEventDto);

return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}

@GetMapping("/{event_id}")
public ResponseEntity<GetEventDetailsFormatterDto> getEventFromAccount(HttpServletRequest request,
@PathVariable("account_id") String accountId, @PathVariable("event_id") String eventId) {
logger.info("Get Event request received");

GetEventDetailsFormatterDto getEventDetailsResponse = getAccountEventDetailsService.getEventDetails(request,
eventId);

return ResponseEntity.ok().body(getEventDetailsResponse);
Raj-Shah1 marked this conversation as resolved.
Show resolved Hide resolved
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@

import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.salessparrow.api.dto.formatter.CreateNoteFormatterDto;
import com.salessparrow.api.dto.formatter.GetNoteDetailsFormatterDto;
import com.salessparrow.api.dto.formatter.GetNotesListFormatterDto;
import com.salessparrow.api.dto.requestMapper.NoteDto;
import com.salessparrow.api.dto.requestMapper.AccountNoteDto;
import com.salessparrow.api.services.accountNotes.CreateAccountNoteService;
import com.salessparrow.api.services.accountNotes.DeleteAccountNoteService;
import com.salessparrow.api.services.accountNotes.GetAccountNoteDetailsService;
import com.salessparrow.api.services.accountNotes.GetAccountNotesListService;
import com.salessparrow.api.services.accountNotes.UpdateAccountNoteService;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
Expand All @@ -43,9 +46,12 @@ public class AccountNoteController {
@Autowired
private DeleteAccountNoteService deleteAccountNoteService;

@Autowired
private UpdateAccountNoteService updateNoteService;

@PostMapping("")
public ResponseEntity<CreateNoteFormatterDto> addNoteToAccount(HttpServletRequest request,
@PathVariable("account_id") String accountId, @Valid @RequestBody NoteDto note) {
@PathVariable("account_id") String accountId, @Valid @RequestBody AccountNoteDto note) {
logger.info("Create Note request received");

CreateNoteFormatterDto createNoteFormatterDto = createNoteService.createNote(request, accountId, note);
Expand Down Expand Up @@ -83,4 +89,14 @@ public ResponseEntity<GetNoteDetailsFormatterDto> deleteNote(HttpServletRequest
return ResponseEntity.noContent().build();
}

@PutMapping("/{note_id}")
public ResponseEntity<Void> updateNote(HttpServletRequest request, @PathVariable("account_id") String accountId,
@PathVariable("note_id") String noteId, @Valid @RequestBody AccountNoteDto accountNoteDto) {
logger.info("Update note request received");

updateNoteService.updateAccountNote(request, accountId, noteId, accountNoteDto);

return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,27 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.salessparrow.api.dto.formatter.CreateTaskFormatterDto;
import com.salessparrow.api.dto.formatter.GetTaskDetailsFormatterDto;
import com.salessparrow.api.dto.requestMapper.CreateAccountTaskDto;
import com.salessparrow.api.dto.requestMapper.UpdateAccountTaskDto;
import com.salessparrow.api.services.accountTask.CreateTaskService;
import com.salessparrow.api.services.accountTask.DeleteTaskService;
import com.salessparrow.api.services.accountTask.GetAccountTaskDetailsService;
import com.salessparrow.api.dto.formatter.GetTasksListFormatterDto;
import com.salessparrow.api.services.accountTask.GetAccountTasksListService;
import com.salessparrow.api.services.accountTask.UpdateAccountTaskService;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;

@RestController
@RequestMapping("/api/v1/accounts")
@RequestMapping("/api/v1/accounts/{account_id}/tasks")
@Validated
public class AccountTaskController {

Expand All @@ -40,7 +45,13 @@ public class AccountTaskController {
@Autowired
private GetAccountTasksListService getAccountTasksListService;

@PostMapping("/{account_id}/tasks")
@Autowired
private UpdateAccountTaskService updateTaskService;

@Autowired
private GetAccountTaskDetailsService getAccountTaskDetailsService;

@PostMapping("")
public ResponseEntity<CreateTaskFormatterDto> createTask(HttpServletRequest request,
@PathVariable("account_id") String accountId, @Valid @RequestBody CreateAccountTaskDto task) {
logger.info("Create task request received");
Expand All @@ -50,7 +61,7 @@ public ResponseEntity<CreateTaskFormatterDto> createTask(HttpServletRequest requ
return ResponseEntity.status(HttpStatus.CREATED).body(createTaskFormatterDto);
}

@GetMapping("/{account_id}/tasks")
@GetMapping("")
public ResponseEntity<GetTasksListFormatterDto> getTasksList(HttpServletRequest request,
@PathVariable("account_id") String accountId) {
logger.info("Get tasks list request received");
Expand All @@ -60,7 +71,7 @@ public ResponseEntity<GetTasksListFormatterDto> getTasksList(HttpServletRequest
return ResponseEntity.status(HttpStatus.OK).body(getTasksListFormatterDto);
}

@DeleteMapping("/{account_id}/tasks/{task_id}")
@DeleteMapping("/{task_id}")
public ResponseEntity<Void> deleteTask(HttpServletRequest request, @PathVariable("account_id") String accountId,
@PathVariable("task_id") String taskId) {
logger.info("Delete task request received");
Expand All @@ -70,4 +81,25 @@ public ResponseEntity<Void> deleteTask(HttpServletRequest request, @PathVariable
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}

@PutMapping("/{task_id}")
public ResponseEntity<Void> updateTask(HttpServletRequest request, @PathVariable("account_id") String accountId,
@PathVariable("task_id") String taskId, @Valid @RequestBody UpdateAccountTaskDto updateTaskDto) {
logger.info("Update task request received");

updateTaskService.updateAccountTask(request, accountId, taskId, updateTaskDto);

return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}

@GetMapping("/{task_id}")
public ResponseEntity<GetTaskDetailsFormatterDto> getTaskFromAccount(HttpServletRequest request,
@PathVariable("account_id") String accountId, @PathVariable("task_id") String taskId) {
logger.info("Get Task request received");

GetTaskDetailsFormatterDto getTaskDetailsResponse = getAccountTaskDetailsService.getTaskDetails(request,
taskId);

return ResponseEntity.ok().body(getTaskDetailsResponse);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.salessparrow.api.dto.entities;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

import lombok.Data;

/**
* Add Event Suggestion Entity is a DTO class for the Add Event Suggestion Entity.
*/
@Data
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class AddEventSuggestionEntityDto {

private String description;

private String startDatetime;

private String endDatetime;

Raj-Shah1 marked this conversation as resolved.
Show resolved Hide resolved
}
29 changes: 29 additions & 0 deletions src/main/java/com/salessparrow/api/dto/entities/EventEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.salessparrow.api.dto.entities;

import java.util.Date;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

import lombok.Data;

/**
* EventEntity is a DTO class for the Event List.
*/
@Data
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class EventEntity {

private String id;

private String creatorName;

private String description;

private String startDatetime;

private String endDatetime;

private Date lastModifiedTime;

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class TaskEntity {

private String crmOrganizationUserName;

private String crmOrganizationUserId;

private Date lastModifiedTime;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.salessparrow.api.dto.formatter;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

import lombok.Data;

/**
* CreateEventFormatterDto is a DTO class for the Create Event response.
*/
@Data
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class CreateEventFormatterDto {

private String eventId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.salessparrow.api.dto.entities.AddEventSuggestionEntityDto;
import com.salessparrow.api.dto.entities.AddTaskSuggestionEntityDto;

import lombok.Data;
Expand All @@ -18,4 +19,6 @@ public class CrmActionSuggestionsFormatterDto {

private List<AddTaskSuggestionEntityDto> addTaskSuggestions;

private List<AddEventSuggestionEntityDto> addEventSuggestions;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.salessparrow.api.dto.formatter;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.salessparrow.api.dto.entities.EventEntity;

import lombok.Data;

@Data
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class GetEventDetailsFormatterDto {

private EventEntity eventDetail;

}
Loading
Loading