Skip to content

Commit

Permalink
Merge pull request #104 from TrueSparrowSystems/create-accounts-event
Browse files Browse the repository at this point in the history
New API Endpoints
  • Loading branch information
Raj-Shah1 authored Oct 9, 2023
2 parents 3640a0c + 1794d18 commit 6f34ccb
Show file tree
Hide file tree
Showing 103 changed files with 4,749 additions and 118 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.0</version>
<version>0.3.0</version>
<name>api</name>
<description>Salessparrow apis</description>

Expand Down
36 changes: 36 additions & 0 deletions repo-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
# 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:

- Improve Task Suggestion to show correct Due Date and empty description if no task found [#94](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/94)

## 0.2.2

### Enhancements:

- Update Default Test User Login to use token from Environment [#92](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/92)

## 0.2.1

### New Features and Enhancements:

- Default Test User Login in Connect Flow [#90](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/90)

### Bug Fixes:

- Use Environment based Naming as Suffix in Cache Names [#91](https://github.com/TrueSparrowSystems/AI-SalesSparrow-API/issues/91)

## 0.2.0

### New Features and Enhancements:
Expand Down
5 changes: 3 additions & 2 deletions sample.secrets.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"ERROR_MAIL_TO": "",
"COOKIE_DOMAIN": "",
"OPENAI_API_KEY": "",
"DEFAULT_TEST_USER":"",
"DEFAULT_TEST_USER_PASSWORD":""
"APP_STORE_TESTER_LOGIN_USER":"",
"APP_STORE_TESTER_LOGIN_PASSWORD":"",
"APP_STORE_TESTER_LOGIN_TOKEN": ""
}
12 changes: 6 additions & 6 deletions src/main/java/com/salessparrow/api/config/CoreConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ public static String localKmsEndpoint() {
return SecretConstants.localKmsEndpoint();
}

public static String defaultTestUser() {
return SecretConstants.defaultTestUser();
public static String appStoreTesterLoginUser() {
return SecretConstants.appStoreTesterLoginUser();
}

public static String defaultTestUserPassword() {
return SecretConstants.defaultTestUserPassword();
public static String appStoreTesterLoginPassword() {
return SecretConstants.appStoreTesterLoginPassword();
}

public static String defaultTestUserCode() {
return "test_12341234";
public static String appStoreTesterLoginToken() {
return SecretConstants.appStoreTesterLoginToken();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class AccountController {
@GetMapping("")
public ResponseEntity<GetAccountListResponseDto> getAccounts(HttpServletRequest request,
@Valid @ModelAttribute GetAccountsDto getAccountsDto) {
logger.info("Request received");
logger.info("Get Accounts Request received");

GetAccountListResponseDto getAccountsResponse = getAccountListService.getAccounts(request, getAccountsDto);

Expand All @@ -45,7 +45,7 @@ public ResponseEntity<GetAccountListResponseDto> getAccounts(HttpServletRequest
@GetMapping("/feed")
public ResponseEntity<GetAccountsFeedResponseDto> getFeed(HttpServletRequest request,
@Valid @ModelAttribute GetAccountsFeedDto getAccountsFeedDto) {
logger.info("Request received");
logger.info("Get Account Feed Request received");

GetAccountsFeedResponseDto getAccountsFeedResponse = getAccountsFeedService.getAccountsFeed(request,
getAccountsFeedDto);
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 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 @@ -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;

}
Loading

0 comments on commit 6f34ccb

Please sign in to comment.