Skip to content

Commit

Permalink
Merge pull request #105 from TrueSparrowSystems/milestone/v0.3.0
Browse files Browse the repository at this point in the history
New API Endpoints
  • Loading branch information
Raj-Shah1 authored Nov 9, 2023
2 parents a5f015a + 2dd7180 commit d548b06
Show file tree
Hide file tree
Showing 110 changed files with 4,860 additions and 102 deletions.
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
Expand Up @@ -24,7 +24,7 @@
@Validated
public class AccountController {

private Logger logger = org.slf4j.LoggerFactory.getLogger(AccountController.class);
private static final Logger logger = org.slf4j.LoggerFactory.getLogger(AccountController.class);

@Autowired
private GetAccountListService getAccountListService;
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
public class AccountEventController {

private static final Logger logger = org.slf4j.LoggerFactory.getLogger(AccountEventController.class);

@Autowired
private CreateAccountEventService createEventService;

@Autowired
private GetAccountEventsListService getAccountEventsListService;

@Autowired
private DeleteAccountEventService deleteEventService;

@Autowired
private UpdateAccountEventService updateEventService;

@Autowired
private GetAccountEventDetailsService getAccountEventDetailsService;

@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);
}

}
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 @@ -29,7 +32,7 @@
@Validated
public class AccountNoteController {

private Logger logger = org.slf4j.LoggerFactory.getLogger(AccountNoteController.class);
private static final Logger logger = org.slf4j.LoggerFactory.getLogger(AccountNoteController.class);

@Autowired
private GetAccountNotesListService getNotesListService;
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,25 +10,31 @@
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 {

// TODO: Use Lombok's @Slf4j annotation instead of the following:
Logger logger = LoggerFactory.getLogger(AccountTaskController.class);

@Autowired
Expand All @@ -40,7 +46,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 +62,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 +72,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 +82,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
Expand Up @@ -19,7 +19,7 @@
@Validated
public class SuggestionsController {

private Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class);
private static final Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class);

@Autowired
private CrmActionsSuggestionsService crmActionsSuggestionsService;
Expand Down
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;

}
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;

}
Loading

0 comments on commit d548b06

Please sign in to comment.