diff --git a/pom.xml b/pom.xml index ffb28e87..7b1344f8 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.salessparrow salessparrow-api - 0.2.3 + 0.3.0 api Salessparrow apis diff --git a/repo-docs/CHANGELOG.md b/repo-docs/CHANGELOG.md index 755b3952..0a9e4dab 100644 --- a/repo-docs/CHANGELOG.md +++ b/repo-docs/CHANGELOG.md @@ -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: diff --git a/src/main/java/com/salessparrow/api/controllers/AccountController.java b/src/main/java/com/salessparrow/api/controllers/AccountController.java index adaa9ab5..4050afa7 100644 --- a/src/main/java/com/salessparrow/api/controllers/AccountController.java +++ b/src/main/java/com/salessparrow/api/controllers/AccountController.java @@ -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; diff --git a/src/main/java/com/salessparrow/api/controllers/AccountEventController.java b/src/main/java/com/salessparrow/api/controllers/AccountEventController.java new file mode 100644 index 00000000..ac28d711 --- /dev/null +++ b/src/main/java/com/salessparrow/api/controllers/AccountEventController.java @@ -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 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 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 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 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 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); + } + +} diff --git a/src/main/java/com/salessparrow/api/controllers/AccountNoteController.java b/src/main/java/com/salessparrow/api/controllers/AccountNoteController.java index ff6d4d6c..c4bfd8d1 100644 --- a/src/main/java/com/salessparrow/api/controllers/AccountNoteController.java +++ b/src/main/java/com/salessparrow/api/controllers/AccountNoteController.java @@ -2,12 +2,14 @@ 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; @@ -15,11 +17,12 @@ 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; @@ -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; @@ -43,9 +46,12 @@ public class AccountNoteController { @Autowired private DeleteAccountNoteService deleteAccountNoteService; + @Autowired + private UpdateAccountNoteService updateNoteService; + @PostMapping("") public ResponseEntity 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); @@ -83,4 +89,14 @@ public ResponseEntity deleteNote(HttpServletRequest return ResponseEntity.noContent().build(); } + @PutMapping("/{note_id}") + public ResponseEntity 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(); + } + } diff --git a/src/main/java/com/salessparrow/api/controllers/AccountTaskController.java b/src/main/java/com/salessparrow/api/controllers/AccountTaskController.java index 7cab58dc..0e9f38c9 100644 --- a/src/main/java/com/salessparrow/api/controllers/AccountTaskController.java +++ b/src/main/java/com/salessparrow/api/controllers/AccountTaskController.java @@ -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 @@ -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 createTask(HttpServletRequest request, @PathVariable("account_id") String accountId, @Valid @RequestBody CreateAccountTaskDto task) { logger.info("Create task request received"); @@ -50,7 +62,7 @@ public ResponseEntity createTask(HttpServletRequest requ return ResponseEntity.status(HttpStatus.CREATED).body(createTaskFormatterDto); } - @GetMapping("/{account_id}/tasks") + @GetMapping("") public ResponseEntity getTasksList(HttpServletRequest request, @PathVariable("account_id") String accountId) { logger.info("Get tasks list request received"); @@ -60,7 +72,7 @@ public ResponseEntity getTasksList(HttpServletRequest return ResponseEntity.status(HttpStatus.OK).body(getTasksListFormatterDto); } - @DeleteMapping("/{account_id}/tasks/{task_id}") + @DeleteMapping("/{task_id}") public ResponseEntity deleteTask(HttpServletRequest request, @PathVariable("account_id") String accountId, @PathVariable("task_id") String taskId) { logger.info("Delete task request received"); @@ -70,4 +82,25 @@ public ResponseEntity deleteTask(HttpServletRequest request, @PathVariable return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); } + @PutMapping("/{task_id}") + public ResponseEntity 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 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); + } + } diff --git a/src/main/java/com/salessparrow/api/controllers/SuggestionsController.java b/src/main/java/com/salessparrow/api/controllers/SuggestionsController.java index 0bef0c1e..f07c7df9 100644 --- a/src/main/java/com/salessparrow/api/controllers/SuggestionsController.java +++ b/src/main/java/com/salessparrow/api/controllers/SuggestionsController.java @@ -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; diff --git a/src/main/java/com/salessparrow/api/dto/entities/AddEventSuggestionEntityDto.java b/src/main/java/com/salessparrow/api/dto/entities/AddEventSuggestionEntityDto.java new file mode 100644 index 00000000..3886fa16 --- /dev/null +++ b/src/main/java/com/salessparrow/api/dto/entities/AddEventSuggestionEntityDto.java @@ -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; + +} diff --git a/src/main/java/com/salessparrow/api/dto/entities/EventEntity.java b/src/main/java/com/salessparrow/api/dto/entities/EventEntity.java new file mode 100644 index 00000000..3c21fed6 --- /dev/null +++ b/src/main/java/com/salessparrow/api/dto/entities/EventEntity.java @@ -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; + +} diff --git a/src/main/java/com/salessparrow/api/dto/entities/TaskEntity.java b/src/main/java/com/salessparrow/api/dto/entities/TaskEntity.java index ba1a199e..6897a273 100644 --- a/src/main/java/com/salessparrow/api/dto/entities/TaskEntity.java +++ b/src/main/java/com/salessparrow/api/dto/entities/TaskEntity.java @@ -24,6 +24,8 @@ public class TaskEntity { private String crmOrganizationUserName; + private String crmOrganizationUserId; + private Date lastModifiedTime; } diff --git a/src/main/java/com/salessparrow/api/dto/formatter/CreateEventFormatterDto.java b/src/main/java/com/salessparrow/api/dto/formatter/CreateEventFormatterDto.java new file mode 100644 index 00000000..06d7f156 --- /dev/null +++ b/src/main/java/com/salessparrow/api/dto/formatter/CreateEventFormatterDto.java @@ -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; + +} \ No newline at end of file diff --git a/src/main/java/com/salessparrow/api/dto/formatter/CrmActionSuggestionsFormatterDto.java b/src/main/java/com/salessparrow/api/dto/formatter/CrmActionSuggestionsFormatterDto.java index 36d39ad7..0057ac18 100644 --- a/src/main/java/com/salessparrow/api/dto/formatter/CrmActionSuggestionsFormatterDto.java +++ b/src/main/java/com/salessparrow/api/dto/formatter/CrmActionSuggestionsFormatterDto.java @@ -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; @@ -18,4 +19,6 @@ public class CrmActionSuggestionsFormatterDto { private List addTaskSuggestions; + private List addEventSuggestions; + } diff --git a/src/main/java/com/salessparrow/api/dto/formatter/GetEventDetailsFormatterDto.java b/src/main/java/com/salessparrow/api/dto/formatter/GetEventDetailsFormatterDto.java new file mode 100644 index 00000000..40872016 --- /dev/null +++ b/src/main/java/com/salessparrow/api/dto/formatter/GetEventDetailsFormatterDto.java @@ -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; + +} diff --git a/src/main/java/com/salessparrow/api/dto/formatter/GetEventsListFormatterDto.java b/src/main/java/com/salessparrow/api/dto/formatter/GetEventsListFormatterDto.java new file mode 100644 index 00000000..bbd573c2 --- /dev/null +++ b/src/main/java/com/salessparrow/api/dto/formatter/GetEventsListFormatterDto.java @@ -0,0 +1,23 @@ +package com.salessparrow.api.dto.formatter; + +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import com.salessparrow.api.dto.entities.EventEntity; + +import lombok.Data; + +/** + * GetEventsListFormatterDto is a DTO class for the GetEventsListFormatterDto response. + */ +@Data +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class GetEventsListFormatterDto { + + private List eventIds; + + private Map eventMapById; + +} diff --git a/src/main/java/com/salessparrow/api/dto/formatter/GetTaskDetailsFormatterDto.java b/src/main/java/com/salessparrow/api/dto/formatter/GetTaskDetailsFormatterDto.java new file mode 100644 index 00000000..16981303 --- /dev/null +++ b/src/main/java/com/salessparrow/api/dto/formatter/GetTaskDetailsFormatterDto.java @@ -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.TaskEntity; + +import lombok.Data; + +@Data +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class GetTaskDetailsFormatterDto { + + private TaskEntity taskDetail; + +} diff --git a/src/main/java/com/salessparrow/api/dto/requestMapper/NoteDto.java b/src/main/java/com/salessparrow/api/dto/requestMapper/AccountNoteDto.java similarity index 90% rename from src/main/java/com/salessparrow/api/dto/requestMapper/NoteDto.java rename to src/main/java/com/salessparrow/api/dto/requestMapper/AccountNoteDto.java index 44ca28f6..cfc24e53 100644 --- a/src/main/java/com/salessparrow/api/dto/requestMapper/NoteDto.java +++ b/src/main/java/com/salessparrow/api/dto/requestMapper/AccountNoteDto.java @@ -6,7 +6,7 @@ import lombok.Data; @Data -public class NoteDto { +public class AccountNoteDto { @NotBlank(message = "missing_text") @Length(max = 12000, message = "text_too_long") diff --git a/src/main/java/com/salessparrow/api/dto/requestMapper/CreateAccountEventDto.java b/src/main/java/com/salessparrow/api/dto/requestMapper/CreateAccountEventDto.java new file mode 100644 index 00000000..e2315545 --- /dev/null +++ b/src/main/java/com/salessparrow/api/dto/requestMapper/CreateAccountEventDto.java @@ -0,0 +1,28 @@ +package com.salessparrow.api.dto.requestMapper; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import com.salessparrow.api.lib.customAnnotations.ValidDatetimeFormat; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.Data; + +@Data +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class CreateAccountEventDto { + + @NotBlank(message = "missing_description") + @Size(max = 32000, message = "description_too_long") + private String description; + + @NotNull(message = "missing_start_datetime") + @ValidDatetimeFormat(message = "invalid_start_datetime") + private String startDatetime; + + @NotNull(message = "missing_end_datetime") + @ValidDatetimeFormat(message = "invalid_end_datetime") + private String endDatetime; + +} diff --git a/src/main/java/com/salessparrow/api/dto/requestMapper/UpdateAccountEventDto.java b/src/main/java/com/salessparrow/api/dto/requestMapper/UpdateAccountEventDto.java new file mode 100644 index 00000000..80b3327b --- /dev/null +++ b/src/main/java/com/salessparrow/api/dto/requestMapper/UpdateAccountEventDto.java @@ -0,0 +1,28 @@ +package com.salessparrow.api.dto.requestMapper; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import com.salessparrow.api.lib.customAnnotations.ValidDatetimeFormat; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.Data; + +@Data +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class UpdateAccountEventDto { + + @NotBlank(message = "missing_description") + @Size(max = 32000, message = "description_too_long") + private String description; + + @NotNull(message = "missing_start_datetime") + @ValidDatetimeFormat(message = "invalid_start_datetime") + private String startDatetime; + + @NotNull(message = "missing_end_datetime") + @ValidDatetimeFormat(message = "invalid_end_datetime") + private String endDatetime; + +} diff --git a/src/main/java/com/salessparrow/api/dto/requestMapper/UpdateAccountTaskDto.java b/src/main/java/com/salessparrow/api/dto/requestMapper/UpdateAccountTaskDto.java new file mode 100644 index 00000000..3a9efc05 --- /dev/null +++ b/src/main/java/com/salessparrow/api/dto/requestMapper/UpdateAccountTaskDto.java @@ -0,0 +1,25 @@ +package com.salessparrow.api.dto.requestMapper; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import com.salessparrow.api.lib.customAnnotations.ValidDateFormat; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; +import lombok.Data; + +@Data +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class UpdateAccountTaskDto { + + @NotBlank(message = "missing_crm_organization_user_id") + private String crmOrganizationUserId; + + @NotBlank(message = "missing_description") + @Size(max = 32000, message = "description_too_long") + private String description; + + @ValidDateFormat(message = "invalid_due_date") + private String dueDate; + +} diff --git a/src/main/java/com/salessparrow/api/exception/GlobalExceptionHandler.java b/src/main/java/com/salessparrow/api/exception/GlobalExceptionHandler.java index fe628eee..7ed1a7c0 100644 --- a/src/main/java/com/salessparrow/api/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/salessparrow/api/exception/GlobalExceptionHandler.java @@ -26,7 +26,7 @@ @ControllerAdvice public class GlobalExceptionHandler { - private Logger logger = org.slf4j.LoggerFactory.getLogger(GlobalExceptionHandler.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(GlobalExceptionHandler.class); @Autowired private ErrorResponse er; diff --git a/src/main/java/com/salessparrow/api/lib/GetCrmActionSuggestions.java b/src/main/java/com/salessparrow/api/lib/GetCrmActionSuggestions.java index b39ad738..fc14fb8c 100644 --- a/src/main/java/com/salessparrow/api/lib/GetCrmActionSuggestions.java +++ b/src/main/java/com/salessparrow/api/lib/GetCrmActionSuggestions.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.salessparrow.api.controllers.SuggestionsController; +import com.salessparrow.api.dto.entities.AddEventSuggestionEntityDto; import com.salessparrow.api.dto.entities.AddTaskSuggestionEntityDto; import com.salessparrow.api.dto.formatter.CrmActionSuggestionsFormatterDto; import com.salessparrow.api.exception.CustomException; @@ -20,6 +21,7 @@ import com.salessparrow.api.lib.openAi.OpenAiPayloadBuilder; import com.salessparrow.api.lib.openAi.OpenAiRequest; import com.salessparrow.api.lib.validators.DateFormatValidator; +import com.salessparrow.api.lib.validators.DatetimeFormatValidator; /** * GetCrmActionSuggestions is a class for getting the crm action suggestions. @@ -35,7 +37,9 @@ public class GetCrmActionSuggestions { private DateFormatValidator dateFormatValidator = new DateFormatValidator(); - private Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class); + private DatetimeFormatValidator datetimeFormatValidator = new DatetimeFormatValidator(); + + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class); /** * Get the crm action suggestions. @@ -69,6 +73,7 @@ private CrmActionSuggestionsFormatterDto parseResponse(String responseBody) { JsonNode functionNode = rootNode.get("choices").get(0).get("message").get("function_call"); List formattedTaskSuggestionEntityDtos = new ArrayList<>(); + List formattedEventSuggestionEntityDtos = new ArrayList<>(); if (functionNode != null) { @@ -78,13 +83,23 @@ private CrmActionSuggestionsFormatterDto parseResponse(String responseBody) { objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); String argumentsJson = objectMapper.convertValue(argumentsNode, String.class); - Map> arguments = objectMapper.readValue(argumentsJson, - new TypeReference>>() { + Map> arguments = objectMapper.readValue(argumentsJson, + new TypeReference>>() { + }); + + List addTaskList = arguments.get("add_task"); + List addEventList = arguments.get("add_event"); + + List typedAddTaskList = objectMapper.convertValue(addTaskList, + new TypeReference>() { }); - List addTaskList = arguments.get("add_task"); - if (addTaskList != null) { - for (AddTaskSuggestionEntityDto addTask : addTaskList) { + List typedAddEventList = objectMapper.convertValue(addEventList, + new TypeReference>() { + }); + + if (typedAddTaskList != null) { + for (AddTaskSuggestionEntityDto addTask : typedAddTaskList) { AddTaskSuggestionEntityDto addTaskSuggestionEntityDto = new AddTaskSuggestionEntityDto(); addTaskSuggestionEntityDto.setDescription(addTask.getDescription()); @@ -98,9 +113,30 @@ private CrmActionSuggestionsFormatterDto parseResponse(String responseBody) { formattedTaskSuggestionEntityDtos.add(addTaskSuggestionEntityDto); } } + + if (typedAddEventList != null) { + for (AddEventSuggestionEntityDto addEvent : typedAddEventList) { + AddEventSuggestionEntityDto addEventSuggestionEntityDto = new AddEventSuggestionEntityDto(); + addEventSuggestionEntityDto.setDescription(addEvent.getDescription()); + + // Format the response check if datetime format is + // yyyy-MM-dd'T'HH:mm:ss.SSSZ else + // remove datetime + if (datetimeFormatValidator.isValid(addEvent.getStartDatetime(), null)) { + addEventSuggestionEntityDto.setStartDatetime(addEvent.getStartDatetime()); + } + + if (datetimeFormatValidator.isValid(addEvent.getEndDatetime(), null)) { + addEventSuggestionEntityDto.setEndDatetime(addEvent.getEndDatetime()); + } + + formattedEventSuggestionEntityDtos.add(addEventSuggestionEntityDto); + } + } } crmActionSuggestionsFormatterDto.setAddTaskSuggestions(formattedTaskSuggestionEntityDtos); + crmActionSuggestionsFormatterDto.setAddEventSuggestions(formattedEventSuggestionEntityDtos); return crmActionSuggestionsFormatterDto; } catch (Exception e) { diff --git a/src/main/java/com/salessparrow/api/lib/Util.java b/src/main/java/com/salessparrow/api/lib/Util.java index 2ca7e414..afce9580 100644 --- a/src/main/java/com/salessparrow/api/lib/Util.java +++ b/src/main/java/com/salessparrow/api/lib/Util.java @@ -173,12 +173,30 @@ public String getDateFormatFromDatetime(Date date) { * @param input The original string containing escaped special characters. * @return A new string where certain special characters have been unescaped. */ - public String unEscapeSpecialCharactersForPlainText(String input) { + public static String unEscapeSpecialCharactersForPlainText(String input) { return input.replace("&", "&"); } - public String replaceNewLineWithBreak(String input) { + public static String replaceNewLineWithBreak(String input) { return input.replace("\n", "
"); } + /** + * Get a trimmed string of a given length. + * @param input + * @param length + * @return String + */ + public static String getTrimmedString(String input, Integer length) { + if (input == null) { + return null; + } + + if (input.length() < length) { + return input; + } + + return input.substring(0, length); + } + } diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateAccountEventFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateAccountEventFactory.java new file mode 100644 index 00000000..54341752 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateAccountEventFactory.java @@ -0,0 +1,43 @@ +package com.salessparrow.api.lib.crmActions.createAccountEvent; + +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.formatter.CreateEventFormatterDto; +import com.salessparrow.api.dto.requestMapper.CreateAccountEventDto; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.globalConstants.UserConstants; + +/** + * CreateAccountEventFactory is a factory class for the create event action for the CRM. + */ +@Component +public class CreateAccountEventFactory { + + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(CreateAccountEventFactory.class); + + @Autowired + private CreateSalesforceAccountEvent createSalesforceEvent; + + /** + * Create an event for a given account + * @param user + * @param accountId + * @return CreateEventFormatterDto + **/ + public CreateEventFormatterDto createEvent(User user, String accountId, CreateAccountEventDto createEventDto) { + logger.info("Create Event Factory started"); + + switch (user.getUserKind()) { + case UserConstants.SALESFORCE_USER_KIND: + return createSalesforceEvent.createEvent(user, accountId, createEventDto); + default: + throw new CustomException( + new ErrorObject("l_ca_cae_caef_cae_1", "something_went_wrong", "Invalid user kind.")); + } + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateAccountEventInterface.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateAccountEventInterface.java new file mode 100644 index 00000000..2acead11 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateAccountEventInterface.java @@ -0,0 +1,17 @@ +package com.salessparrow.api.lib.crmActions.createAccountEvent; + +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.formatter.CreateEventFormatterDto; +import com.salessparrow.api.dto.requestMapper.CreateAccountEventDto; + +/** + * CreateAccountEventInterface is an interface for the create event action for the CRM. + */ +@Component +public interface CreateAccountEventInterface { + + public CreateEventFormatterDto createEvent(User user, String accountId, CreateAccountEventDto createEventDto); + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java new file mode 100644 index 00000000..0f689cbd --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java @@ -0,0 +1,109 @@ +package com.salessparrow.api.lib.crmActions.createAccountEvent; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.formatter.CreateEventFormatterDto; +import com.salessparrow.api.dto.requestMapper.CreateAccountEventDto; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.Util; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.globalConstants.SalesforceConstants; +import com.salessparrow.api.lib.httpLib.HttpClient; +import com.salessparrow.api.lib.salesforce.dto.CompositeRequestDto; +import com.salessparrow.api.lib.salesforce.dto.SalesforceCreateEventDto; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; + +/** + * CreateSalesforceAccountEvent is a class that creates an event for an account in + * Salesforce. + */ +@Component +public class CreateSalesforceAccountEvent implements CreateAccountEventInterface { + + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(CreateSalesforceAccountEvent.class); + + @Autowired + private SalesforceConstants salesforceConstants; + + @Autowired + private MakeCompositeRequest makeCompositeRequest; + + /** + * Create an event for a given account. + * @param user + * @param accountId + * @param createEventDto + * @return CreateEventFormatterDto + */ + public CreateEventFormatterDto createEvent(User user, String accountId, CreateAccountEventDto createEventDto) { + logger.info("Create Salesforce Event started"); + + String salesforceUserId = user.getExternalUserId(); + + String eventDescription = Util.unEscapeSpecialCharactersForPlainText(createEventDto.getDescription()); + String eventSubject = Util.getTrimmedString(eventDescription, + salesforceConstants.salesforceEventSubjectLength()); + + Map createEventBody = new HashMap(); + createEventBody.put("Subject", eventSubject); + createEventBody.put("Description", eventDescription); + createEventBody.put("WhatId", accountId); + createEventBody.put("StartDateTime", createEventDto.getStartDatetime().toString()); + createEventBody.put("EndDateTime", createEventDto.getEndDatetime().toString()); + + CompositeRequestDto createEventCompositeRequestDto = new CompositeRequestDto("POST", + salesforceConstants.salesforceCreateEventUrl(), "CreateEvent", createEventBody); + + List compositeRequests = new ArrayList(); + compositeRequests.add(createEventCompositeRequestDto); + + HttpClient.HttpResponse response = makeCompositeRequest.makePostRequest(compositeRequests, salesforceUserId); + + return parseResponse(response.getResponseBody()); + } + + /** + * Parse the response from Salesforce. + * @param createEventResponse + * @return CreateEventFormatterDto - formatted response + */ + private CreateEventFormatterDto parseResponse(String createEventResponse) { + logger.info("Parsing the response from Salesforce"); + + Util util = new Util(); + JsonNode rootNode = util.getJsonNode(createEventResponse); + + JsonNode createEventCompositeResponse = rootNode.get("compositeResponse").get(0); + Integer createEventStatusCode = createEventCompositeResponse.get("httpStatusCode").asInt(); + + if (createEventStatusCode != 200 && createEventStatusCode != 201) { + String errorBody = createEventCompositeResponse.get("body").asText(); + + throw new CustomException(new ErrorObject("l_ca_cae_csae_pr_1", "internal_server_error", errorBody)); + } + + JsonNode createEventNodeResponseBody = rootNode.get("compositeResponse").get(0).get("body"); + + ObjectMapper mapper = new ObjectMapper(); + mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + SalesforceCreateEventDto salesforceCreateEventDto = mapper.convertValue(createEventNodeResponseBody, + SalesforceCreateEventDto.class); + + CreateEventFormatterDto createEventFormatterDto = new CreateEventFormatterDto(); + createEventFormatterDto.setEventId(salesforceCreateEventDto.getId()); + + return createEventFormatterDto; + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateNoteFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateNoteFactory.java index 64eff701..40eaff4d 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateNoteFactory.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateNoteFactory.java @@ -8,7 +8,7 @@ import com.salessparrow.api.exception.CustomException; import com.salessparrow.api.lib.errorLib.ErrorObject; import com.salessparrow.api.lib.globalConstants.UserConstants; -import com.salessparrow.api.dto.requestMapper.NoteDto; +import com.salessparrow.api.dto.requestMapper.AccountNoteDto; /** * CreateNoteFactory is a factory class for the create note action for the CRM. @@ -25,7 +25,7 @@ public class CreateNoteFactory { * @param accountId * @return CreateNoteFormatterDto **/ - public CreateNoteFormatterDto createNote(SalesforceUser user, String accountId, NoteDto note) { + public CreateNoteFormatterDto createNote(SalesforceUser user, String accountId, AccountNoteDto note) { switch (user.getUserKind()) { case UserConstants.SALESFORCE_USER_KIND: diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateNoteInterface.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateNoteInterface.java index 614274ae..f5526072 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateNoteInterface.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateNoteInterface.java @@ -4,7 +4,7 @@ import com.salessparrow.api.domain.SalesforceUser; import com.salessparrow.api.dto.formatter.CreateNoteFormatterDto; -import com.salessparrow.api.dto.requestMapper.NoteDto; +import com.salessparrow.api.dto.requestMapper.AccountNoteDto; /** * CreateNoteInterface is an interface for the create note action for the CRM. @@ -12,6 +12,6 @@ @Component public interface CreateNoteInterface { - public CreateNoteFormatterDto createNote(SalesforceUser user, String accountId, NoteDto note); + public CreateNoteFormatterDto createNote(SalesforceUser user, String accountId, AccountNoteDto note); } diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateSalesforceNote.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateSalesforceNote.java index 5e06f69e..030a8635 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateSalesforceNote.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateSalesforceNote.java @@ -16,7 +16,7 @@ import com.salessparrow.api.domain.SalesforceUser; import com.salessparrow.api.dto.formatter.CreateNoteFormatterDto; import com.salessparrow.api.exception.CustomException; -import com.salessparrow.api.dto.requestMapper.NoteDto; +import com.salessparrow.api.dto.requestMapper.AccountNoteDto; import com.salessparrow.api.lib.Base64Helper; import com.salessparrow.api.lib.Util; import com.salessparrow.api.lib.errorLib.ErrorObject; @@ -51,13 +51,15 @@ public class CreateSalesforceNote implements CreateNoteInterface { * @param note * @return CreateNoteFormatterDto */ - public CreateNoteFormatterDto createNote(SalesforceUser user, String accountId, NoteDto note) { + public CreateNoteFormatterDto createNote(SalesforceUser user, String accountId, AccountNoteDto note) { String salesforceUserId = user.getExternalUserId(); - Util util = new Util(); String noteContent = note.getText(); - String noteTitle = getNoteTitleFromContent(noteContent); - noteContent = util.replaceNewLineWithBreak(noteContent); + String unEscapeNoteContent = Util.unEscapeSpecialCharactersForPlainText(noteContent); + String noteTitle = Util.getTrimmedString(unEscapeNoteContent, + salesforceConstants.salesforceContentNoteTitleLength()); + + noteContent = Util.replaceNewLineWithBreak(noteContent); String encodedNoteContent = base64Helper.base64Encode(noteContent); Map createNoteBody = new HashMap(); @@ -124,20 +126,4 @@ private CreateNoteFormatterDto parseResponse(String createNoteResponse) { return createNoteFormatterDto; } - /** - * Get the first 50 characters of the note content. - * @param note - note dto - * @return String - */ - private String getNoteTitleFromContent(String noteContent) { - Util util = new Util(); - noteContent = util.unEscapeSpecialCharactersForPlainText(noteContent); - - if (noteContent.length() < 50) { - return noteContent; - } - - return noteContent.substring(0, 50); - } - } diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTask.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTaskInterface.java similarity index 74% rename from src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTask.java rename to src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTaskInterface.java index eb57e094..8e044ea7 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTask.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTaskInterface.java @@ -7,10 +7,11 @@ import com.salessparrow.api.dto.requestMapper.CreateAccountTaskDto; /** - * CreateTask interface is interface for createTask for various CRM services + * CreateAccountTaskInterface interface is interface for createTask for various CRM + * services */ @Component -public interface CreateAccountTask { +public interface CreateAccountTaskInterface { public CreateTaskFormatterDto createAccountTask(User User, String accountId, CreateAccountTaskDto task); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateSalesforceAccountTask.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateSalesforceAccountTask.java index be02ebb9..3a8e19de 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateSalesforceAccountTask.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateSalesforceAccountTask.java @@ -29,7 +29,7 @@ * CreateSalesforceTask class is responsible for creating a task in Salesforce */ @Component -public class CreateSalesforceAccountTask implements CreateAccountTask { +public class CreateSalesforceAccountTask implements CreateAccountTaskInterface { Logger logger = LoggerFactory.getLogger(CreateSalesforceAccountTask.class); @@ -50,8 +50,8 @@ public CreateTaskFormatterDto createAccountTask(User User, String accountId, Cre String salesforceUserId = User.getExternalUserId(); logger.info("createAccountTask task description: {}", task.getDescription()); - Util util = new Util(); - String unEscapedTaskDescription = util.unEscapeSpecialCharactersForPlainText(task.getDescription()); + + String unEscapedTaskDescription = Util.unEscapeSpecialCharactersForPlainText(task.getDescription()); String taskSubject = getTaskSubjectFromDescription(unEscapedTaskDescription); logger.info("performing create task in salesforce"); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteAccountEventFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteAccountEventFactory.java new file mode 100644 index 00000000..388fd3be --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteAccountEventFactory.java @@ -0,0 +1,44 @@ +package com.salessparrow.api.lib.crmActions.deleteAccountEvent; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.globalConstants.UserConstants; + +/** + * DeleteAccountEventFactory is a factory class that handles the deleting of an event in + * an account. + */ +@Component +public class DeleteAccountEventFactory { + + Logger logger = LoggerFactory.getLogger(DeleteAccountEventFactory.class); + + @Autowired + DeleteSalesforceAccountEvent deleteSalesforceAccountEvent; + + /** + * Deletes a event in an account. + * @param user + * @param accountId + * @param eventId + * @return void + */ + public void deleteAccountEvent(User user, String accountId, String eventId) { + logger.info("Delete Account Event Factory called"); + switch (user.getUserKind()) { + case UserConstants.SALESFORCE_USER_KIND: + deleteSalesforceAccountEvent.deleteAccountEvent(user, accountId, eventId); + break; + default: + throw new CustomException( + new ErrorObject("l_ca_dae_daef_1", "something_went_wrong", "Invalid user kind.")); + } + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteAccountEventInterface.java b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteAccountEventInterface.java new file mode 100644 index 00000000..d3572468 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteAccountEventInterface.java @@ -0,0 +1,15 @@ +package com.salessparrow.api.lib.crmActions.deleteAccountEvent; + +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; + +/** + * DeleteAccountEventInterface is an interface for deleting an event in an account. + */ +@Component +public interface DeleteAccountEventInterface { + + public void deleteAccountEvent(User user, String accountId, String eventId); + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteSalesforceAccountEvent.java b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteSalesforceAccountEvent.java new file mode 100644 index 00000000..9bb2200a --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteSalesforceAccountEvent.java @@ -0,0 +1,93 @@ +package com.salessparrow.api.lib.crmActions.deleteAccountEvent; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.JsonNode; +import com.salessparrow.api.domain.User; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.Util; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.errorLib.ParamErrorObject; +import com.salessparrow.api.lib.globalConstants.SalesforceConstants; +import com.salessparrow.api.lib.httpLib.HttpClient; +import com.salessparrow.api.lib.salesforce.dto.CompositeRequestDto; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; + +/** + * DeleteSalesforceAccountEvent is a class that handles the deleting of an event in an + * account for salesforce. + */ +@Component +public class DeleteSalesforceAccountEvent implements DeleteAccountEventInterface { + + private final Util util = new Util(); + + Logger logger = LoggerFactory.getLogger(DeleteSalesforceAccountEvent.class); + + @Autowired + private SalesforceConstants salesforceConstants; + + @Autowired + private MakeCompositeRequest makeCompositeRequest; + + /** + * Deletes an event in an account for salesforce. + * @param user + * @param accountId + * @param eventId + * @return void + */ + public void deleteAccountEvent(User user, String accountId, String eventId) { + logger.info("Delete Salesforce Account Event called"); + + String salesforceUserId = user.getExternalUserId(); + + String url = salesforceConstants.salesforceDeleteAccountEventUrl(eventId); + + CompositeRequestDto compositeReq = new CompositeRequestDto("DELETE", url, "DeleteEvent"); + + List compositeRequests = new ArrayList(); + compositeRequests.add(compositeReq); + + HttpClient.HttpResponse response = makeCompositeRequest.makePostRequest(compositeRequests, salesforceUserId); + + parseResponse(response.getResponseBody()); + + } + + /** + * Parses the response from salesforce. + * @param responseBody + * @return void + */ + private void parseResponse(String responseBody) { + logger.info("Parsing response body"); + JsonNode rootNode = util.getJsonNode(responseBody); + + JsonNode deleteEventCompositeResponse = rootNode.get("compositeResponse").get(0); + Integer deleteEventStatusCode = deleteEventCompositeResponse.get("httpStatusCode").asInt(); + + if (deleteEventStatusCode != 200 && deleteEventStatusCode != 201 && deleteEventStatusCode != 204) { + logger.error("Error in deleting event in salesforce:{}", deleteEventCompositeResponse); + String errorBody = deleteEventCompositeResponse.get("body").asText(); + + // MALFORMED_ID or NOT_FOUND + if (deleteEventStatusCode == 400 || deleteEventStatusCode == 404) { + + throw new CustomException( + new ParamErrorObject("l_ca_dae_dsae_pr_1", errorBody, Arrays.asList("invalid_event_id"))); + } + else { + throw new CustomException(new ErrorObject("l_ca_dae_dsae_pr_2", "something_went_wrong", errorBody)); + } + } + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteAccountNoteFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteAccountNoteFactory.java index c3cfce49..8f32eb8a 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteAccountNoteFactory.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteAccountNoteFactory.java @@ -16,7 +16,7 @@ @Component public class DeleteAccountNoteFactory { - private Logger logger = org.slf4j.LoggerFactory.getLogger(DeleteAccountNoteFactory.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(DeleteAccountNoteFactory.class); @Autowired DeleteSalesforceAccountNote getSalesforceNoteDetails; diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteSalesforceAccountNote.java b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteSalesforceAccountNote.java index 07bd0299..434f08bb 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteSalesforceAccountNote.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteSalesforceAccountNote.java @@ -26,7 +26,7 @@ @Component public class DeleteSalesforceAccountNote implements DeleteAccountNoteInterface { - private Logger logger = org.slf4j.LoggerFactory.getLogger(DeleteSalesforceAccountNote.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(DeleteSalesforceAccountNote.class); @Autowired private SalesforceConstants salesforceConstants; diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountTask/DeleteSalesforceAccountTask.java b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountTask/DeleteSalesforceAccountTask.java index ea237034..d1305f19 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountTask/DeleteSalesforceAccountTask.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountTask/DeleteSalesforceAccountTask.java @@ -70,21 +70,21 @@ private void parseResponse(String responseBody) { Util util = new Util(); JsonNode rootNode = util.getJsonNode(responseBody); - JsonNode deleteNoteCompositeResponse = rootNode.get("compositeResponse").get(0); - Integer deleteNoteStatusCode = deleteNoteCompositeResponse.get("httpStatusCode").asInt(); + JsonNode deleteTaskCompositeResponse = rootNode.get("compositeResponse").get(0); + Integer deleteTaskStatusCode = deleteTaskCompositeResponse.get("httpStatusCode").asInt(); - if (deleteNoteStatusCode != 200 && deleteNoteStatusCode != 201 && deleteNoteStatusCode != 204) { - logger.error("Error in deleting task in salesforce:{}", deleteNoteCompositeResponse); - String errorBody = deleteNoteCompositeResponse.get("body").asText(); + if (deleteTaskStatusCode != 200 && deleteTaskStatusCode != 201 && deleteTaskStatusCode != 204) { + logger.error("Error in deleting task in salesforce:{}", deleteTaskCompositeResponse); + String errorBody = deleteTaskCompositeResponse.get("body").asText(); // MALFORMED_ID or NOT_FOUND - if (deleteNoteStatusCode == 400 || deleteNoteStatusCode == 404) { + if (deleteTaskStatusCode == 400 || deleteTaskStatusCode == 404) { throw new CustomException( - new ParamErrorObject("l_ca_dan_dasn_pr_1", errorBody, Arrays.asList("invalid_task_id"))); + new ParamErrorObject("l_ca_dat_dsat_pr_1", errorBody, Arrays.asList("invalid_task_id"))); } else { - throw new CustomException(new ErrorObject("l_ca_dan_dasn_pr_2", "something_went_wrong", errorBody)); + throw new CustomException(new ErrorObject("l_ca_dat_dsat_pr_2", "something_went_wrong", errorBody)); } } } diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventDetails/GetAccountEventDetails.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventDetails/GetAccountEventDetails.java new file mode 100644 index 00000000..303855e0 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventDetails/GetAccountEventDetails.java @@ -0,0 +1,16 @@ +package com.salessparrow.api.lib.crmActions.getAccountEventDetails; + +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.formatter.GetEventDetailsFormatterDto; + +/** + * GetAccountEventDetails is an interface for the getEventDetails action for the CRM. + */ +@Component +public interface GetAccountEventDetails { + + public GetEventDetailsFormatterDto getEventDetails(User user, String eventId); + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventDetails/GetAccountEventDetailsFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventDetails/GetAccountEventDetailsFactory.java new file mode 100644 index 00000000..b7393264 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventDetails/GetAccountEventDetailsFactory.java @@ -0,0 +1,39 @@ +package com.salessparrow.api.lib.crmActions.getAccountEventDetails; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.formatter.GetEventDetailsFormatterDto; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.globalConstants.UserConstants; + +/** + * GetAccountEventDetailsFactory is a factory class for the getEventDetails action for the + * CRM. + */ +@Component +public class GetAccountEventDetailsFactory { + + @Autowired + GetSalesforceAccountEventDetails getSalesforceEventDetails; + + /** + * getEventDetails is a method that returns the details of an event. + * @param user + * @param eventId + * @return GetEventDetailsFormatterDto + */ + public GetEventDetailsFormatterDto getEventDetails(User user, String eventId) { + + switch (user.getUserKind()) { + case UserConstants.SALESFORCE_USER_KIND: + return getSalesforceEventDetails.getEventDetails(user, eventId); + default: + throw new CustomException( + new ErrorObject("l_ca_gaed_gaedf_gaed_1", "something_went_wrong", "Invalid user kind.")); + } + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventDetails/GetSalesforceAccountEventDetails.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventDetails/GetSalesforceAccountEventDetails.java new file mode 100644 index 00000000..7a29d623 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventDetails/GetSalesforceAccountEventDetails.java @@ -0,0 +1,112 @@ +package com.salessparrow.api.lib.crmActions.getAccountEventDetails; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.entities.EventEntity; +import com.salessparrow.api.dto.formatter.GetEventDetailsFormatterDto; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.Util; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.errorLib.ParamErrorObject; +import com.salessparrow.api.lib.globalConstants.SalesforceConstants; +import com.salessparrow.api.lib.httpLib.HttpClient; +import com.salessparrow.api.lib.salesforce.dto.CompositeRequestDto; +import com.salessparrow.api.lib.salesforce.dto.SalesforceGetEventsListDto; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; +import com.salessparrow.api.lib.salesforce.helper.SalesforceQueryBuilder; + +@Component +public class GetSalesforceAccountEventDetails implements GetAccountEventDetails { + + Logger logger = LoggerFactory.getLogger(GetSalesforceAccountEventDetails.class); + + @Autowired + private SalesforceConstants salesforceConstants; + + @Autowired + private MakeCompositeRequest makeCompositeRequest; + + /** + * Get the details of an event. + * @param user + * @param eventId + * @return GetEventDetailsFormatterDto + **/ + public GetEventDetailsFormatterDto getEventDetails(User user, String eventId) { + + logger.info("Salesforce getEventDetails action called"); + + String salesforceUserId = user.getExternalUserId(); + + SalesforceQueryBuilder salesforceQuery = new SalesforceQueryBuilder(); + String query = salesforceQuery.getAccountEventDetailsUrl(eventId); + + String url = salesforceConstants.queryUrlPath() + query; + + CompositeRequestDto compositeReq = new CompositeRequestDto("GET", url, "GetEventsList"); + + List compositeRequests = new ArrayList(); + compositeRequests.add(compositeReq); + + HttpClient.HttpResponse response = makeCompositeRequest.makePostRequest(compositeRequests, salesforceUserId); + + return parseResponse(response.getResponseBody()); + + } + + /** + * Parse Response + * @param responseBody + * @return GetEventsListFormatterDto + **/ + public GetEventDetailsFormatterDto parseResponse(String responseBody) { + + Util util = new Util(); + JsonNode rootNode = util.getJsonNode(responseBody); + + JsonNode compositeResponse = rootNode.get("compositeResponse").get(0); + Integer statusCode = compositeResponse.get("httpStatusCode").asInt(); + + if (statusCode != 200 && statusCode != 201) { + String errorBody = compositeResponse.get("body").asText(); + + if (statusCode == 400) { + throw new CustomException( + new ParamErrorObject("l_ca_gaed_gsaed_pr_1", errorBody, Arrays.asList("invalid_account_id"))); + } + else { + throw new CustomException(new ErrorObject("l_ca_gaed_gsaed_pr_2", "something_went_wrong", errorBody)); + } + } + + JsonNode recordsNode = rootNode.get("compositeResponse").get(0).get("body").get("records"); + + EventEntity eventEntity = new EventEntity(); + if (recordsNode.size() > 0) { + for (JsonNode recordNode : recordsNode) { + ObjectMapper mapper = new ObjectMapper(); + mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + SalesforceGetEventsListDto salesforceGetEventsListDto = mapper.convertValue(recordNode, + SalesforceGetEventsListDto.class); + eventEntity = salesforceGetEventsListDto.eventEntity(); + } + } + + GetEventDetailsFormatterDto getEventDetailsFormatterDto = new GetEventDetailsFormatterDto(); + getEventDetailsFormatterDto.setEventDetail(eventEntity); + + return getEventDetailsFormatterDto; + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventsList/GetAccountEventsListFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventsList/GetAccountEventsListFactory.java new file mode 100644 index 00000000..ff701c05 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventsList/GetAccountEventsListFactory.java @@ -0,0 +1,44 @@ +package com.salessparrow.api.lib.crmActions.getAccountEventsList; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.formatter.GetEventsListFormatterDto; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.globalConstants.UserConstants; + +/** + * GetAccountEventsListFactory is a factory class for the GetAccountEventsList action for + * the CRM. + */ +@Component +public class GetAccountEventsListFactory { + + Logger logger = LoggerFactory.getLogger(GetAccountEventsListFactory.class); + + @Autowired + private GetSalesforceAccountEventsList getSalesforceAccountEventsList; + + /** + * Get the list of events for a given account. + * @param user + * @param accountId + * @return GetEventsListFormatterDto + **/ + public GetEventsListFormatterDto getAccountEventsList(User user, String accountId) { + logger.info("factory for getAccountEventsList action"); + + switch (user.getUserKind()) { + case UserConstants.SALESFORCE_USER_KIND: + return getSalesforceAccountEventsList.getAccountEventsList(user, accountId); + default: + throw new CustomException( + new ErrorObject("l_ca_gatl_gatlf_gtl_1", "something_went_wrong", "Invalid user kind.")); + } + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventsList/GetAccountEventsListInterface.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventsList/GetAccountEventsListInterface.java new file mode 100644 index 00000000..e86a0a26 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventsList/GetAccountEventsListInterface.java @@ -0,0 +1,17 @@ +package com.salessparrow.api.lib.crmActions.getAccountEventsList; + +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.formatter.GetEventsListFormatterDto; + +/** + * GetAccountEventsListInterface is an interface for the GetAccountEventsList action for + * the CRM. + */ +@Component +public interface GetAccountEventsListInterface { + + public GetEventsListFormatterDto getAccountEventsList(User user, String accountId); + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventsList/GetSalesforceAccountEventsList.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventsList/GetSalesforceAccountEventsList.java new file mode 100644 index 00000000..6802ffcf --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventsList/GetSalesforceAccountEventsList.java @@ -0,0 +1,120 @@ +package com.salessparrow.api.lib.crmActions.getAccountEventsList; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.entities.EventEntity; +import com.salessparrow.api.dto.formatter.GetEventsListFormatterDto; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.Util; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.errorLib.ParamErrorObject; +import com.salessparrow.api.lib.globalConstants.SalesforceConstants; +import com.salessparrow.api.lib.httpLib.HttpClient; +import com.salessparrow.api.lib.salesforce.dto.CompositeRequestDto; +import com.salessparrow.api.lib.salesforce.dto.SalesforceGetEventsListDto; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; +import com.salessparrow.api.lib.salesforce.helper.SalesforceQueryBuilder; + +/** + * GetSalesforceAccountEventsList is a class for the GetAccountEventsList service for the + * Salesforce CRM. + */ +@Component +public class GetSalesforceAccountEventsList { + + Logger logger = LoggerFactory.getLogger(GetSalesforceAccountEventsList.class); + + @Autowired + private SalesforceConstants salesforceConstants; + + @Autowired + private MakeCompositeRequest makeCompositeRequest; + + /** + * Get the list of events for a given account in salesforce + * @param user + * @param accountId + * @return GetEventsListFormatterDto + **/ + public GetEventsListFormatterDto getAccountEventsList(User user, String accountId) { + logger.info("Salesforce getAccountEventsList action called"); + + String salesforceUserId = user.getExternalUserId(); + + SalesforceQueryBuilder salesforceQuery = new SalesforceQueryBuilder(); + String query = salesforceQuery.getAccountEventsQuery(accountId); + + String url = salesforceConstants.queryUrlPath() + query; + + CompositeRequestDto compositeReq = new CompositeRequestDto("GET", url, "GetEventsList"); + + List compositeRequests = new ArrayList(); + compositeRequests.add(compositeReq); + + HttpClient.HttpResponse response = makeCompositeRequest.makePostRequest(compositeRequests, salesforceUserId); + + return parseResponse(response.getResponseBody()); + } + + /** + * Parse Response + * @param responseBody + * @return GetEventsListFormatterDto + **/ + public GetEventsListFormatterDto parseResponse(String responseBody) { + + List eventIds = new ArrayList(); + Map eventIdToEntityMap = new HashMap<>(); + + Util util = new Util(); + JsonNode rootNode = util.getJsonNode(responseBody); + + JsonNode getEventsCompositeResponse = rootNode.get("compositeResponse").get(0); + Integer getEventsStatusCode = getEventsCompositeResponse.get("httpStatusCode").asInt(); + + if (getEventsStatusCode != 200 && getEventsStatusCode != 201) { + String errorBody = getEventsCompositeResponse.get("body").asText(); + + if (getEventsStatusCode == 400) { + throw new CustomException( + new ParamErrorObject("l_ca_gael_gsael_pr_1", errorBody, Arrays.asList("invalid_account_id"))); + } + else { + throw new CustomException(new ErrorObject("l_ca_gael_gsael_pr_2", "something_went_wrong", errorBody)); + } + } + + JsonNode recordsNode = rootNode.get("compositeResponse").get(0).get("body").get("records"); + + for (JsonNode recordNode : recordsNode) { + ObjectMapper mapper = new ObjectMapper(); + mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + SalesforceGetEventsListDto salesforceGetEventsListDto = mapper.convertValue(recordNode, + SalesforceGetEventsListDto.class); + EventEntity eventEntity = salesforceGetEventsListDto.eventEntity(); + + eventIds.add(eventEntity.getId()); + eventIdToEntityMap.put(eventEntity.getId(), eventEntity); + } + + GetEventsListFormatterDto getEventsListFormatterDto = new GetEventsListFormatterDto(); + getEventsListFormatterDto.setEventMapById(eventIdToEntityMap); + getEventsListFormatterDto.setEventIds(eventIds); + + return getEventsListFormatterDto; + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetAccountTaskDetails.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetAccountTaskDetails.java new file mode 100644 index 00000000..a06b190e --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetAccountTaskDetails.java @@ -0,0 +1,16 @@ +package com.salessparrow.api.lib.crmActions.getAccountTaskDetails; + +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.formatter.GetTaskDetailsFormatterDto; + +/** + * GetAccountTaskDetails is an interface for the getTaskDetails action for the CRM. + */ +@Component +public interface GetAccountTaskDetails { + + public GetTaskDetailsFormatterDto getTaskDetails(User user, String taskId); + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetAccountTaskDetailsFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetAccountTaskDetailsFactory.java new file mode 100644 index 00000000..6f1d49c0 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetAccountTaskDetailsFactory.java @@ -0,0 +1,39 @@ +package com.salessparrow.api.lib.crmActions.getAccountTaskDetails; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.formatter.GetTaskDetailsFormatterDto; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.globalConstants.UserConstants; + +/** + * GetAccountTaskDetailsFactory is a factory class for the getTaskDetails action for the + * CRM. + */ +@Component +public class GetAccountTaskDetailsFactory { + + @Autowired + GetSalesforceAccountTaskDetails getSalesforceTaskDetails; + + /** + * getTaskDetails is a method that returns the details of a task. + * @param user + * @param taskId + * @return GetTaskDetailsFormatterDto + */ + public GetTaskDetailsFormatterDto getTaskDetails(User user, String taskId) { + + switch (user.getUserKind()) { + case UserConstants.SALESFORCE_USER_KIND: + return getSalesforceTaskDetails.getTaskDetails(user, taskId); + default: + throw new CustomException( + new ErrorObject("l_ca_gatd_gatdf_gatd_1", "something_went_wrong", "Invalid user kind.")); + } + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetSalesforceAccountTaskDetails.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetSalesforceAccountTaskDetails.java new file mode 100644 index 00000000..f269ec86 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetSalesforceAccountTaskDetails.java @@ -0,0 +1,112 @@ +package com.salessparrow.api.lib.crmActions.getAccountTaskDetails; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.entities.TaskEntity; +import com.salessparrow.api.dto.formatter.GetTaskDetailsFormatterDto; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.Util; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.errorLib.ParamErrorObject; +import com.salessparrow.api.lib.globalConstants.SalesforceConstants; +import com.salessparrow.api.lib.httpLib.HttpClient; +import com.salessparrow.api.lib.salesforce.dto.CompositeRequestDto; +import com.salessparrow.api.lib.salesforce.dto.SalesforceGetTasksListDto; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; +import com.salessparrow.api.lib.salesforce.helper.SalesforceQueryBuilder; + +@Component +public class GetSalesforceAccountTaskDetails implements GetAccountTaskDetails { + + Logger logger = LoggerFactory.getLogger(GetSalesforceAccountTaskDetails.class); + + @Autowired + private SalesforceConstants salesforceConstants; + + @Autowired + private MakeCompositeRequest makeCompositeRequest; + + /** + * Get the details of an task. + * @param user + * @param taskId + * @return GetTaskDetailsFormatterDto + **/ + public GetTaskDetailsFormatterDto getTaskDetails(User user, String taskId) { + + logger.info("Salesforce getTaskDetails action called"); + + String salesforceUserId = user.getExternalUserId(); + + SalesforceQueryBuilder salesforceQuery = new SalesforceQueryBuilder(); + String query = salesforceQuery.getAccountTaskDetailsUrl(taskId); + + String url = salesforceConstants.queryUrlPath() + query; + + CompositeRequestDto compositeReq = new CompositeRequestDto("GET", url, "GetTaskDetails"); + + List compositeRequests = new ArrayList(); + compositeRequests.add(compositeReq); + + HttpClient.HttpResponse response = makeCompositeRequest.makePostRequest(compositeRequests, salesforceUserId); + + return parseResponse(response.getResponseBody()); + + } + + /** + * Parse Response + * @param responseBody + * @return GetTaskDetailsFormatterDto + **/ + public GetTaskDetailsFormatterDto parseResponse(String responseBody) { + + Util util = new Util(); + JsonNode rootNode = util.getJsonNode(responseBody); + + JsonNode compositeResponse = rootNode.get("compositeResponse").get(0); + Integer statusCode = compositeResponse.get("httpStatusCode").asInt(); + + if (statusCode != 200 && statusCode != 201) { + String errorBody = compositeResponse.get("body").asText(); + + if (statusCode == 400) { + throw new CustomException( + new ParamErrorObject("l_ca_gatd_gsatd_pr_1", errorBody, Arrays.asList("invalid_account_id"))); + } + else { + throw new CustomException(new ErrorObject("l_ca_gatd_gsatd_pr_2", "something_went_wrong", errorBody)); + } + } + + JsonNode recordsNode = rootNode.get("compositeResponse").get(0).get("body").get("records"); + + TaskEntity taskEntity = new TaskEntity(); + if (recordsNode.size() > 0) { + ObjectMapper mapper = new ObjectMapper(); + mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + for (JsonNode recordNode : recordsNode) { + SalesforceGetTasksListDto salesforceGetTasksListDto = mapper.convertValue(recordNode, + SalesforceGetTasksListDto.class); + taskEntity = salesforceGetTasksListDto.taskEntity(); + } + } + + GetTaskDetailsFormatterDto getTaskDetailsFormatterDto = new GetTaskDetailsFormatterDto(); + getTaskDetailsFormatterDto.setTaskDetail(taskEntity); + + return getTaskDetailsFormatterDto; + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTasksList/GetSalesforceAccountTasksList.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTasksList/GetSalesforceAccountTasksList.java index 5d29e90d..24bc2a27 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTasksList/GetSalesforceAccountTasksList.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTasksList/GetSalesforceAccountTasksList.java @@ -98,7 +98,6 @@ public GetTasksListFormatterDto parseResponse(String responseBody) { } JsonNode recordsNode = rootNode.get("compositeResponse").get(0).get("body").get("records"); - ; for (JsonNode recordNode : recordsNode) { ObjectMapper mapper = new ObjectMapper(); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateAccountEventFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateAccountEventFactory.java new file mode 100644 index 00000000..44fe8d5d --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateAccountEventFactory.java @@ -0,0 +1,43 @@ +package com.salessparrow.api.lib.crmActions.updateAccountEvent; + +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.requestMapper.UpdateAccountEventDto; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.globalConstants.UserConstants; + +/** + * UpdateAccountEventFactory is a factory class for the update event action for the CRM. + */ +@Component +public class UpdateAccountEventFactory { + + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateAccountEventFactory.class); + + @Autowired + private UpdateSalesforceAccountEvent updateSalesforceEvent; + + /** + * Update an event for a given account + * @param user + * @param accountId + * @return void + **/ + public void updateEvent(User user, String accountId, String eventId, UpdateAccountEventDto updateEventDto) { + logger.info("Update Event Factory started"); + + switch (user.getUserKind()) { + case UserConstants.SALESFORCE_USER_KIND: + updateSalesforceEvent.updateEvent(user, accountId, eventId, updateEventDto); + return; + default: + throw new CustomException( + new ErrorObject("l_ua_uae_uaef_uae_1", "something_went_wrong", "Invalid user kind.")); + } + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateAccountEventInterface.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateAccountEventInterface.java new file mode 100644 index 00000000..1427bb66 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateAccountEventInterface.java @@ -0,0 +1,16 @@ +package com.salessparrow.api.lib.crmActions.updateAccountEvent; + +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.requestMapper.UpdateAccountEventDto; + +/** + * UpdateAccountEventInterface is an interface for the update event action for the CRM. + */ +@Component +public interface UpdateAccountEventInterface { + + public void updateEvent(User user, String accountId, String eventId, UpdateAccountEventDto updateEventDto); + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java new file mode 100644 index 00000000..2c1299ed --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java @@ -0,0 +1,102 @@ +package com.salessparrow.api.lib.crmActions.updateAccountEvent; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.JsonNode; +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.requestMapper.UpdateAccountEventDto; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.Util; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.errorLib.ParamErrorObject; +import com.salessparrow.api.lib.globalConstants.SalesforceConstants; +import com.salessparrow.api.lib.httpLib.HttpClient; +import com.salessparrow.api.lib.salesforce.dto.CompositeRequestDto; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; + +/** + * UpdateSalesforceAccountEvent is a class that updates an event for an account in + * Salesforce. + */ +@Component +public class UpdateSalesforceAccountEvent implements UpdateAccountEventInterface { + + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateSalesforceAccountEvent.class); + + @Autowired + private SalesforceConstants salesforceConstants; + + @Autowired + private MakeCompositeRequest makeCompositeRequest; + + /** + * Update an event for a given account. + * @param user + * @param accountId + * @param updateEventDto + * @return void + */ + public void updateEvent(User user, String accountId, String eventId, UpdateAccountEventDto updateEventDto) { + logger.info("Update Salesforce Event started"); + + String salesforceUserId = user.getExternalUserId(); + + String eventDescription = Util.unEscapeSpecialCharactersForPlainText(updateEventDto.getDescription()); + String eventSubject = Util.getTrimmedString(eventDescription, + salesforceConstants.salesforceEventSubjectLength()); + + Map updateEventBody = new HashMap(); + updateEventBody.put("Subject", eventSubject); + updateEventBody.put("Description", eventDescription); + updateEventBody.put("StartDateTime", updateEventDto.getStartDatetime().toString()); + updateEventBody.put("EndDateTime", updateEventDto.getEndDatetime().toString()); + + CompositeRequestDto updateEventCompositeRequestDto = new CompositeRequestDto("PATCH", + salesforceConstants.salesforceUpdateEventUrl(eventId), "UpdateEvent", updateEventBody); + + List compositeRequests = new ArrayList(); + compositeRequests.add(updateEventCompositeRequestDto); + + HttpClient.HttpResponse response = makeCompositeRequest.makePostRequest(compositeRequests, salesforceUserId); + + parseResponse(response.getResponseBody()); + } + + /** + * Parse the response from Salesforce. + * @param updateEventResponse + * @return void + */ + private void parseResponse(String updateEventResponse) { + logger.info("Parsing the response from Salesforce"); + + Util util = new Util(); + JsonNode rootNode = util.getJsonNode(updateEventResponse); + + JsonNode updateEventCompositeResponse = rootNode.get("compositeResponse").get(0); + Integer updateEventStatusCode = updateEventCompositeResponse.get("httpStatusCode").asInt(); + + if (updateEventStatusCode != 200 && updateEventStatusCode != 201 && updateEventStatusCode != 204) { + String errorBody = updateEventCompositeResponse.get("body").asText(); + + // MALFORMED_ID or NOT_FOUND + if (updateEventStatusCode == 400 || updateEventStatusCode == 404) { + + throw new CustomException( + new ParamErrorObject("l_ua_uae_usae_pr_1", errorBody, Arrays.asList("invalid_event_id"))); + } + else { + throw new CustomException(new ErrorObject("l_ua_uae_usae_pr_2", "something_went_wrong", errorBody)); + } + } + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateAccountNoteFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateAccountNoteFactory.java new file mode 100644 index 00000000..1b304287 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateAccountNoteFactory.java @@ -0,0 +1,43 @@ +package com.salessparrow.api.lib.crmActions.updateAccountNote; + +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.requestMapper.AccountNoteDto; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.globalConstants.UserConstants; + +/** + * UpdateAccountNoteFactory is a factory class for the update note action for the CRM. + */ +@Component +public class UpdateAccountNoteFactory { + + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateAccountNoteFactory.class); + + @Autowired + private UpdateSalesforceAccountNote updateSalesforceNote; + + /** + * Update a note for a given account + * @param user + * @param accountId + * @return void + **/ + public void updateNote(User user, String accountId, String noteId, AccountNoteDto accountNoteDto) { + logger.info("Update Note Factory started"); + + switch (user.getUserKind()) { + case UserConstants.SALESFORCE_USER_KIND: + updateSalesforceNote.updateNote(user, accountId, noteId, accountNoteDto); + return; + default: + throw new CustomException( + new ErrorObject("l_ua_uan_uanf_uan_1", "something_went_wrong", "Invalid user kind.")); + } + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateAccountNoteInterface.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateAccountNoteInterface.java new file mode 100644 index 00000000..cd872529 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateAccountNoteInterface.java @@ -0,0 +1,16 @@ +package com.salessparrow.api.lib.crmActions.updateAccountNote; + +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.requestMapper.AccountNoteDto; + +/** + * UpdateAccountNoteInterface is an interface for the update note action for the CRM. + */ +@Component +public interface UpdateAccountNoteInterface { + + public void updateNote(User user, String accountId, String noteId, AccountNoteDto noteDto); + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java new file mode 100644 index 00000000..63ec6929 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java @@ -0,0 +1,108 @@ +package com.salessparrow.api.lib.crmActions.updateAccountNote; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.JsonNode; +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.requestMapper.AccountNoteDto; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.Base64Helper; +import com.salessparrow.api.lib.Util; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.errorLib.ParamErrorObject; +import com.salessparrow.api.lib.globalConstants.SalesforceConstants; +import com.salessparrow.api.lib.httpLib.HttpClient; +import com.salessparrow.api.lib.salesforce.dto.CompositeRequestDto; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; + +/** + * UpdateSalesforceAccountNote is a class that updates a note for an account in + * Salesforce. + */ +@Component +public class UpdateSalesforceAccountNote implements UpdateAccountNoteInterface { + + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateSalesforceAccountNote.class); + + @Autowired + private SalesforceConstants salesforceConstants; + + @Autowired + private MakeCompositeRequest makeCompositeRequest; + + @Autowired + private Base64Helper base64Helper; + + /** + * Update a note for a given account. + * @param user + * @param accountId + * @param accountNoteDto + * @param noteId + * @return void + */ + public void updateNote(User user, String accountId, String noteId, AccountNoteDto accountNoteDto) { + logger.info("Update Salesforce Note started"); + String salesforceUserId = user.getExternalUserId(); + + String noteContent = accountNoteDto.getText(); + String unEscapeNoteContent = Util.unEscapeSpecialCharactersForPlainText(noteContent); + String noteTitle = Util.getTrimmedString(unEscapeNoteContent, + salesforceConstants.salesforceContentNoteTitleLength()); + + noteContent = Util.replaceNewLineWithBreak(noteContent); + String encodedNoteContent = base64Helper.base64Encode(noteContent); + + Map updateNoteBody = new HashMap(); + updateNoteBody.put("Title", noteTitle); + updateNoteBody.put("Content", encodedNoteContent); + + CompositeRequestDto updateNoteCompositeRequestDto = new CompositeRequestDto("PATCH", + salesforceConstants.salesforceUpdateNoteUrl(noteId), "UpdateNote", updateNoteBody); + + List compositeRequests = new ArrayList(); + compositeRequests.add(updateNoteCompositeRequestDto); + + HttpClient.HttpResponse response = makeCompositeRequest.makePostRequest(compositeRequests, salesforceUserId); + + parseResponse(response.getResponseBody()); + } + + /** + * Parse the response from Salesforce. + * @param updateNoteResponse + * @return void + */ + private void parseResponse(String updateNoteResponse) { + logger.info("Parsing the response from Salesforce"); + + Util util = new Util(); + JsonNode rootNode = util.getJsonNode(updateNoteResponse); + + JsonNode compositeResponse = rootNode.get("compositeResponse").get(0); + Integer statusCode = compositeResponse.get("httpStatusCode").asInt(); + + if (statusCode != 200 && statusCode != 201 && statusCode != 204) { + String errorBody = compositeResponse.get("body").asText(); + + // MALFORMED_ID or NOT_FOUND + if (statusCode == 400 || statusCode == 404) { + + throw new CustomException( + new ParamErrorObject("l_ua_uan_usan_pr_1", errorBody, Arrays.asList("invalid_note_id"))); + } + else { + throw new CustomException(new ErrorObject("l_ua_uan_usan_pr_2", "something_went_wrong", errorBody)); + } + } + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateAccountTaskFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateAccountTaskFactory.java new file mode 100644 index 00000000..85b14968 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateAccountTaskFactory.java @@ -0,0 +1,43 @@ +package com.salessparrow.api.lib.crmActions.updateAccountTask; + +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.requestMapper.UpdateAccountTaskDto; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.globalConstants.UserConstants; + +/** + * UpdateAccountTaskFactory is a factory class for the update task action for the CRM. + */ +@Component +public class UpdateAccountTaskFactory { + + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateAccountTaskFactory.class); + + @Autowired + private UpdateSalesforceAccountTask updateSalesforceTask; + + /** + * Update a task for a given account + * @param user + * @param accountId + * @return void + **/ + public void updateTask(User user, String accountId, String taskId, UpdateAccountTaskDto updateTaskDto) { + logger.info("Update Task Factory started"); + + switch (user.getUserKind()) { + case UserConstants.SALESFORCE_USER_KIND: + updateSalesforceTask.updateTask(user, accountId, taskId, updateTaskDto); + return; + default: + throw new CustomException( + new ErrorObject("l_ua_uat_uatf_uat_1", "something_went_wrong", "Invalid user kind.")); + } + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateAccountTaskInterface.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateAccountTaskInterface.java new file mode 100644 index 00000000..581b820f --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateAccountTaskInterface.java @@ -0,0 +1,16 @@ +package com.salessparrow.api.lib.crmActions.updateAccountTask; + +import org.springframework.stereotype.Component; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.requestMapper.UpdateAccountTaskDto; + +/** + * UpdateAccountTaskInterface is an interface for the update task action for the CRM. + */ +@Component +public interface UpdateAccountTaskInterface { + + public void updateTask(User user, String accountId, String taskId, UpdateAccountTaskDto updateTaskDto); + +} diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java new file mode 100644 index 00000000..6bf18ae4 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java @@ -0,0 +1,101 @@ +package com.salessparrow.api.lib.crmActions.updateAccountTask; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.JsonNode; +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.requestMapper.UpdateAccountTaskDto; +import com.salessparrow.api.exception.CustomException; +import com.salessparrow.api.lib.Util; +import com.salessparrow.api.lib.errorLib.ErrorObject; +import com.salessparrow.api.lib.errorLib.ParamErrorObject; +import com.salessparrow.api.lib.globalConstants.SalesforceConstants; +import com.salessparrow.api.lib.httpLib.HttpClient; +import com.salessparrow.api.lib.salesforce.dto.CompositeRequestDto; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; + +/** + * UpdateSalesforceAccountTask is a class that updates a task for an account in + * Salesforce. + */ +@Component +public class UpdateSalesforceAccountTask implements UpdateAccountTaskInterface { + + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateSalesforceAccountTask.class); + + @Autowired + private SalesforceConstants salesforceConstants; + + @Autowired + private MakeCompositeRequest makeCompositeRequest; + + /** + * Update a task for a given account. + * @param user + * @param accountId + * @param updateTaskDto + * @return void + */ + public void updateTask(User user, String accountId, String taskId, UpdateAccountTaskDto updateTaskDto) { + logger.info("Update Salesforce Task started"); + + String salesforceUserId = user.getExternalUserId(); + + String taskDescription = Util.unEscapeSpecialCharactersForPlainText(updateTaskDto.getDescription()); + String taskSubject = Util.getTrimmedString(taskDescription, salesforceConstants.salesforceTaskSubjectLength()); + + Map updateTaskBody = new HashMap(); + updateTaskBody.put("Subject", taskSubject); + updateTaskBody.put("Description", taskDescription); + updateTaskBody.put("OwnerId", updateTaskDto.getCrmOrganizationUserId()); + updateTaskBody.put("ActivityDate", updateTaskDto.getDueDate()); + + CompositeRequestDto updateTaskCompositeRequestDto = new CompositeRequestDto("PATCH", + salesforceConstants.salesforceUpdateTaskUrl(taskId), "UpdateTask", updateTaskBody); + + List compositeRequests = new ArrayList(); + compositeRequests.add(updateTaskCompositeRequestDto); + + HttpClient.HttpResponse response = makeCompositeRequest.makePostRequest(compositeRequests, salesforceUserId); + + parseResponse(response.getResponseBody()); + } + + /** + * Parse the response from Salesforce. + * @param updateTaskResponse + * @return void + */ + private void parseResponse(String updateTaskResponse) { + logger.info("Parsing the response from Salesforce"); + + Util util = new Util(); + JsonNode rootNode = util.getJsonNode(updateTaskResponse); + + JsonNode compositeResponse = rootNode.get("compositeResponse").get(0); + Integer statusCode = compositeResponse.get("httpStatusCode").asInt(); + + if (statusCode != 200 && statusCode != 201 && statusCode != 204) { + String errorBody = compositeResponse.get("body").asText(); + + // MALFORMED_ID or NOT_FOUND + if (statusCode == 400 || statusCode == 404) { + + throw new CustomException( + new ParamErrorObject("l_ua_uat_usat_pr_1", errorBody, Arrays.asList("invalid_task_id"))); + } + else { + throw new CustomException(new ErrorObject("l_ua_uat_usat_pr_2", "something_went_wrong", errorBody)); + } + } + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/customAnnotations/ValidDatetimeFormat.java b/src/main/java/com/salessparrow/api/lib/customAnnotations/ValidDatetimeFormat.java new file mode 100644 index 00000000..788832e5 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/customAnnotations/ValidDatetimeFormat.java @@ -0,0 +1,20 @@ +package com.salessparrow.api.lib.customAnnotations; + +import jakarta.validation.Constraint; +import jakarta.validation.Payload; +import java.lang.annotation.*; + +import com.salessparrow.api.lib.validators.DatetimeFormatValidator; + +@Target({ ElementType.FIELD }) +@Retention(RetentionPolicy.RUNTIME) +@Constraint(validatedBy = DatetimeFormatValidator.class) +public @interface ValidDatetimeFormat { + + String message() default "Invalid Datetime Format"; + + Class[] groups() default {}; + + Class[] payload() default {}; + +} \ No newline at end of file diff --git a/src/main/java/com/salessparrow/api/lib/globalConstants/SalesforceConstants.java b/src/main/java/com/salessparrow/api/lib/globalConstants/SalesforceConstants.java index e1718598..cb5372ab 100644 --- a/src/main/java/com/salessparrow/api/lib/globalConstants/SalesforceConstants.java +++ b/src/main/java/com/salessparrow/api/lib/globalConstants/SalesforceConstants.java @@ -38,6 +38,22 @@ public String salesforceCreateNoteUrl() { return sObjectsPath() + "/ContentNote"; } + public String salesforceCreateEventUrl() { + return sObjectsPath() + "/Event"; + } + + public String salesforceUpdateEventUrl(String eventId) { + return sObjectsPath() + "/Event/" + eventId; + } + + public String salesforceUpdateTaskUrl(String taskId) { + return sObjectsPath() + "/Task/" + taskId; + } + + public String salesforceUpdateNoteUrl(String noteId) { + return sObjectsPath() + "/ContentNote/" + noteId; + } + public String salesforceDeleteNoteUrl(String noteId) { return sObjectsPath() + "/ContentNote/" + noteId; } @@ -66,6 +82,18 @@ public Integer timeoutMillis() { return 10000; } + public Integer salesforceEventSubjectLength() { + return 60; + } + + public Integer salesforceTaskSubjectLength() { + return 60; + } + + public Integer salesforceContentNoteTitleLength() { + return 50; + } + public String salesforceNotesContentUrl(String urlPrefix, String noteId) { return urlPrefix + "/services/data/v58.0/sobjects/ContentNote/" + noteId + "/Content"; } @@ -78,4 +106,8 @@ public String salesforceDeleteAccountTaskUrl(String taskId) { return sObjectsPath() + "/Task/" + taskId; } + public String salesforceDeleteAccountEventUrl(String eventId) { + return sObjectsPath() + "/Event/" + eventId; + } + } diff --git a/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java b/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java index 4603d099..35ce37e0 100644 --- a/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java +++ b/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java @@ -17,29 +17,43 @@ public class OpenAiPayloadBuilder { * @return */ public String payloadForCrmActionsSuggestions(String text) { - String todayDate = getTodaysDate(); - return "{\n" + " \"model\": \"gpt-3.5-turbo-0613\",\n" + " \"messages\": [\n" + " {\n" + // TODO - Use Jackson Library to build this JSON + String payload = "{\n" + " \"model\": \"gpt-3.5-turbo-0613\",\n" + " \"messages\": [\n" + " {\n" + " \"role\": \"system\",\n" - + " \"content\": \"You are an AI assistant that provides suggestions for creating tasks in CRM based solely on the content of the input message. The content of task if any found should only be from input message. If no task suggestions are found in the input message, return empty data. If task suggestions are found, they should include description and due date. Due Date format should be YYYY-MM-DD. Today's date is " + + " \"content\": \"You are an AI assistant that provides suggestions for creating tasks and events in CRM based solely on the content of the input message. The content of the task or event, if any found, should only be from the input message. If no task or event suggestions are found in the input message, return empty data. Suggestions can either be both task and event list or only tasks or only events or empty. If task suggestions are found, they should include description and due date. Due Date format should be YYYY-MM-DD. If event suggestions are found, they should include description and start datetime and end datetime. If end datetime not provided it should be start datetime + 1 hour. Start datetime and end datetime format is yyyy-MM-dd'T'HH:mm:ss.SSS+0000. Today's date is " + todayDate - + ". Use the functions provided to determine task suggestions. If no tasks are possible for the given input message, return an empty response. For example, If Input Message: Had a call with product team. They need a pitch desk by tomorrow. Then it should return description: Create pitch deck. For 2nd Example, If Input Message: 3 tasks. Then it should return empty response as no tasks can be suggested from input message\"\n" + + ". Use the functions provided to determine events and tasks suggestions. If no tasks or events are possible for the given input message, return an empty response. Example 1: Input Message: Had a call with the product team. They need a pitch deck by tomorrow. A meeting is gonna be held in 5 days to discuss the product. Output for Task: Description: Create pitch deck. Output for Event: Description: Meeting with product team to discuss the product. Example 2: Input Message: 3 tasks. Then it should return an empty response as no tasks and no events can be suggested from the input message.\"\n" + " },\n" + " {\n" + " \"role\": \"user\",\n" + " \"content\": \" Input message: \\n" + text + "\\n\"\n" + " }\n" + " ],\n" + " \"functions\": [\n" + " {\n" + " \"name\": \"suggest_actions\",\n" - + " \"description\": \"This is function for suggesting actions in crm(example salesforce, freshsales) based on input message.\",\n" + + " \"description\": \"This is a function for suggesting actions in CRM (example Salesforce, Freshsales) based on the input message.\",\n" + " \"parameters\": {\n" + " \"type\": \"object\",\n" + " \"properties\": {\n" + " \"add_task\": {\n" + " \"name\": \"add_task\",\n" - + " \"description\": \"Tasks using input message. The task should be created only from the input message and if no task can be generated from input message then empty data should be returned.\",\n" + + " \"description\": \"Tasks using the input message. The task should be created only from the input message, and if no task can be generated from the input message, then empty data should be returned.\",\n" + " \"type\": \"array\",\n" + " \"items\": {\n" - + " \"type\": \"object\",\n" + " \"properties\": {\n" + + " \"type\": \"object\",\n" + " \"properties\": {\n" + " \"description\": {\n" + " \"type\": \"string\",\n" - + " \"description\": \"Description for task to add.\"\n" + " },\n" + + " \"description\": \"Description for the task to add.\"\n" + " },\n" + " \"due_date\": {\n" + " \"type\": \"string\",\n" - + " \"description\": \"Due date for task in YYYY-MM-DD format. Today's date is " + + " \"description\": \"Due date for the task in YYYY-MM-DD format. Today's date is " + todayDate + ".\"\n" + " }\n" + " }\n" + " }\n" - + " }\n" + " }\n" + " }\n" + " }\n" + " ]\n" + "}"; + + " },\n" + " \"add_event\": {\n" + " \"name\": \"add_event\",\n" + + " \"description\": \"Events using the input message. The event should be created only from the input message, and if no event can be generated from the input message, then empty data should be returned.\",\n" + + " \"type\": \"array\",\n" + " \"items\": {\n" + + " \"type\": \"object\",\n" + " \"properties\": {\n" + + " \"description\": {\n" + " \"type\": \"string\",\n" + + " \"description\": \"Description for the event to add.\"\n" + " },\n" + + " \"start_datetime\": {\n" + " \"type\": \"string\",\n" + + " \"description\": \"Start Datetime for the event in yyyy-MM-dd'T'HH:mm:ss.SSS+0000 format.\"\n" + + " },\n" + " \"end_datetime\": {\n" + + " \"type\": \"string\",\n" + + " \"description\": \"End Datetime for the event in yyyy-MM-dd'T'HH:mm:ss.SSS+0000 format.\"\n" + + " }\n" + " }\n" + " }\n" + " }\n" + " }\n" + + " }\n" + " }\n" + " ]\n" + "}"; + + return payload; } /** diff --git a/src/main/java/com/salessparrow/api/lib/openAi/OpenAiRequest.java b/src/main/java/com/salessparrow/api/lib/openAi/OpenAiRequest.java index c9389108..e29c828d 100644 --- a/src/main/java/com/salessparrow/api/lib/openAi/OpenAiRequest.java +++ b/src/main/java/com/salessparrow/api/lib/openAi/OpenAiRequest.java @@ -24,7 +24,7 @@ public class OpenAiRequest { @Autowired private OpenAiConstants openAiConstants; - private Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class); /** * Make a request to the OpenAI API. diff --git a/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceCreateEventDto.java b/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceCreateEventDto.java new file mode 100644 index 00000000..e521ba1a --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceCreateEventDto.java @@ -0,0 +1,17 @@ +package com.salessparrow.api.lib.salesforce.dto; + +import lombok.Data; + +/** + * DTO for the response of the Salesforce API when creating an event. + */ +@Data +public class SalesforceCreateEventDto { + + String id; + + String success; + + String[] errors; + +} diff --git a/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetEventsListDto.java b/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetEventsListDto.java new file mode 100644 index 00000000..26bf7e84 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetEventsListDto.java @@ -0,0 +1,48 @@ +package com.salessparrow.api.lib.salesforce.dto; + +import java.util.Date; + +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.UpperCamelCaseStrategy.class) +public class SalesforceGetEventsListDto { + + private String id; + + private String description; + + private CreatedBy createdBy; + + private String startDateTime; + + private String endDateTime; + + private Date lastModifiedDate; + + @Data + @JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class) + private class CreatedBy { + + private String name; + + } + + public EventEntity eventEntity() { + + EventEntity eventEntity = new EventEntity(); + eventEntity.setId(this.id); + eventEntity.setCreatorName(this.createdBy.name); + eventEntity.setDescription(this.description); + eventEntity.setStartDatetime(this.startDateTime); + eventEntity.setEndDatetime(this.endDateTime); + eventEntity.setLastModifiedTime(this.lastModifiedDate); + + return eventEntity; + } + +} diff --git a/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetNoteDetailsDto.java b/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetNoteDetailsDto.java index bb8422d2..9151bda6 100644 --- a/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetNoteDetailsDto.java +++ b/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetNoteDetailsDto.java @@ -2,6 +2,8 @@ import java.util.Date; +import org.springframework.web.util.HtmlUtils; + import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; import com.salessparrow.api.dto.entities.NoteDetailEntity; @@ -27,8 +29,9 @@ private class CreatedBy { } public NoteDetailEntity noteDetailEntity(String noteContentResponse) { - NoteDetailEntity noteDetailEntity = new NoteDetailEntity(this.id, this.createdBy.name, noteContentResponse, - this.lastModifiedDate); + String decodedNoteContentResponse = HtmlUtils.htmlUnescape(noteContentResponse); + NoteDetailEntity noteDetailEntity = new NoteDetailEntity(this.id, this.createdBy.name, + decodedNoteContentResponse, this.lastModifiedDate); return noteDetailEntity; } diff --git a/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetTasksListDto.java b/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetTasksListDto.java index f8bfe670..10fc80ca 100644 --- a/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetTasksListDto.java +++ b/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetTasksListDto.java @@ -39,6 +39,8 @@ private class Owner { private String name; + private String id; + } public TaskEntity taskEntity() { @@ -49,6 +51,7 @@ public TaskEntity taskEntity() { taskEntity.setCreatorName(this.createdBy.name); taskEntity.setDescription(this.description); taskEntity.setCrmOrganizationUserName(this.owner.name); + taskEntity.setCrmOrganizationUserId(this.owner.id); taskEntity.setLastModifiedTime(this.lastModifiedDate); String dueDate = util.getDateFormatFromDatetime(this.activityDate); diff --git a/src/main/java/com/salessparrow/api/lib/salesforce/helper/SalesforceQueryBuilder.java b/src/main/java/com/salessparrow/api/lib/salesforce/helper/SalesforceQueryBuilder.java index eeacbeda..4b496cb2 100644 --- a/src/main/java/com/salessparrow/api/lib/salesforce/helper/SalesforceQueryBuilder.java +++ b/src/main/java/com/salessparrow/api/lib/salesforce/helper/SalesforceQueryBuilder.java @@ -54,7 +54,7 @@ public String getAccountTasksQuery(String accountId) { accountId = Util.escapeSpecialChars(accountId); return Util.urlEncoder( - "SELECT Id, Description, ActivityDate, CreatedBy.Name, Owner.Name, LastModifiedDate FROM Task WHERE WhatId='" + "SELECT Id, Description, ActivityDate, CreatedBy.Name, Owner.Name, Owner.Id, LastModifiedDate FROM Task WHERE WhatId='" + accountId + "' ORDER BY LastModifiedDate DESC LIMIT 5"); } @@ -115,4 +115,33 @@ public String getCrmOrganizationUsersQuery(String searchTerm) { return Util.urlEncoder(query); } + /** + * Get the list of events for a given account + * @param accountId + * @return String + */ + public String getAccountEventsQuery(String accountId) { + accountId = Util.escapeSpecialChars(accountId); + + return Util.urlEncoder( + "SELECT Id, Description, CreatedBy.Name, StartDateTime, EndDateTime, LastModifiedDate FROM Event WHERE WhatId='" + + accountId + "' ORDER BY LastModifiedDate DESC LIMIT 5"); + } + + public String getAccountEventDetailsUrl(String eventId) { + eventId = Util.escapeSpecialChars(eventId); + + return Util.urlEncoder( + "SELECT Id, Description, CreatedBy.Name, StartDateTime, EndDateTime, LastModifiedDate FROM Event WHERE Id = '" + + eventId + "'"); + } + + public String getAccountTaskDetailsUrl(String taskId) { + taskId = Util.escapeSpecialChars(taskId); + + return Util.urlEncoder( + "SELECT Id, Description, ActivityDate, CreatedBy.Name, Owner.Name, Owner.Id, LastModifiedDate FROM Task WHERE Id = '" + + taskId + "'"); + } + } diff --git a/src/main/java/com/salessparrow/api/lib/validators/DatetimeFormatValidator.java b/src/main/java/com/salessparrow/api/lib/validators/DatetimeFormatValidator.java new file mode 100644 index 00000000..d843e3c3 --- /dev/null +++ b/src/main/java/com/salessparrow/api/lib/validators/DatetimeFormatValidator.java @@ -0,0 +1,54 @@ +package com.salessparrow.api.lib.validators; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.salessparrow.api.lib.customAnnotations.ValidDatetimeFormat; + +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; + +/** + * Validate datetime format with regular expression + * + */ +public class DatetimeFormatValidator implements ConstraintValidator { + + private static final String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; + + /** + * Validate datetime format with regular expression + * @param value datetime address for validation + * @return true valid date format, false invalid date format + */ + @Override + public boolean isValid(String value, ConstraintValidatorContext context) { + if (value == null) { + return false; + } + + SimpleDateFormat sdf = new SimpleDateFormat(DATETIME_FORMAT); + sdf.setLenient(false); + + try { + // Attempt to parse the input date string + Date parsedDate = sdf.parse(value); + + // Check if the parsed date is not null + if (parsedDate != null) { + // Format the parsed date back into a string + String formattedDate = sdf.format(parsedDate); + + // Compare the formatted date with the input value + return formattedDate.equals(value); + } + else { + return false; + } + } + catch (Exception ex) { + return false; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/salessparrow/api/services/accountEvents/CreateAccountEventService.java b/src/main/java/com/salessparrow/api/services/accountEvents/CreateAccountEventService.java new file mode 100644 index 00000000..ae21eb43 --- /dev/null +++ b/src/main/java/com/salessparrow/api/services/accountEvents/CreateAccountEventService.java @@ -0,0 +1,42 @@ +package com.salessparrow.api.services.accountEvents; + +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.formatter.CreateEventFormatterDto; +import com.salessparrow.api.dto.requestMapper.CreateAccountEventDto; +import com.salessparrow.api.lib.crmActions.createAccountEvent.CreateAccountEventFactory; + +import jakarta.servlet.http.HttpServletRequest; + +/** + * CreateAccountEventService is a service class for the create account event action for + * the CRM. + */ +@Service +public class CreateAccountEventService { + + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(CreateAccountEventService.class); + + @Autowired + private CreateAccountEventFactory createAccountEventFactory; + + /** + * Create an event for a specific account. + * @param request + * @param accountId + * @param createEventDto + * @return CreateEventFormatterDto + */ + public CreateEventFormatterDto createEvent(HttpServletRequest request, String accountId, + CreateAccountEventDto createEventDto) { + logger.info("Create Account Event Service started"); + + User currentUser = (User) request.getAttribute("current_user"); + + return createAccountEventFactory.createEvent(currentUser, accountId, createEventDto); + } + +} \ No newline at end of file diff --git a/src/main/java/com/salessparrow/api/services/accountEvents/DeleteAccountEventService.java b/src/main/java/com/salessparrow/api/services/accountEvents/DeleteAccountEventService.java new file mode 100644 index 00000000..20ee67a6 --- /dev/null +++ b/src/main/java/com/salessparrow/api/services/accountEvents/DeleteAccountEventService.java @@ -0,0 +1,40 @@ +package com.salessparrow.api.services.accountEvents; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.lib.crmActions.deleteAccountEvent.DeleteAccountEventFactory; + +import jakarta.servlet.http.HttpServletRequest; + +/** + * DeleteAccountEventService is a service class that handles the deleting of an event in + * an account. + */ +@Service +public class DeleteAccountEventService { + + Logger logger = LoggerFactory.getLogger(DeleteAccountEventService.class); + + @Autowired + private DeleteAccountEventFactory deleteAccountEventFactory; + + /** + * Deletes an event in an account. + * @param request + * @param accountId + * @param eventId + * @return void + */ + public void deleteAccountEvent(HttpServletRequest request, String accountId, String eventId) { + logger.info("Delete event in account service called"); + + User currentUser = (User) request.getAttribute("current_user"); + + deleteAccountEventFactory.deleteAccountEvent(currentUser, accountId, eventId); + } + +} diff --git a/src/main/java/com/salessparrow/api/services/accountEvents/GetAccountEventDetailsService.java b/src/main/java/com/salessparrow/api/services/accountEvents/GetAccountEventDetailsService.java new file mode 100644 index 00000000..a9e47013 --- /dev/null +++ b/src/main/java/com/salessparrow/api/services/accountEvents/GetAccountEventDetailsService.java @@ -0,0 +1,34 @@ +package com.salessparrow.api.services.accountEvents; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.formatter.GetEventDetailsFormatterDto; +import com.salessparrow.api.lib.crmActions.getAccountEventDetails.GetAccountEventDetailsFactory; + +import jakarta.servlet.http.HttpServletRequest; + +/** + * GetAccountEventDetailsService is a service class for the getEventDetails action for the + * CRM. + */ +@Service +public class GetAccountEventDetailsService { + + @Autowired + private GetAccountEventDetailsFactory getEventDetailsFactory; + + /** + * Get the details of an event + * @param accountId + * @param eventId + * @return GetEventDetailsFormatterDto + */ + public GetEventDetailsFormatterDto getEventDetails(HttpServletRequest request, String eventId) { + User currentUser = (User) request.getAttribute("current_user"); + + return getEventDetailsFactory.getEventDetails(currentUser, eventId); + } + +} diff --git a/src/main/java/com/salessparrow/api/services/accountEvents/GetAccountEventsListService.java b/src/main/java/com/salessparrow/api/services/accountEvents/GetAccountEventsListService.java new file mode 100644 index 00000000..8566c3ee --- /dev/null +++ b/src/main/java/com/salessparrow/api/services/accountEvents/GetAccountEventsListService.java @@ -0,0 +1,39 @@ +package com.salessparrow.api.services.accountEvents; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.formatter.GetEventsListFormatterDto; +import com.salessparrow.api.lib.crmActions.getAccountEventsList.GetAccountEventsListFactory; + +import jakarta.servlet.http.HttpServletRequest; + +/** + * GetAccountEventsListService class is responsible for getting list of account events in + * CRM + */ +@Service +public class GetAccountEventsListService { + + Logger logger = LoggerFactory.getLogger(GetAccountEventsListService.class); + + @Autowired + private GetAccountEventsListFactory getAccountEventsListFactory; + + /** + * Get list of account events from CRM + * @param request HttpServletRequest object + * @param accountId CRM account id + * @return GetEventsListFormatterDto object + */ + public GetEventsListFormatterDto getAccountEventsList(HttpServletRequest request, String accountId) { + logger.info("getAccountEventsList Service called"); + + User currentUser = (User) request.getAttribute("current_user"); + return getAccountEventsListFactory.getAccountEventsList(currentUser, accountId); + } + +} diff --git a/src/main/java/com/salessparrow/api/services/accountEvents/UpdateAccountEventService.java b/src/main/java/com/salessparrow/api/services/accountEvents/UpdateAccountEventService.java new file mode 100644 index 00000000..85721a26 --- /dev/null +++ b/src/main/java/com/salessparrow/api/services/accountEvents/UpdateAccountEventService.java @@ -0,0 +1,42 @@ +package com.salessparrow.api.services.accountEvents; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.requestMapper.UpdateAccountEventDto; +import com.salessparrow.api.lib.crmActions.updateAccountEvent.UpdateAccountEventFactory; + +import jakarta.servlet.http.HttpServletRequest; + +/** + * UpdateAccountEventService is a service class that handles the update of an event in an + * account. + */ +@Service +public class UpdateAccountEventService { + + Logger logger = LoggerFactory.getLogger(UpdateAccountEventService.class); + + @Autowired + private UpdateAccountEventFactory updateAccountEventFactory; + + /** + * Updates an event in an account. + * @param request + * @param accountId + * @param eventId + * @return void + */ + public void updateAccountEvent(HttpServletRequest request, String accountId, String eventId, + UpdateAccountEventDto updateEventDto) { + logger.info("Update event in account service called"); + + User currentUser = (User) request.getAttribute("current_user"); + + updateAccountEventFactory.updateEvent(currentUser, accountId, eventId, updateEventDto); + } + +} diff --git a/src/main/java/com/salessparrow/api/services/accountNotes/CreateAccountNoteService.java b/src/main/java/com/salessparrow/api/services/accountNotes/CreateAccountNoteService.java index c7ab77aa..17b9bf85 100644 --- a/src/main/java/com/salessparrow/api/services/accountNotes/CreateAccountNoteService.java +++ b/src/main/java/com/salessparrow/api/services/accountNotes/CreateAccountNoteService.java @@ -5,7 +5,7 @@ import com.salessparrow.api.domain.SalesforceUser; import com.salessparrow.api.dto.formatter.CreateNoteFormatterDto; -import com.salessparrow.api.dto.requestMapper.NoteDto; +import com.salessparrow.api.dto.requestMapper.AccountNoteDto; import com.salessparrow.api.lib.crmActions.createAccountNote.CreateNoteFactory; import jakarta.servlet.http.HttpServletRequest; @@ -25,7 +25,7 @@ public class CreateAccountNoteService { * @param accountId * @return CreateNoteFormatterDto */ - public CreateNoteFormatterDto createNote(HttpServletRequest request, String accountId, NoteDto note) { + public CreateNoteFormatterDto createNote(HttpServletRequest request, String accountId, AccountNoteDto note) { SalesforceUser currentUser = (SalesforceUser) request.getAttribute("current_user"); diff --git a/src/main/java/com/salessparrow/api/services/accountNotes/DeleteAccountNoteService.java b/src/main/java/com/salessparrow/api/services/accountNotes/DeleteAccountNoteService.java index 2c5843b9..2aaf22bf 100644 --- a/src/main/java/com/salessparrow/api/services/accountNotes/DeleteAccountNoteService.java +++ b/src/main/java/com/salessparrow/api/services/accountNotes/DeleteAccountNoteService.java @@ -16,7 +16,7 @@ @Service public class DeleteAccountNoteService { - private Logger logger = org.slf4j.LoggerFactory.getLogger(DeleteAccountNoteService.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(DeleteAccountNoteService.class); @Autowired private DeleteAccountNoteFactory deleteAccountNoteFactory; diff --git a/src/main/java/com/salessparrow/api/services/accountNotes/UpdateAccountNoteService.java b/src/main/java/com/salessparrow/api/services/accountNotes/UpdateAccountNoteService.java new file mode 100644 index 00000000..3dcb0715 --- /dev/null +++ b/src/main/java/com/salessparrow/api/services/accountNotes/UpdateAccountNoteService.java @@ -0,0 +1,42 @@ +package com.salessparrow.api.services.accountNotes; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.requestMapper.AccountNoteDto; +import com.salessparrow.api.lib.crmActions.updateAccountNote.UpdateAccountNoteFactory; + +import jakarta.servlet.http.HttpServletRequest; + +/** + * UpdateAccountNoteService is a service class that handles the update of a note in an + * account. + */ +@Service +public class UpdateAccountNoteService { + + Logger logger = LoggerFactory.getLogger(UpdateAccountNoteService.class); + + @Autowired + private UpdateAccountNoteFactory updateAccountNoteFactory; + + /** + * Updates a note in an account. + * @param request + * @param accountId + * @param noteId + * @return void + */ + public void updateAccountNote(HttpServletRequest request, String accountId, String noteId, + AccountNoteDto accountNoteDto) { + logger.info("Update note in account service called"); + + User currentUser = (User) request.getAttribute("current_user"); + + updateAccountNoteFactory.updateNote(currentUser, accountId, noteId, accountNoteDto); + } + +} diff --git a/src/main/java/com/salessparrow/api/services/accountTask/GetAccountTaskDetailsService.java b/src/main/java/com/salessparrow/api/services/accountTask/GetAccountTaskDetailsService.java new file mode 100644 index 00000000..888efd91 --- /dev/null +++ b/src/main/java/com/salessparrow/api/services/accountTask/GetAccountTaskDetailsService.java @@ -0,0 +1,34 @@ +package com.salessparrow.api.services.accountTask; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.formatter.GetTaskDetailsFormatterDto; +import com.salessparrow.api.lib.crmActions.getAccountTaskDetails.GetAccountTaskDetailsFactory; + +import jakarta.servlet.http.HttpServletRequest; + +/** + * GetAccountTaskDetailsService is a service class for the getTaskDetails action for the + * CRM. + */ +@Service +public class GetAccountTaskDetailsService { + + @Autowired + private GetAccountTaskDetailsFactory getTaskDetailsFactory; + + /** + * Get the details of a task + * @param accountId + * @param taskId + * @return GetTaskDetailsFormatterDto + */ + public GetTaskDetailsFormatterDto getTaskDetails(HttpServletRequest request, String taskId) { + User currentUser = (User) request.getAttribute("current_user"); + + return getTaskDetailsFactory.getTaskDetails(currentUser, taskId); + } + +} diff --git a/src/main/java/com/salessparrow/api/services/accountTask/UpdateAccountTaskService.java b/src/main/java/com/salessparrow/api/services/accountTask/UpdateAccountTaskService.java new file mode 100644 index 00000000..3bfc5c95 --- /dev/null +++ b/src/main/java/com/salessparrow/api/services/accountTask/UpdateAccountTaskService.java @@ -0,0 +1,42 @@ +package com.salessparrow.api.services.accountTask; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.salessparrow.api.domain.User; +import com.salessparrow.api.dto.requestMapper.UpdateAccountTaskDto; +import com.salessparrow.api.lib.crmActions.updateAccountTask.UpdateAccountTaskFactory; + +import jakarta.servlet.http.HttpServletRequest; + +/** + * UpdateAccountTaskService is a service class that handles the update of a task in an + * account. + */ +@Service +public class UpdateAccountTaskService { + + Logger logger = LoggerFactory.getLogger(UpdateAccountTaskService.class); + + @Autowired + private UpdateAccountTaskFactory updateAccountTaskFactory; + + /** + * Updates a task in an account. + * @param request + * @param accountId + * @param taskId + * @return void + */ + public void updateAccountTask(HttpServletRequest request, String accountId, String taskId, + UpdateAccountTaskDto updateTaskDto) { + logger.info("Update task in account service called"); + + User currentUser = (User) request.getAttribute("current_user"); + + updateAccountTaskFactory.updateTask(currentUser, accountId, taskId, updateTaskDto); + } + +} diff --git a/src/main/java/com/salessparrow/api/services/suggestions/CrmActionsSuggestionsService.java b/src/main/java/com/salessparrow/api/services/suggestions/CrmActionsSuggestionsService.java index 2923e2e2..f2ad3ecd 100644 --- a/src/main/java/com/salessparrow/api/services/suggestions/CrmActionsSuggestionsService.java +++ b/src/main/java/com/salessparrow/api/services/suggestions/CrmActionsSuggestionsService.java @@ -18,7 +18,7 @@ public class CrmActionsSuggestionsService { @Autowired private GetCrmActionSuggestions getCrmActionSuggestions; - private Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class); public CrmActionSuggestionsFormatterDto getSuggestions(CrmActionsSuggestionsDto crmActionsSuggestionsDto) { logger.info("Crm actions service called"); diff --git a/src/main/resources/config/ParamErrorConfig.json b/src/main/resources/config/ParamErrorConfig.json index eb3fb4a1..72d0ff7b 100644 --- a/src/main/resources/config/ParamErrorConfig.json +++ b/src/main/resources/config/ParamErrorConfig.json @@ -49,6 +49,11 @@ "param_error_identifier": "invalid_note_id", "message": "The note id you sent is incorrect. Please double check and try again." }, + "invalid_event_id":{ + "parameter": "event_id", + "param_error_identifier": "invalid_event_id", + "message": "Invalid event ID. Please double check and try again." + }, "text_too_long": { "parameter": "text", "param_error_identifier": "text_too_long", @@ -58,5 +63,15 @@ "parameter": "account_id", "param_error_identifier": "invalid_account_id", "message": "The account id you sent is incorrect. Please double check and try again." + }, + "invalid_start_datetime": { + "parameter": "start_datetime", + "param_error_identifier": "invalid_start_datetime", + "message": "Invalid start datetime. Please double check and try again." + }, + "invalid_end_datetime": { + "parameter": "end_datetime", + "param_error_identifier": "invalid_end_datetime", + "message": "Invalid end datetime. Please double check and try again." } } \ No newline at end of file diff --git a/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/CreateAccountEventTest.java b/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/CreateAccountEventTest.java new file mode 100644 index 00000000..5a2ed9cc --- /dev/null +++ b/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/CreateAccountEventTest.java @@ -0,0 +1,135 @@ +package com.salessparrow.api.functional.controllers.accountEventController; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; +import org.springframework.http.MediaType; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.dynamobee.exception.DynamobeeException; +import com.salessparrow.api.helper.Cleanup; +import com.salessparrow.api.helper.Common; +import com.salessparrow.api.helper.Constants; +import com.salessparrow.api.helper.FixtureData; +import com.salessparrow.api.helper.LoadFixture; +import com.salessparrow.api.helper.Scenario; +import com.salessparrow.api.helper.Setup; +import com.salessparrow.api.lib.globalConstants.CookieConstants; +import com.salessparrow.api.lib.httpLib.HttpClient.HttpResponse; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; + +import jakarta.servlet.http.Cookie; + +@SpringBootTest +@AutoConfigureMockMvc +@WebAppConfiguration +@Import({ Setup.class, Cleanup.class, Common.class, LoadFixture.class }) +public class CreateAccountEventTest { + + @Autowired + private MockMvc mockMvc; + + @Autowired + private Common common; + + @Autowired + private LoadFixture loadFixture; + + @Autowired + private Setup setup; + + @Autowired + private Cleanup cleanup; + + @MockBean + private MakeCompositeRequest makeCompositeRequestMock; + + @BeforeEach + public void setUp() throws DynamobeeException { + setup.perform(); + } + + @AfterEach + public void tearDown() { + cleanup.perform(); + } + + @ParameterizedTest + @MethodSource("testScenariosProvider") + public void createAccountEvent(Scenario testScenario) throws Exception { + + // Load fixture data + String currentFunctionName = new Object() { + }.getClass().getEnclosingMethod().getName(); + FixtureData fixtureData = common.loadFixture( + "classpath:fixtures/functional/controllers/accountEventController/createAccountEvent.fixtures.json", + currentFunctionName); + loadFixture.perform(fixtureData); + + // Read data from the scenario + ObjectMapper objectMapper = new ObjectMapper(); + String cookieValue = Constants.SALESFORCE_ACTIVE_USER_COOKIE_VALUE; + String accountId = (String) testScenario.getInput().get("accountId"); + + // Prepare mock responses + HttpResponse createEventMockResponse = new HttpResponse(); + createEventMockResponse + .setResponseBody(objectMapper.writeValueAsString(testScenario.getMocks().get("makeCompositeRequest"))); + when(makeCompositeRequestMock.makePostRequest(any(), any())).thenReturn(createEventMockResponse); + + // Perform the request + String requestBody = objectMapper.writeValueAsString(testScenario.getInput().get("body")); + String url = "/api/v1/accounts/" + accountId + "/events"; + + ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders.post(url) + .cookie(new Cookie(CookieConstants.USER_LOGIN_COOKIE_NAME, cookieValue)) + .content(requestBody) + .contentType(MediaType.APPLICATION_JSON)); + + // Check the response + String expectedOutput = objectMapper.writeValueAsString(testScenario.getOutput()); + String actualOutput = resultActions.andReturn().getResponse().getContentAsString(); + + if (resultActions.andReturn().getResponse().getStatus() == 201) { + assertEquals(expectedOutput, actualOutput); + } + else { + common.compareErrors(testScenario, actualOutput); + } + } + + static Stream testScenariosProvider() throws IOException { + List testScenarios = loadScenarios(); + return testScenarios.stream(); + } + + private static List loadScenarios() throws IOException { + String scenariosPath = "classpath:data/functional/controllers/accountEventController/createAccountEvent.scenarios.json"; + Resource resource = new DefaultResourceLoader().getResource(scenariosPath); + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(resource.getInputStream(), new TypeReference>() { + }); + } + +} diff --git a/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/DeleteAccountEventTest.java b/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/DeleteAccountEventTest.java new file mode 100644 index 00000000..3bc8804e --- /dev/null +++ b/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/DeleteAccountEventTest.java @@ -0,0 +1,139 @@ +package com.salessparrow.api.functional.controllers.accountEventController; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; +import org.springframework.http.MediaType; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.dynamobee.exception.DynamobeeException; +import com.salessparrow.api.helper.Cleanup; +import com.salessparrow.api.helper.Common; +import com.salessparrow.api.helper.Constants; +import com.salessparrow.api.helper.FixtureData; +import com.salessparrow.api.helper.LoadFixture; +import com.salessparrow.api.helper.Scenario; +import com.salessparrow.api.helper.Setup; +import com.salessparrow.api.lib.globalConstants.CookieConstants; +import com.salessparrow.api.lib.httpLib.HttpClient.HttpResponse; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; + +import jakarta.servlet.http.Cookie; + +@SpringBootTest +@AutoConfigureMockMvc +@WebAppConfiguration +@Import({ Setup.class, Cleanup.class, Common.class, LoadFixture.class }) +public class DeleteAccountEventTest { + + @Autowired + private MockMvc mockMvc; + + @Autowired + private Common common; + + @Autowired + private LoadFixture loadFixture; + + @Autowired + private Setup setup; + + @Autowired + private Cleanup cleanup; + + @MockBean + private MakeCompositeRequest makeCompositeRequestMock; + + @BeforeEach + public void setUp() throws DynamobeeException { + setup.perform(); + } + + @AfterEach + public void tearDown() { + cleanup.perform(); + } + + @ParameterizedTest + @MethodSource("testScenariosProvider") + public void deleteAccountEvent(Scenario testScenario) throws Exception { + + // Load fixture data + String currentFunctionName = new Object() { + }.getClass().getEnclosingMethod().getName(); + FixtureData fixtureData = common.loadFixture( + "classpath:fixtures/functional/controllers/accountEventController/deleteAccountEvent.fixtures.json", + currentFunctionName); + loadFixture.perform(fixtureData); + + // Read data from the scenario + ObjectMapper objectMapper = new ObjectMapper(); + String cookieValue = Constants.SALESFORCE_ACTIVE_USER_COOKIE_VALUE; + String accountId = (String) testScenario.getInput().get("accountId"); + String eventId = (String) testScenario.getInput().get("eventId"); + + // Prepare mock responses + HttpResponse mockResponse = new HttpResponse(); + mockResponse + .setResponseBody(objectMapper.writeValueAsString(testScenario.getMocks().get("makeCompositeRequest"))); + when(makeCompositeRequestMock.makePostRequest(any(), any())).thenReturn(mockResponse); + + // Perform the request + String requestBody = objectMapper.writeValueAsString(testScenario.getInput().get("body")); + String url = "/api/v1/accounts/" + accountId + "/events/" + eventId; + + ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders.delete(url) + .cookie(new Cookie(CookieConstants.USER_LOGIN_COOKIE_NAME, cookieValue)) + .content(requestBody) + .contentType(MediaType.APPLICATION_JSON)); + + // Check the response + String expectedOutput = objectMapper.writeValueAsString(testScenario.getOutput()); + String actualOutput = resultActions.andReturn().getResponse().getContentAsString(); + + if (resultActions.andReturn().getResponse().getStatus() == 204) { + if (expectedOutput.equals("{}")) { + expectedOutput = ""; + } + assertEquals(expectedOutput, actualOutput); + } + else { + common.compareErrors(testScenario, actualOutput); + } + } + + static Stream testScenariosProvider() throws IOException { + List testScenarios = loadScenarios(); + return testScenarios.stream(); + } + + private static List loadScenarios() throws IOException { + String scenariosPath = "classpath:data/functional/controllers/accountEventController/deleteAccountEvent.scenarios.json"; + Resource resource = new DefaultResourceLoader().getResource(scenariosPath); + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(resource.getInputStream(), new TypeReference>() { + }); + } + +} diff --git a/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/GetAccountEventDetailsTest.java b/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/GetAccountEventDetailsTest.java new file mode 100644 index 00000000..cfa57c8d --- /dev/null +++ b/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/GetAccountEventDetailsTest.java @@ -0,0 +1,137 @@ +package com.salessparrow.api.functional.controllers.accountEventController; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; +import org.springframework.http.MediaType; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.dynamobee.exception.DynamobeeException; +import com.salessparrow.api.helper.Cleanup; +import com.salessparrow.api.helper.Common; +import com.salessparrow.api.helper.FixtureData; +import com.salessparrow.api.helper.LoadFixture; +import com.salessparrow.api.helper.Scenario; +import com.salessparrow.api.helper.Setup; +import com.salessparrow.api.lib.globalConstants.CookieConstants; +import com.salessparrow.api.helper.Constants; + +import com.salessparrow.api.lib.httpLib.HttpClient.HttpResponse; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; + +import jakarta.servlet.http.Cookie; + +@SpringBootTest +@AutoConfigureMockMvc +@WebAppConfiguration +@Import({ Setup.class, Cleanup.class, Common.class, LoadFixture.class }) +public class GetAccountEventDetailsTest { + + @Autowired + private MockMvc mockMvc; + + @Autowired + private Common common; + + @Autowired + private LoadFixture loadFixture; + + @Autowired + private Setup setup; + + @Autowired + private Cleanup cleanup; + + @MockBean + private MakeCompositeRequest makeCompositeRequestMock; + + @BeforeEach + public void setUp() throws DynamobeeException, IOException { + setup.perform(); + } + + @AfterEach + public void tearDown() { + cleanup.perform(); + } + + @ParameterizedTest + @MethodSource("testScenariosProvider") + public void getAccountEventDetails(Scenario testScenario) throws Exception { + // Load fixture data + String currentFunctionName = new Object() { + }.getClass().getEnclosingMethod().getName(); + FixtureData fixtureData = common.loadFixture( + "classpath:fixtures/functional/controllers/accountEventController/getAccountEventDetails.fixtures.json", + currentFunctionName); + loadFixture.perform(fixtureData); + + // Read data from the scenario + ObjectMapper objectMapper = new ObjectMapper(); + String cookieValue = Constants.SALESFORCE_ACTIVE_USER_COOKIE_VALUE; + String accountId = (String) testScenario.getInput().get("accountId"); + String eventId = (String) testScenario.getInput().get("eventId"); + + // Prepare mock responses + HttpResponse getEventsListMockResponse = new HttpResponse(); + getEventsListMockResponse + .setResponseBody(objectMapper.writeValueAsString(testScenario.getMocks().get("makeCompositeRequest"))); + when(makeCompositeRequestMock.makePostRequest(any(), any())).thenReturn(getEventsListMockResponse); + + // Perform the request + String url = "/api/v1/accounts/" + accountId + "/events/" + eventId; + + ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders.get(url) + .cookie(new Cookie(CookieConstants.USER_LOGIN_COOKIE_NAME, cookieValue)) + .contentType(MediaType.APPLICATION_JSON)); + + // Check the response + String expectedOutput = objectMapper.writeValueAsString(testScenario.getOutput()); + String actualOutput = resultActions.andReturn().getResponse().getContentAsString(); + + if (resultActions.andReturn().getResponse().getStatus() == 200) { + if (expectedOutput.equals("{}")) { + expectedOutput = ""; + } + assertEquals(expectedOutput, actualOutput); + } + else { + common.compareErrors(testScenario, actualOutput); + } + } + + static Stream testScenariosProvider() throws IOException { + List testScenarios = loadScenarios(); + return testScenarios.stream(); + } + + private static List loadScenarios() throws IOException { + String scenariosPath = "classpath:data/functional/controllers/accountEventController/getAccountEventDetails.scenarios.json"; + Resource resource = new DefaultResourceLoader().getResource(scenariosPath); + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(resource.getInputStream(), new TypeReference>() { + }); + } + +} diff --git a/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/GetAccountEventsListTest.java b/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/GetAccountEventsListTest.java new file mode 100644 index 00000000..4b0179d4 --- /dev/null +++ b/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/GetAccountEventsListTest.java @@ -0,0 +1,128 @@ +package com.salessparrow.api.functional.controllers.accountEventController; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; +import org.springframework.http.MediaType; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.dynamobee.exception.DynamobeeException; +import com.salessparrow.api.helper.Cleanup; +import com.salessparrow.api.helper.Common; +import com.salessparrow.api.helper.Constants; +import com.salessparrow.api.helper.FixtureData; +import com.salessparrow.api.helper.LoadFixture; +import com.salessparrow.api.helper.Scenario; +import com.salessparrow.api.helper.Setup; +import com.salessparrow.api.lib.globalConstants.CookieConstants; +import com.salessparrow.api.lib.httpLib.HttpClient.HttpResponse; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; + +import jakarta.servlet.http.Cookie; + +@SpringBootTest +@AutoConfigureMockMvc +@WebAppConfiguration +@Import({ Setup.class, Cleanup.class, Common.class, LoadFixture.class }) +public class GetAccountEventsListTest { + + @Autowired + private MockMvc mockMvc; + + @Autowired + private Common common; + + @Autowired + private LoadFixture loadFixture; + + @Autowired + private Setup setup; + + @Autowired + private Cleanup cleanup; + + @MockBean + private MakeCompositeRequest makeCompositeRequestMock; + + @BeforeEach + public void setUp() throws DynamobeeException { + setup.perform(); + } + + @AfterEach + public void tearDown() { + cleanup.perform(); + } + + @ParameterizedTest + @MethodSource("testScenariosProvider") + public void getAccountEventsList(Scenario testScenario) throws Exception { + + // Load fixture data + String currentFunctionName = new Object() { + }.getClass().getEnclosingMethod().getName(); + FixtureData fixtureData = common.loadFixture( + "classpath:fixtures/functional/controllers/accountEventController/getAccountEventsList.fixtures.json", + currentFunctionName); + loadFixture.perform(fixtureData); + + // Read data from the scenario + ObjectMapper objectMapper = new ObjectMapper(); + String cookieValue = Constants.SALESFORCE_ACTIVE_USER_COOKIE_VALUE; + String accountId = (String) testScenario.getInput().get("accountId"); + + // Prepare mock responses + HttpResponse getEventsListMockResponse = new HttpResponse(); + getEventsListMockResponse + .setResponseBody(objectMapper.writeValueAsString(testScenario.getMocks().get("makeCompositeRequest"))); + when(makeCompositeRequestMock.makePostRequest(any(), any())).thenReturn(getEventsListMockResponse); + + // Perform the request + String url = "/api/v1/accounts/" + accountId + "/events"; + + ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders.get(url) + .cookie(new Cookie(CookieConstants.USER_LOGIN_COOKIE_NAME, cookieValue)) + .contentType(MediaType.APPLICATION_JSON)); + + // Check the response + String expectedOutput = objectMapper.writeValueAsString(testScenario.getOutput()); + String actualOutput = resultActions.andReturn().getResponse().getContentAsString(); + + assertEquals(expectedOutput, actualOutput); + } + + static Stream testScenariosProvider() throws IOException { + List testScenarios = loadScenarios(); + return testScenarios.stream(); + } + + private static List loadScenarios() throws IOException { + String scenariosPath = "classpath:data/functional/controllers/accountEventController/getAccountEventsList.scenarios.json"; + Resource resource = new DefaultResourceLoader().getResource(scenariosPath); + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(resource.getInputStream(), new TypeReference>() { + }); + } + +} diff --git a/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/UpdateAccountEventTest.java b/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/UpdateAccountEventTest.java new file mode 100644 index 00000000..9b86179c --- /dev/null +++ b/src/test/java/com/salessparrow/api/functional/controllers/accountEventController/UpdateAccountEventTest.java @@ -0,0 +1,141 @@ +package com.salessparrow.api.functional.controllers.accountEventController; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; +import org.springframework.http.MediaType; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.dynamobee.exception.DynamobeeException; +import com.salessparrow.api.helper.Cleanup; +import com.salessparrow.api.helper.Common; +import com.salessparrow.api.helper.Constants; +import com.salessparrow.api.helper.FixtureData; +import com.salessparrow.api.helper.LoadFixture; +import com.salessparrow.api.helper.Scenario; +import com.salessparrow.api.helper.Setup; +import com.salessparrow.api.lib.globalConstants.CookieConstants; +import com.salessparrow.api.lib.httpLib.HttpClient.HttpResponse; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; + +import jakarta.servlet.http.Cookie; + +@SpringBootTest +@AutoConfigureMockMvc +@WebAppConfiguration +@Import({ Setup.class, Cleanup.class, Common.class, LoadFixture.class }) +public class UpdateAccountEventTest { + + @Autowired + private MockMvc mockMvc; + + @Autowired + private Common common; + + @Autowired + private LoadFixture loadFixture; + + @Autowired + private Setup setup; + + @Autowired + private Cleanup cleanup; + + @MockBean + private MakeCompositeRequest makeCompositeRequestMock; + + @BeforeEach + public void setUp() throws DynamobeeException { + setup.perform(); + } + + @AfterEach + public void tearDown() { + cleanup.perform(); + } + + @ParameterizedTest + @MethodSource("testScenariosProvider") + public void updateAccountEvent(Scenario testScenario) throws Exception { + + // Load fixture data + String currentFunctionName = new Object() { + }.getClass().getEnclosingMethod().getName(); + FixtureData fixtureData = common.loadFixture( + "classpath:fixtures/functional/controllers/accountEventController/updateAccountEvent.fixtures.json", + currentFunctionName); + loadFixture.perform(fixtureData); + + // Read data from the scenario + ObjectMapper objectMapper = new ObjectMapper(); + String cookieValue = Constants.SALESFORCE_ACTIVE_USER_COOKIE_VALUE; + String accountId = (String) testScenario.getInput().get("accountId"); + String eventId = (String) testScenario.getInput().get("eventId"); + + // Prepare mock responses + HttpResponse mockResponse = new HttpResponse(); + mockResponse + .setResponseBody(objectMapper.writeValueAsString(testScenario.getMocks().get("makeCompositeRequest"))); + when(makeCompositeRequestMock.makePostRequest(any(), any())).thenReturn(mockResponse); + + // Perform the request + String requestBody = objectMapper.writeValueAsString(testScenario.getInput().get("body")); + String url = "/api/v1/accounts/" + accountId + "/events/" + eventId; + + ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders.put(url) + .cookie(new Cookie(CookieConstants.USER_LOGIN_COOKIE_NAME, cookieValue)) + .content(requestBody) + .contentType(MediaType.APPLICATION_JSON)); + + // Check the response + String expectedOutput = objectMapper.writeValueAsString(testScenario.getOutput()); + String actualOutput = resultActions.andReturn().getResponse().getContentAsString(); + + Integer responseStatus = resultActions.andReturn().getResponse().getStatus(); + + if (responseStatus == 200 || responseStatus == 201 || responseStatus == 204) { + if (expectedOutput.equals("{}")) { + expectedOutput = ""; + } + assertEquals(expectedOutput, actualOutput); + } + else { + common.compareErrors(testScenario, actualOutput); + } + } + + static Stream testScenariosProvider() throws IOException { + List testScenarios = loadScenarios(); + return testScenarios.stream(); + } + + private static List loadScenarios() throws IOException { + String scenariosPath = "classpath:data/functional/controllers/accountEventController/updateAccountEvent.scenarios.json"; + Resource resource = new DefaultResourceLoader().getResource(scenariosPath); + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(resource.getInputStream(), new TypeReference>() { + }); + } + +} diff --git a/src/test/java/com/salessparrow/api/functional/controllers/accountNoteController/DeleteAccountNoteTest.java b/src/test/java/com/salessparrow/api/functional/controllers/accountNoteController/DeleteAccountNoteTest.java index 2c5d5cee..574fa4c7 100644 --- a/src/test/java/com/salessparrow/api/functional/controllers/accountNoteController/DeleteAccountNoteTest.java +++ b/src/test/java/com/salessparrow/api/functional/controllers/accountNoteController/DeleteAccountNoteTest.java @@ -1,6 +1,5 @@ package com.salessparrow.api.functional.controllers.accountNoteController; -import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; diff --git a/src/test/java/com/salessparrow/api/functional/controllers/accountNoteController/UpdateAccountNoteTest.java b/src/test/java/com/salessparrow/api/functional/controllers/accountNoteController/UpdateAccountNoteTest.java new file mode 100644 index 00000000..02dfd91f --- /dev/null +++ b/src/test/java/com/salessparrow/api/functional/controllers/accountNoteController/UpdateAccountNoteTest.java @@ -0,0 +1,141 @@ +package com.salessparrow.api.functional.controllers.accountNoteController; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; +import org.springframework.http.MediaType; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.dynamobee.exception.DynamobeeException; +import com.salessparrow.api.helper.Cleanup; +import com.salessparrow.api.helper.Common; +import com.salessparrow.api.helper.Constants; +import com.salessparrow.api.helper.FixtureData; +import com.salessparrow.api.helper.LoadFixture; +import com.salessparrow.api.helper.Scenario; +import com.salessparrow.api.helper.Setup; +import com.salessparrow.api.lib.globalConstants.CookieConstants; +import com.salessparrow.api.lib.httpLib.HttpClient.HttpResponse; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; + +import jakarta.servlet.http.Cookie; + +@SpringBootTest +@AutoConfigureMockMvc +@WebAppConfiguration +@Import({ Setup.class, Cleanup.class, Common.class, LoadFixture.class }) +public class UpdateAccountNoteTest { + + @Autowired + private MockMvc mockMvc; + + @Autowired + private Common common; + + @Autowired + private LoadFixture loadFixture; + + @Autowired + private Setup setup; + + @Autowired + private Cleanup cleanup; + + @MockBean + private MakeCompositeRequest makeCompositeRequestMock; + + @BeforeEach + public void setUp() throws DynamobeeException { + setup.perform(); + } + + @AfterEach + public void tearDown() { + cleanup.perform(); + } + + @ParameterizedTest + @MethodSource("testScenariosProvider") + public void updateAccountNote(Scenario testScenario) throws Exception { + + // Load fixture data + String currentFunctionName = new Object() { + }.getClass().getEnclosingMethod().getName(); + FixtureData fixtureData = common.loadFixture( + "classpath:fixtures/functional/controllers/accountNoteController/updateAccountNote.fixtures.json", + currentFunctionName); + loadFixture.perform(fixtureData); + + // Read data from the scenario + ObjectMapper objectMapper = new ObjectMapper(); + String cookieValue = Constants.SALESFORCE_ACTIVE_USER_COOKIE_VALUE; + String accountId = (String) testScenario.getInput().get("accountId"); + String noteId = (String) testScenario.getInput().get("noteId"); + + // Prepare mock responses + HttpResponse mockResponse = new HttpResponse(); + mockResponse + .setResponseBody(objectMapper.writeValueAsString(testScenario.getMocks().get("makeCompositeRequest"))); + when(makeCompositeRequestMock.makePostRequest(any(), any())).thenReturn(mockResponse); + + // Perform the request + String requestBody = objectMapper.writeValueAsString(testScenario.getInput().get("body")); + String url = "/api/v1/accounts/" + accountId + "/notes/" + noteId; + + ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders.put(url) + .cookie(new Cookie(CookieConstants.USER_LOGIN_COOKIE_NAME, cookieValue)) + .content(requestBody) + .contentType(MediaType.APPLICATION_JSON)); + + // Check the response + String expectedOutput = objectMapper.writeValueAsString(testScenario.getOutput()); + String actualOutput = resultActions.andReturn().getResponse().getContentAsString(); + + Integer responseStatus = resultActions.andReturn().getResponse().getStatus(); + + if (responseStatus == 200 || responseStatus == 201 || responseStatus == 204) { + if (expectedOutput.equals("{}")) { + expectedOutput = ""; + } + assertEquals(expectedOutput, actualOutput); + } + else { + common.compareErrors(testScenario, actualOutput); + } + } + + static Stream testScenariosProvider() throws IOException { + List testScenarios = loadScenarios(); + return testScenarios.stream(); + } + + private static List loadScenarios() throws IOException { + String scenariosPath = "classpath:data/functional/controllers/accountNoteController/updateAccountNote.scenarios.json"; + Resource resource = new DefaultResourceLoader().getResource(scenariosPath); + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(resource.getInputStream(), new TypeReference>() { + }); + } + +} diff --git a/src/test/java/com/salessparrow/api/functional/controllers/accountTaskController/GetAccountTaskDetailsTest.java b/src/test/java/com/salessparrow/api/functional/controllers/accountTaskController/GetAccountTaskDetailsTest.java new file mode 100644 index 00000000..bd814c91 --- /dev/null +++ b/src/test/java/com/salessparrow/api/functional/controllers/accountTaskController/GetAccountTaskDetailsTest.java @@ -0,0 +1,137 @@ +package com.salessparrow.api.functional.controllers.accountTaskController; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; +import org.springframework.http.MediaType; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.dynamobee.exception.DynamobeeException; +import com.salessparrow.api.helper.Cleanup; +import com.salessparrow.api.helper.Common; +import com.salessparrow.api.helper.FixtureData; +import com.salessparrow.api.helper.LoadFixture; +import com.salessparrow.api.helper.Scenario; +import com.salessparrow.api.helper.Setup; +import com.salessparrow.api.lib.globalConstants.CookieConstants; +import com.salessparrow.api.helper.Constants; + +import com.salessparrow.api.lib.httpLib.HttpClient.HttpResponse; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; + +import jakarta.servlet.http.Cookie; + +@SpringBootTest +@AutoConfigureMockMvc +@WebAppConfiguration +@Import({ Setup.class, Cleanup.class, Common.class, LoadFixture.class }) +public class GetAccountTaskDetailsTest { + + @Autowired + private MockMvc mockMvc; + + @Autowired + private Common common; + + @Autowired + private LoadFixture loadFixture; + + @Autowired + private Setup setup; + + @Autowired + private Cleanup cleanup; + + @MockBean + private MakeCompositeRequest makeCompositeRequestMock; + + @BeforeEach + public void setUp() throws DynamobeeException, IOException { + setup.perform(); + } + + @AfterEach + public void tearDown() { + cleanup.perform(); + } + + @ParameterizedTest + @MethodSource("testScenariosProvider") + public void getAccountTaskDetails(Scenario testScenario) throws Exception { + // Load fixture data + String currentFunctionName = new Object() { + }.getClass().getEnclosingMethod().getName(); + FixtureData fixtureData = common.loadFixture( + "classpath:fixtures/functional/controllers/accountTaskController/getAccountTaskDetails.fixtures.json", + currentFunctionName); + loadFixture.perform(fixtureData); + + // Read data from the scenario + ObjectMapper objectMapper = new ObjectMapper(); + String cookieValue = Constants.SALESFORCE_ACTIVE_USER_COOKIE_VALUE; + String accountId = (String) testScenario.getInput().get("accountId"); + String taskId = (String) testScenario.getInput().get("taskId"); + + // Prepare mock responses + HttpResponse getTasksListMockResponse = new HttpResponse(); + getTasksListMockResponse + .setResponseBody(objectMapper.writeValueAsString(testScenario.getMocks().get("makeCompositeRequest"))); + when(makeCompositeRequestMock.makePostRequest(any(), any())).thenReturn(getTasksListMockResponse); + + // Perform the request + String url = "/api/v1/accounts/" + accountId + "/tasks/" + taskId; + + ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders.get(url) + .cookie(new Cookie(CookieConstants.USER_LOGIN_COOKIE_NAME, cookieValue)) + .contentType(MediaType.APPLICATION_JSON)); + + // Check the response + String expectedOutput = objectMapper.writeValueAsString(testScenario.getOutput()); + String actualOutput = resultActions.andReturn().getResponse().getContentAsString(); + + if (resultActions.andReturn().getResponse().getStatus() == 200) { + if (expectedOutput.equals("{}")) { + expectedOutput = ""; + } + assertEquals(expectedOutput, actualOutput); + } + else { + common.compareErrors(testScenario, actualOutput); + } + } + + static Stream testScenariosProvider() throws IOException { + List testScenarios = loadScenarios(); + return testScenarios.stream(); + } + + private static List loadScenarios() throws IOException { + String scenariosPath = "classpath:data/functional/controllers/accountTaskController/getAccountTaskDetails.scenarios.json"; + Resource resource = new DefaultResourceLoader().getResource(scenariosPath); + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(resource.getInputStream(), new TypeReference>() { + }); + } + +} diff --git a/src/test/java/com/salessparrow/api/functional/controllers/accountTaskController/UpdateAccountTaskTest.java b/src/test/java/com/salessparrow/api/functional/controllers/accountTaskController/UpdateAccountTaskTest.java new file mode 100644 index 00000000..b7f6a1c2 --- /dev/null +++ b/src/test/java/com/salessparrow/api/functional/controllers/accountTaskController/UpdateAccountTaskTest.java @@ -0,0 +1,141 @@ +package com.salessparrow.api.functional.controllers.accountTaskController; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Import; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; +import org.springframework.http.MediaType; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.dynamobee.exception.DynamobeeException; +import com.salessparrow.api.helper.Cleanup; +import com.salessparrow.api.helper.Common; +import com.salessparrow.api.helper.Constants; +import com.salessparrow.api.helper.FixtureData; +import com.salessparrow.api.helper.LoadFixture; +import com.salessparrow.api.helper.Scenario; +import com.salessparrow.api.helper.Setup; +import com.salessparrow.api.lib.globalConstants.CookieConstants; +import com.salessparrow.api.lib.httpLib.HttpClient.HttpResponse; +import com.salessparrow.api.lib.salesforce.helper.MakeCompositeRequest; + +import jakarta.servlet.http.Cookie; + +@SpringBootTest +@AutoConfigureMockMvc +@WebAppConfiguration +@Import({ Setup.class, Cleanup.class, Common.class, LoadFixture.class }) +public class UpdateAccountTaskTest { + + @Autowired + private MockMvc mockMvc; + + @Autowired + private Common common; + + @Autowired + private LoadFixture loadFixture; + + @Autowired + private Setup setup; + + @Autowired + private Cleanup cleanup; + + @MockBean + private MakeCompositeRequest makeCompositeRequestMock; + + @BeforeEach + public void setUp() throws DynamobeeException { + setup.perform(); + } + + @AfterEach + public void tearDown() { + cleanup.perform(); + } + + @ParameterizedTest + @MethodSource("testScenariosProvider") + public void updateAccountTask(Scenario testScenario) throws Exception { + + // Load fixture data + String currentFunctionName = new Object() { + }.getClass().getEnclosingMethod().getName(); + FixtureData fixtureData = common.loadFixture( + "classpath:fixtures/functional/controllers/accountTaskController/updateAccountTask.fixtures.json", + currentFunctionName); + loadFixture.perform(fixtureData); + + // Read data from the scenario + ObjectMapper objectMapper = new ObjectMapper(); + String cookieValue = Constants.SALESFORCE_ACTIVE_USER_COOKIE_VALUE; + String accountId = (String) testScenario.getInput().get("accountId"); + String taskId = (String) testScenario.getInput().get("taskId"); + + // Prepare mock responses + HttpResponse mockResponse = new HttpResponse(); + mockResponse + .setResponseBody(objectMapper.writeValueAsString(testScenario.getMocks().get("makeCompositeRequest"))); + when(makeCompositeRequestMock.makePostRequest(any(), any())).thenReturn(mockResponse); + + // Perform the request + String requestBody = objectMapper.writeValueAsString(testScenario.getInput().get("body")); + String url = "/api/v1/accounts/" + accountId + "/tasks/" + taskId; + + ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders.put(url) + .cookie(new Cookie(CookieConstants.USER_LOGIN_COOKIE_NAME, cookieValue)) + .content(requestBody) + .contentType(MediaType.APPLICATION_JSON)); + + // Check the response + String expectedOutput = objectMapper.writeValueAsString(testScenario.getOutput()); + String actualOutput = resultActions.andReturn().getResponse().getContentAsString(); + + Integer responseStatus = resultActions.andReturn().getResponse().getStatus(); + + if (responseStatus == 200 || responseStatus == 201 || responseStatus == 204) { + if (expectedOutput.equals("{}")) { + expectedOutput = ""; + } + assertEquals(expectedOutput, actualOutput); + } + else { + common.compareErrors(testScenario, actualOutput); + } + } + + static Stream testScenariosProvider() throws IOException { + List testScenarios = loadScenarios(); + return testScenarios.stream(); + } + + private static List loadScenarios() throws IOException { + String scenariosPath = "classpath:data/functional/controllers/accountTaskController/updateAccountTask.scenarios.json"; + Resource resource = new DefaultResourceLoader().getResource(scenariosPath); + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(resource.getInputStream(), new TypeReference>() { + }); + } + +} diff --git a/src/test/java/com/salessparrow/api/helper/Constants.java b/src/test/java/com/salessparrow/api/helper/Constants.java index 0ad4b468..5e0cc281 100644 --- a/src/test/java/com/salessparrow/api/helper/Constants.java +++ b/src/test/java/com/salessparrow/api/helper/Constants.java @@ -5,6 +5,6 @@ */ public class Constants { - public static final String SALESFORCE_ACTIVE_USER_COOKIE_VALUE = "1:0055i00000AUxQHAA1:SALESFORCE:app:1692878227:a2xOxjcPChK/YsKCWRuY50J3gH21/tqcGlv7sWU/aPw3/UFVFPbvWn2LLzY5B5kVPXjj1gELRqa4B4ds6uuqIw=="; + public static final String SALESFORCE_ACTIVE_USER_COOKIE_VALUE = "1:0055i00000AUxQHAA1:SALESFORCE:app:1702978227:3sYUB9JUTxtN1ETSlAMgTio66GodR6cGTb/gEcXWGzBcQ4D3YlaiFxq1xFv3Hnd8McSILBnVIcjI88HW+yL3Hw=="; } diff --git a/src/test/resources/data/controllers/eventController/createEvent.scenarios.json b/src/test/resources/data/controllers/eventController/createEvent.scenarios.json new file mode 100644 index 00000000..0463c4b7 --- /dev/null +++ b/src/test/resources/data/controllers/eventController/createEvent.scenarios.json @@ -0,0 +1,244 @@ +[ + { + "description": "Should successfully create the event", + "input": { + "body": { + "description": "Here the event description will go and it is a long description with length of more than 100 characters", + "start_datetime": "2023-07-21T13:12:17.000+0000", + "end_datetime": "2023-07-21T14:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": { + "id": "00U1e000003ToABEA0", + "success": true, + "errors": [] + }, + "httpHeaders": { + "Location": "/services/data/v58.0/sobjects/Event/00U1e000003ToABEA0" + }, + "httpStatusCode": 201, + "referenceId": "createEvent" + } + ] + } + }, + "output": { + "event_id": "00U1e000003ToABEA0" + } + }, + { + "description": "Should fail when the event description is empty", + "input": { + "body": { + "description": "", + "start_datetime": "2023-07-21T13:12:17.000+0000", + "end_datetime": "2023-07-21T14:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + { + "parameter": "description", + "param_error_identifier": "missing_description", + "message": "description is required parameter. Please provide description." + } + ] + } + }, + { + "description": "Should fail when the event description is not provided", + "input": { + "body": { + "start_datetime": "2023-07-21T13:12:17.000+0000", + "end_datetime": "2023-07-21T14:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + { + "parameter": "description", + "param_error_identifier": "missing_description", + "message": "description is required parameter. Please provide description." + } + ] + } + }, + { + "description": "Should fail when the event start_datetime is not provided", + "input": { + "body": { + "description":"Test Description", + "end_datetime": "2023-07-21T14:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + { + "parameter": "description", + "param_error_identifier": "missing_description", + "message": "description is required parameter. Please provide description." + } + ] + } + }, + { + "description": "Should fail when the event end_datetime is not provided", + "input": { + "body": { + "description":"Test Description", + "start_datetime": "2023-07-21T13:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + { + "parameter": "description", + "param_error_identifier": "missing_description", + "message": "description is required parameter. Please provide description." + } + ] + } + }, + { + "description": "Should fail when incorrect start_datetime format is provided", + "input": { + "body": { + "description":"Test Description", + "start_datetime": "07-2023-21T13:12:17.000+0000", + "end_datetime": "2023-07-21T14:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "Invalid datetime format.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + { + "parameter": "start_datetime", + "param_error_identifier": "invalid_datetime_format", + "message": "start_datetime is invalid. Please provide valid datetime format." + } + ] + } + }, + { + "description": "Should fail when incorrect end_datetime format is provided", + "input": { + "body": { + "description":"Test Description", + "start_datetime": "2023-07-21T14:12:17.000+0000", + "end_datetime": "07-2023-21T13:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "Invalid datetime format.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + { + "parameter": "end_datetime", + "param_error_identifier": "invalid_datetime_format", + "message": "Please provide valid datetime format." + } + ] + } + }, + { + "description": "Should fail when the account id invalid", + "input": { + "body": { + "description": "Here the event description will go and it is a long description with length of more than 100 characters", + "start_datetime": "2023-07-21T13:12:17.000+0000", + "end_datetime": "2023-07-21T14:12:17.000+0000" + }, + "accountId": "invalid" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": [ + { + "message": "Related To ID: id value of incorrect type: invalid", + "errorCode": "MALFORMED_ID", + "fields": [ + "WhatId" + ] + } + ], + "httpHeaders": {}, + "httpStatusCode": 400, + "referenceId": "createEvent" + } + ] + } + }, + "output": { + "http_code": 500, + "message": "Something went wrong.", + "code": "INTERNAL_SERVER_ERROR", + "internal_error_identifier": "l_ca_ce_cse_pr_1", + "param_errors": [] + } + }, + { + "description": "Should fail when description length is greater than 32000 characters", + "input": { + "body": { + "description":"Test Description to be extended in code upto more than 32000 characters", + "start_datetime": "2023-07-21T14:12:17.000+0000", + "end_datetime": "2023-07-21T14:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "Invalid datetime format.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + { + "parameter": "end_datetime", + "param_error_identifier": "invalid_datetime_format", + "message": "Please provide valid datetime format." + } + ] + } + } +] \ No newline at end of file diff --git a/src/test/resources/data/functional/controllers/accountController/getNoteDetails.scenarios.json b/src/test/resources/data/functional/controllers/accountController/getNoteDetails.scenarios.json index b2359c95..57766053 100644 --- a/src/test/resources/data/functional/controllers/accountController/getNoteDetails.scenarios.json +++ b/src/test/resources/data/functional/controllers/accountController/getNoteDetails.scenarios.json @@ -44,7 +44,7 @@ "note_detail": { "id": "0691e000001WY58AAG", "creator": "Ashfaq Bhojani", - "text": "\"

Let's use plural routes and have accountId in URL as per the API Convention.\\n/v1/account/content-notes => /v1/salesforce/accounts/{accountId}/content-notes\\n/v1/composite is generic. It can be under a salesforce route.\\n/v1/composite => /v1/salesforce/composite\\nQuestion:TextPreview in content notes response is a truncated version of the full text in notes?She suspicion dejection saw instantly. Well deny may real one told yet saw hard dear. Bed chief house rapid right the. Set noisy one state tears which. No girl oh part must fact high my he. Simplicity in excellence melancholy as remarkably discovered. Own partiality motionless was old excellence she inquietude contrasted. Sister giving so wicket cousin of an he rather marked. Of on game part body rich. Adapted mr savings venture it or comfort affixed friends.Prepared is me marianne pleasure likewise debating. Wonder an unable except better stairs do ye admire. His and eat secure sex called esteem praise. So moreover as speedily differed branched ignorant. Tall are her knew poor now does then. Procured to contempt oh he raptures amounted occasion. One boy assure income spirit lovers set.Passage its ten led hearted removal cordial. Preference any astonished unreserved mrs. Prosperous understood middletons in conviction an uncommonly do. Supposing so be resolving breakfast am or perfectly. Is drew am hill from mr. Valley by oh twenty direct me so. Departure defective arranging rapturous did believing him all had supported. Family months lasted simple set nature vulgar him. Picture for attempt joy excited ten carried manners talking how. Suspicion neglected he resolving agreement perceived at an.Dashwood contempt on mr unlocked resolved provided of of. Stanhill wondered it it welcomed oh. Hundred no prudent he however smiling at an offence. If earnestly extremity he he propriety something admitting convinced ye. Pleasant in to although as if differed horrible. Mirth his quick its set front enjoy hoped had there. Who connection imprudence middletons too but increasing celebrated principles joy. Herself too improve gay winding ask expense are compact. New all paid few hard pure she.That know ask case sex ham dear her spot. Weddings followed the all marianne nor whatever settling. Perhaps six prudent several her had offence. Did had way law dinner square tastes. Recommend concealed yet her procuring see consulted depending. Adieu

\"", + "text": "\"

Let's use plural routes and have accountId in URL as per the API Convention.\\n/v1/account/content-notes => /v1/salesforce/accounts/{accountId}/content-notes\\n/v1/composite is generic. It can be under a salesforce route.\\n/v1/composite => /v1/salesforce/composite\\nQuestion:TextPreview in content notes response is a truncated version of the full text in notes?She suspicion dejection saw instantly. Well deny may real one told yet saw hard dear. Bed chief house rapid right the. Set noisy one state tears which. No girl oh part must fact high my he. Simplicity in excellence melancholy as remarkably discovered. Own partiality motionless was old excellence she inquietude contrasted. Sister giving so wicket cousin of an he rather marked. Of on game part body rich. Adapted mr savings venture it or comfort affixed friends.Prepared is me marianne pleasure likewise debating. Wonder an unable except better stairs do ye admire. His and eat secure sex called esteem praise. So moreover as speedily differed branched ignorant. Tall are her knew poor now does then. Procured to contempt oh he raptures amounted occasion. One boy assure income spirit lovers set.Passage its ten led hearted removal cordial. Preference any astonished unreserved mrs. Prosperous understood middletons in conviction an uncommonly do. Supposing so be resolving breakfast am or perfectly. Is drew am hill from mr. Valley by oh twenty direct me so. Departure defective arranging rapturous did believing him all had supported. Family months lasted simple set nature vulgar him. Picture for attempt joy excited ten carried manners talking how. Suspicion neglected he resolving agreement perceived at an.Dashwood contempt on mr unlocked resolved provided of of. Stanhill wondered it it welcomed oh. Hundred no prudent he however smiling at an offence. If earnestly extremity he he propriety something admitting convinced ye. Pleasant in to although as if differed horrible. Mirth his quick its set front enjoy hoped had there. Who connection imprudence middletons too but increasing celebrated principles joy. Herself too improve gay winding ask expense are compact. New all paid few hard pure she.That know ask case sex ham dear her spot. Weddings followed the all marianne nor whatever settling. Perhaps six prudent several her had offence. Did had way law dinner square tastes. Recommend concealed yet her procuring see consulted depending. Adieu

\"", "last_modified_time": "2023-08-01T10:38:23.000+00:00" } } diff --git a/src/test/resources/data/functional/controllers/accountEventController/createAccountEvent.scenarios.json b/src/test/resources/data/functional/controllers/accountEventController/createAccountEvent.scenarios.json new file mode 100644 index 00000000..b78e6953 --- /dev/null +++ b/src/test/resources/data/functional/controllers/accountEventController/createAccountEvent.scenarios.json @@ -0,0 +1,176 @@ +[ + { + "description": "Should successfully create the event", + "input": { + "body": { + "description":"Create Event", + "start_datetime": "2023-07-21T13:12:17.000+0000", + "end_datetime": "2023-07-22T13:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": { + "id": "00T1e000007mDA7EAM", + "success": true, + "errors": [] + }, + "httpHeaders": { + "Location": "/services/data/v58.0/sobjects/Event/00T1e000007mDA7EAM" + }, + "httpStatusCode": 201, + "referenceId": "CreateEvent" + } + ] + } + }, + "output": { + "event_id": "00T1e000007mDA7EAM" + } + }, + { + "description": "Should fail when the event description is empty", + "input": { + "body": { + "description":"", + "start_datetime": "2023-07-21T13:12:17.000+0000", + "end_datetime": "2023-07-22T13:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + "missing_description" + ] + } + }, + { + "description": "Should fail when event task description is not provided", + "input": { + "body": { + "start_datetime": "2023-07-21T13:12:17.000+0000", + "end_datetime": "2023-07-22T13:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + "missing_description" + ] + } + }, + { + "description": "Should fail when the event start_datetime is invalid", + "input": { + "body": { + "description":"Create Event", + "start_datetime": "2023-07-21", + "end_datetime": "2023-07-22T13:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + "invalid_start_datetime" + ] + } + }, + { + "description": "Should fail when the event end_datetime is invalid", + "input": { + "body": { + "description":"Create Event", + "start_datetime": "2023-07-22T13:12:17.000+0000", + "end_datetime": "2023-07-22T13:12.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + "invalid_end_datetime" + ] + } + }, + { + "description": "Should fail when the event description is too long", + "input": { + "body": { + "description":"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi. Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci. Phasellus consectetuer vestibulum elit. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Vestibulum fringilla pede sit amet augue. In turpis. Pellentesque posuere. Praesent turpis. Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus. Ut varius tincidunt libero. Phasellus dolor. Maecenas vestibulum mollis diam. Pellentesque ut neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. In ac felis quis tortor malesuada pretium. Pellentesque auctor neque nec urna. Proin sapien ipsum, porta a, auctor quis, euismod ut, mi. Aenean viverra rhoncus pede. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut non enim eleifend felis pretium feugiat. Vivamus quis mi. Phasellus a est. Phasellus magna. In hac habitasse platea dictumst. Curabitur at lacus ac velit ornare lobortis. Curabitur a felis in nunc fringilla tristique. Morbi mattis ullamcorper velit. Phasellus gravida semper nisi. Nullam vel sem. Pellentesque libero tortor, tincidunt et, tincidunt eget, semper nec, quam. Sed hendrerit. Morbi ac felis. Nunc egestas, augue at pellentesque laoreet, felis eros vehicula leo, at malesuada velit leo quis pede. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Nunc nulla. Fusce risus nisl, viverra et, tempor et, pretium in, sapien. Donec venenatis vulputate lorem. Morbi nec metus. Phasellus blandit leo ut odio. Maecenas ullamcorper, dui et placerat feugiat, eros pede varius nisi, condimentum viverra felis nunc et lorem. Sed magna purus, fermentum eu, tincidunt eu, varius ut, felis. In auctor lobortis lacus. Quisque libero metus, condimentum nec, tempor a, commodo mollis, magna. Vestibulum ullamcorper mauris at ligula. Fusce fermentum. Nullam cursus lacinia erat. Praesent blandit laoreet nibh. Fusce convallis metus id felis luctus adipiscing. Pellentesque egestas, neque sit amet convallis pulvinar, justo nulla eleifend augue, ac auctor orci leo non est. Quisque id mi. Ut tincidunt tincidunt erat. Etiam feugiat lorem non metus. Vestibulum dapibus nunc ac augue. Curabitur vestibulum aliquam leo. Praesent egestas neque eu enim. In hac habitasse platea dictumst. Fusce a quam. Etiam ut purus mattis mauris sodales aliquam. Curabitur nisi. Quisque malesuada placerat nisl. Nam ipsum risus, rutrum vitae, vestibulum eu, molestie vel, lacus. Sed augue ipsum, egestas nec, vestibulum et, malesuada adipiscing, dui. Vestibulum facilisis, purus nec pulvinar iaculis, ligula mi congue nunc, vitae euismod ligula urna in dolor. Mauris sollicitudin fermentum libero. Praesent nonummy mi in odio. Nunc interdum lacus sit amet orci. Vestibulum rutrum, mi nec elementum vehicula, eros quam gravida nisl, id fringilla neque ante vel mi. Morbi mollis tellus ac sapien. Phasellus volutpat, metus eget egestas mollis, lacus lacus blandit dui, id egestas quam mauris ut lacus. Fusce vel dui. Sed in libero ut nibh placerat accumsan. Proin faucibus arcu quis ante. In consectetuer turpis ut velit. Nulla sit amet est. Praesent metus tellus, elementum eu, semper a, adipiscing nec, purus. Cras risus ipsum, faucibus ut, ullamcorper id, varius ac, leo. Suspendisse feugiat. Suspendisse enim turpis, dictum sed, iaculis a, condimentum nec, nisi. Praesent nec nisl a purus blandit viverra. Praesent ac massa at ligula laoreet iaculis. Nulla neque dolor, sagittis eget, iaculis quis, molestie non, velit. Mauris turpis nunc, blandit et, volutpat molestie, porta ut, ligula. Fusce pharetra convallis urna. Quisque ut nisi. Donec mi odio, faucibus at, scelerisque quis, convallis in, nisi. Suspendisse non nisl sit amet velit hendrerit rutrum. Ut leo. Ut a nisl id ante tempus hendrerit. Proin pretium, leo ac pellentesque mollis, felis nunc ultrices eros, sed gravida augue augue mollis justo. Suspendisse eu ligula. Nulla facilisi. Donec id justo. Praesent porttitor, nulla vitae posuere iaculis, arcu nisl dignissim dolor, a pretium mi sem ut ipsum. Curabitur suscipit suscipit tellus. Praesent vestibulum dapibus nibh. Etiam iaculis nunc ac metus. Ut id nisl quis enim dignissim sagittis. Etiam sollicitudin, ipsum eu pulvinar rutrum, tellus ipsum laoreet sapien, quis venenatis ante odio sit amet eros. Proin magna. Duis vel nibh at velit scelerisque suscipit. Curabitur turpis. Vestibulum suscipit nulla quis orci. Fusce ac felis sit amet ligula pharetra condimentum. Maecenas egestas arcu quis ligula mattis placerat. Duis lobortis massa imperdiet quam. Suspendisse potenti. Pellentesque commodo eros a enim. Vestibulum turpis sem, aliquet eget, lobortis pellentesque, rutrum eu, nisl. Sed libero. Aliquam erat volutpat. Etiam vitae tortor. Morbi vestibulum volutpat enim. Aliquam eu nunc. Nunc sed turpis. Sed mollis, eros et ultrices tempus, mauris ipsum aliquam libero, non adipiscing dolor urna a orci. Nulla porta dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Pellentesque dapibus hendrerit tortor. Praesent egestas tristique nibh. Sed a libero. Cras varius. Donec vitae orci sed dolor rutrum auctor. Fusce egestas elit eget lorem. Suspendisse nisl elit, rhoncus eget, elementum ac, condimentum eget, diam. Nam at tortor in tellus interdum sagittis. Aliquam lobortis. Donec orci lectus, aliquam ut, faucibus non, euismod id, nulla. Curabitur blandit mollis lacus. Nam adipiscing. Vestibulum eu odio. Vivamus laoreet. Nullam tincidunt adipiscing enim. Phasellus tempus. Proin viverra, ligula sit amet ultrices semper, ligula arcu tristique sapien, a accumsan nisi mauris ac eros. Fusce neque. Suspendisse faucibus, nunc et pellentesque egestas, lacus ante convallis tellus, vitae iaculis lacus elit id tortor. Vivamus aliquet elit ac nisl. Fusce fermentum odio nec arcu. Vivamus euismod mauris. In ut quam vitae odio lacinia tincidunt. Praesent ut ligula non mi varius sagittis. Cras sagittis. Praesent ac sem eget est egestas volutpat. Vivamus consectetuer hendrerit lacus. Cras non dolor. Vivamus in erat ut urna cursus vestibulum. Fusce commodo aliquam arcu. Nam commodo suscipit quam. Quisque id odio. Praesent venenatis metus at tortor pulvinar varius. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi. Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci. Phasellus consectetuer vestibulum elit. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Vestibulum fringilla pede sit amet augue. In turpis. Pellentesque posuere. Praesent turpis. Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus. Ut varius tincidunt libero. Phasellus dolor. Maecenas vestibulum mollis diam. Pellentesque ut neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. In ac felis quis tortor malesuada pretium. Pellentesque auctor neque nec urna. Proin sapien ipsum, porta a, auctor quis, euismod ut, mi. Aenean viverra rhoncus pede. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut non enim eleifend felis pretium feugiat. Vivamus quis mi. Phasellus a est. Phasellus magna. In hac habitasse platea dictumst. Curabitur at lacus ac velit ornare lobortis. Curabitur a felis in nunc fringilla tristique. Morbi mattis ullamcorper velit. Phasellus gravida semper nisi. Nullam vel sem. Pellentesque libero tortor, tincidunt et, tincidunt eget, semper nec, quam. Sed hendrerit. Morbi ac felis. Nunc egestas, augue at pellentesque laoreet, felis eros vehicula leo, at malesuada velit leo quis pede. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Nunc nulla. Fusce risus nisl, viverra et, tempor et, pretium in, sapien. Donec venenatis vulputate lorem. Morbi nec metus. Phasellus blandit leo ut odio. Maecenas ullamcorper, dui et placerat feugiat, eros pede varius nisi, condimentum viverra felis nunc et lorem. Sed magna purus, fermentum eu, tincidunt eu, varius ut, felis. In auctor lobortis lacus. Quisque libero metus, condimentum nec, tempor a, commodo mollis, magna. Vestibulum ullamcorper mauris at ligula. Fusce fermentum. Nullam cursus lacinia erat. Praesent blandit laoreet nibh. Fusce convallis metus id felis luctus adipiscing. Pellentesque egestas, neque sit amet convallis pulvinar, justo nulla eleifend augue, ac auctor orci leo non est. Quisque id mi. Ut tincidunt tincidunt erat. Etiam feugiat lorem non metus. Vestibulum dapibus nunc ac augue. Curabitur vestibulum aliquam leo. Praesent egestas neque eu enim. In hac habitasse platea dictumst. Fusce a quam. Etiam ut purus mattis mauris sodales aliquam. Curabitur nisi. Quisque malesuada placerat nisl. Nam ipsum risus, rutrum vitae, vestibulum eu, molestie vel, lacus. Sed augue ipsum, egestas nec, vestibulum et, malesuada adipiscing, dui. Vestibulum facilisis, purus nec pulvinar iaculis, ligula mi congue nunc, vitae euismod ligula urna in dolor. Mauris sollicitudin fermentum libero. Praesent nonummy mi in odio. Nunc interdum lacus sit amet orci. Vestibulum rutrum, mi nec elementum vehicula, eros quam gravida nisl, id fringilla neque ante vel mi. Morbi mollis tellus ac sapien. Phasellus volutpat, metus eget egestas mollis, lacus lacus blandit dui, id egestas quam mauris ut lacus. Fusce vel dui. Sed in libero ut nibh placerat accumsan. Proin faucibus arcu quis ante. In consectetuer turpis ut velit. Nulla sit amet est. Praesent metus tellus, elementum eu, semper a, adipiscing nec, purus. Cras risus ipsum, faucibus ut, ullamcorper id, varius ac, leo. Suspendisse feugiat. Suspendisse enim turpis, dictum sed, iaculis a, condimentum nec, nisi. Praesent nec nisl a purus blandit viverra. Praesent ac massa at ligula laoreet iaculis. Nulla neque dolor, sagittis eget, iaculis quis, molestie non, velit. Mauris turpis nunc, blandit et, volutpat molestie, porta ut, ligula. Fusce pharetra convallis urna. Quisque ut nisi. Donec mi odio, faucibus at, scelerisque quis, convallis in, nisi. Suspendisse non nisl sit amet velit hendrerit rutrum. Ut leo. Ut a nisl id ante tempus hendrerit. Proin pretium, leo ac pellentesque mollis, felis nunc ultrices eros, sed gravida augue augue mollis justo. Suspendisse eu ligula. Nulla facilisi. Donec id justo. Praesent porttitor, nulla vitae posuere iaculis, arcu nisl dignissim dolor, a pretium mi sem ut ipsum. Curabitur suscipit suscipit tellus. Praesent vestibulum dapibus nibh. Etiam iaculis nunc ac metus. Ut id nisl quis enim dignissim sagittis. Etiam sollicitudin, ipsum eu pulvinar rutrum, tellus ipsum laoreet sapien, quis venenatis ante odio sit amet eros. Proin magna. Duis vel nibh at velit scelerisque suscipit. Curabitur turpis. Vestibulum suscipit nulla quis orci. Fusce ac felis sit amet ligula pharetra condimentum. Maecenas egestas arcu quis ligula mattis placerat. Duis lobortis massa imperdiet quam. Suspendisse potenti. Pellentesque commodo eros a enim. Vestibulum turpis sem, aliquet eget, lobortis pellentesque, rutrum eu, nisl. Sed libero. Aliquam erat volutpat. Etiam vitae tortor. Morbi vestibulum volutpat enim. Aliquam eu nunc. Nunc sed turpis. Sed mollis, eros et ultrices tempus, mauris ipsum aliquam libero, non adipiscing dolor urna a orci. Nulla porta dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Pellentesque dapibus hendrerit tortor. Praesent egestas tristique nibh. Sed a libero. Cras varius. Donec vitae orci sed dolor rutrum auctor. Fusce egestas elit eget lorem. Suspendisse nisl elit, rhoncus eget, elementum ac, condimentum eget, diam. Nam at tortor in tellus interdum sagittis. Aliquam lobortis. Donec orci lectus, aliquam ut, faucibus non, euismod id, nulla. Curabitur blandit mollis lacus. Nam adipiscing. Vestibulum eu odio. Vivamus laoreet. Nullam tincidunt adipiscing enim. Phasellus tempus. Proin viverra, ligula sit amet ultrices semper, ligula arcu tristique sapien, a accumsan nisi mauris ac eros. Fusce neque. Suspendisse faucibus, nunc et pellentesque egestas, lacus ante convallis tellus, vitae iaculis lacus elit id tortor. Vivamus aliquet elit ac nisl. Fusce fermentum odio nec arcu. Vivamus euismod mauris. In ut quam vitae odio lacinia tincidunt. Praesent ut ligula non mi varius sagittis. Cras sagittis. Praesent ac sem eget est egestas volutpat. Vivamus consectetuer hendrerit lacus. Cras non dolor. Vivamus in erat ut urna cursus vestibulum. Fusce commodo aliquam arcu. Nam commodo suscipit quam. Quisque id odio. Praesent venenatis metus at tortor pulvinar varius. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi. Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci. Phasellus consectetuer vestibulum elit. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Vestibulum fringilla pede sit amet augue. In turpis. Pellentesque posuere. Praesent turpis. Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus. Ut varius tincidunt libero. Phasellus dolor. Maecenas vestibulum mollis diam. Pellentesque ut neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. In ac felis quis tortor malesuada pretium. Pellentesque auctor neque nec urna. Proin sapien ipsum, porta a, auctor quis, euismod ut, mi. Aenean viverra rhoncus pede. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut non enim eleifend felis pretium feugiat. Vivamus quis mi. Phasellus a est. Phasellus magna. In hac habitasse platea dictumst. Curabitur at lacus ac velit ornare lobortis. Curabitur a felis in nunc fringilla tristique. Morbi mattis ullamcorper velit. Phasellus gravida semper nisi. Nullam vel sem. Pellentesque libero tortor, tincidunt et, tincidunt eget, semper nec, quam. Sed hendrerit. Morbi ac felis. Nunc egestas, augue at pellentesque laoreet, felis eros vehicula leo, at malesuada velit leo quis pede. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Nunc nulla. Fusce risus nisl, viverra et, tempor et, pretium in, sapien. Donec venenatis vulputate lorem. Morbi nec metus. Phasellus blandit leo ut odio. Maecenas ullamcorper, dui et placerat feugiat, eros pede varius nisi, condimentum viverra felis nunc et lorem. Sed magna purus, fermentum eu, tincidunt eu, varius ut, felis. In auctor lobortis lacus. Quisque libero metus, condimentum nec, tempor a, commodo mollis, magna. Vestibulum ullamcorper mauris at ligula. Fusce fermentum. Nullam cursus lacinia erat. Praesent blandit laoreet nibh. Fusce convallis metus id felis luctus adipiscing. Pellentesque egestas, neque sit amet convallis pulvinar, justo nulla eleifend augue, ac auctor orci leo non est. Quisque id mi. Ut tincidunt tincidunt erat. Etiam feugiat lorem non metus. Vestibulum dapibus nunc ac augue. Curabitur vestibulum aliquam leo. Praesent egestas neque eu enim. In hac habitasse platea dictumst. Fusce a quam. Etiam ut purus mattis mauris sodales aliquam. Curabitur nisi. Quisque malesuada placerat nisl. Nam ipsum risus, rutrum vitae, vestibulum eu, molestie vel, lacus. Sed augue ipsum, egestas nec, vestibulum et, malesuada adipiscing, dui. Vestibulum facilisis, purus nec pulvinar iaculis, ligula mi congue nunc, vitae euismod ligula urna in dolor. Mauris sollicitudin fermentum libero. Praesent nonummy mi in odio. Nunc interdum lacus sit amet orci. Vestibulum rutrum, mi nec elementum vehicula, eros quam gravida nisl, id fringilla neque ante vel mi. Morbi mollis tellus ac sapien. Phasellus volutpat, metus eget egestas mollis, lacus lacus blandit dui, id egestas quam mauris ut lacus. Fusce vel dui. Sed in libero ut nibh placerat accumsan. Proin faucibus arcu quis ante. In consectetuer turpis ut velit. Nulla sit amet est. Praesent metus tellus, elementum eu, semper a, adipiscing nec, purus. Cras risus ipsum, faucibus ut, ullamcorper id, varius ac, leo. Suspendisse feugiat. Suspendisse enim turpis, dictum sed, iaculis a, condimentum nec, nisi. Praesent nec nisl a purus blandit viverra. Praesent ac massa at ligula laoreet iaculis. Nulla neque dolor, sagittis eget, iaculis quis, molestie non, velit. Mauris turpis nunc, blandit et, volutpat molestie, porta ut, ligula. Fusce pharetra convallis urna. Quisque ut nisi. Donec mi odio, faucibus at, scelerisque quis, convallis in, nisi. Suspendisse non nisl sit amet velit hendrerit rutrum. Ut leo. Ut a nisl id ante tempus hendrerit. Proin pretium, leo ac pellentesque mollis, felis nunc ultrices eros, sed gravida augue augue mollis justo. Suspendisse eu ligula. Nulla facilisi. Donec id justo. Praesent porttitor, nulla vitae posuere iaculis, arcu nisl dignissim dolor, a pretium mi sem ut ipsum. Curabitur suscipit suscipit tellus. Praesent vestibulum dapibus nibh. Etiam iaculis nunc ac metus. Ut id nisl quis enim dignissim sagittis. Etiam sollicitudin, ipsum eu pulvinar rutrum, tellus ipsum laoreet sapien, quis venenatis ante odio sit amet eros. Proin magna. Duis vel nibh at velit scelerisque suscipit. Curabitur turpis. Vestibulum suscipit nulla quis orci. Fusce ac felis sit amet ligula pharetra condimentum. Maecenas egestas arcu quis ligula mattis placerat. Duis lobortis massa imperdiet quam. Suspendisse potenti. Pellentesque commodo eros a enim. Vestibulum turpis sem, aliquet eget, lobortis pellentesque, rutrum eu, nisl. Sed libero. Aliquam erat volutpat. Etiam vitae tortor. Morbi vestibulum volutpat enim. Aliquam eu nunc. Nunc sed turpis. Sed mollis, eros et ultrices tempus, mauris ipsum aliquam libero, non adipiscing dolor urna a orci. Nulla porta dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Pellentesque dapibus hendrerit tortor. Praesent egestas tristique nibh. Sed a libero. Cras varius. Donec vitae orci sed dolor rutrum auctor. Fusce egestas elit eget lorem. Suspendisse nisl elit, rhoncus eget, elementum ac, condimentum eget, diam. Nam at tortor in tellus interdum sagittis. Aliquam lobortis. Donec orci lectus, aliquam ut, faucibus non, euismod id, nulla. Curabitur blandit mollis lacus. Nam adipiscing. Vestibulum eu odio. Vivamus laoreet. Nullam tincidunt adipiscing enim. Phasellus tempus. Proin viverra, ligula sit amet ultrices semper, ligula arcu tristique sapien, a accumsan nisi mauris ac eros. Fusce neque. Suspendisse faucibus, nunc et pellentesque egestas, lacus ante convallis tellus, vitae iaculis lacus elit id tortor. Vivamus aliquet elit ac nisl. Fusce fermentum odio nec arcu. Vivamus euismod mauris. In ut quam vitae odio lacinia tincidunt. Praesent ut ligula non mi varius sagittis. Cras sagittis. Praesent ac sem eget est egestas volutpat. Vivamus consectetuer hendrerit lacus. Cras non dolor. Vivamus in erat ut urna cursus vestibulum. Fusce commodo aliquam arcu. Nam commodo suscipit quam. Quisque id odio. Praesent venenatis metus at tortor pulvinar varius. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi. Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci. Phasellus consectetuer vestibulum elit. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Vestibulum fringilla pede sit amet augue. In turpis. Pellentesque posuere. Praesent turpis. Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus. Ut varius tincidunt libero. Phasellus dolor. Maecenas vestibulum mollis diam. Pellentesque ut neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. In ac felis quis tortor malesuada pretium. Pellentesque auctor neque nec urna. Proin sapien ipsum, porta a, auctor quis, euismod ut, mi. Aenean viverra rhoncus pede. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut non enim eleifend felis pretium feugiat. Vivamus quis mi. Phasellus a est. Phasellus magna. In hac habitasse platea dictumst. Curabitur at lacus ac velit ornare lobortis. Curabitur a felis in nunc fringilla tristique. Morbi mattis ullamcorper velit. Phasellus gravida semper nisi. Nullam vel sem. Pellentesque libero tortor, tincidunt et, tincidunt eget, semper nec, quam. Sed hendrerit. Morbi ac felis. Nunc egestas, augue at pellentesque laoreet, felis eros vehicula leo, at malesuada velit leo quis pede. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Nunc nulla. Fusce risus nisl, viverra et, tempor et, pretium in, sapien. Donec venenatis vulputate lorem. Morbi nec metus. Phasellus blandit leo ut odio. Maecenas ullamcorper, dui et placerat feugiat, eros pede varius nisi, condimentum viverra felis nunc et lorem. Sed magna purus, fermentum eu, tincidunt eu,", + "start_datetime": "2023-07-21T13:12:17.000+0000", + "end_datetime": "2023-07-22T13:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + "description_too_long" + ] + } + }, + { + "description": "Should fail when the account id invalid", + "input": { + "body": { + "description":"Create Event", + "start_datetime": "2023-07-21T13:12:17.000+0000", + "end_datetime": "2023-07-22T13:12:17.000+0000" + }, + "accountId": "invalid" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": [ + { + "message": "Related To ID: id value of incorrect type: 0011e00000bWSxdAA1", + "errorCode": "MALFORMED_ID", + "fields": [ + "WhatId" + ] + } + ], + "httpHeaders": {}, + "httpStatusCode": 400, + "referenceId": "CreateEvent" + } + ] + } + }, + "output": { + "http_code": 500, + "message": "Something went wrong.", + "code": "INTERNAL_SERVER_ERROR", + "internal_error_identifier": "l_ca_cae_csae_pr_1", + "param_errors": [] + } + } +] \ No newline at end of file diff --git a/src/test/resources/data/functional/controllers/accountEventController/deleteAccountEvent.scenarios.json b/src/test/resources/data/functional/controllers/accountEventController/deleteAccountEvent.scenarios.json new file mode 100644 index 00000000..6dc71950 --- /dev/null +++ b/src/test/resources/data/functional/controllers/accountEventController/deleteAccountEvent.scenarios.json @@ -0,0 +1,55 @@ +[ + { + "description": "Should successfully delete the event for given event id", + "input": { + "accountId": "0011e00000bWSxdAAG", + "eventId":"0691e000001X1yTAAS" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": null, + "httpHeaders": {}, + "httpStatusCode": 204, + "referenceId": "DeleteEvent" + } + ] + } + }, + "output": {} + }, + { + "description": "should return error response when event id is invalid", + "input": { + "accountId": "0011e00000bWSxdAAG", + "eventId":"invalidEventId" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": [ + { + "errorCode": "NOT_FOUND", + "message": "Provided external ID field does not exist or is not accessible: INVALID_EVENT_ID" + } + ], + "httpHeaders": {}, + "httpStatusCode": 404, + "referenceId": "DeleteEvent" + } + ] + } + }, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "l_ca_dae_dsae_pr_1", + "param_errors": [ + "invalid_event_id" + ] + } + } + ] \ No newline at end of file diff --git a/src/test/resources/data/functional/controllers/accountEventController/getAccountEventDetails.scenarios.json b/src/test/resources/data/functional/controllers/accountEventController/getAccountEventDetails.scenarios.json new file mode 100644 index 00000000..1d536fd0 --- /dev/null +++ b/src/test/resources/data/functional/controllers/accountEventController/getAccountEventDetails.scenarios.json @@ -0,0 +1,88 @@ +[ + { + "description": "Should return the event details for a given event id", + "input": { + "accountId": "0011e00000bWSxdAAG", + "eventId": "00T1e000007mGYaEAA" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": { + "totalSize": 1, + "done": true, + "records": [ + { + "attributes": { + "type": "Event", + "url": "/services/data/v58.0/sobjects/Event/00U1e000003UPzbEAG" + }, + "Id": "00U1e000003UPzbEAG", + "WhatId": "0011e00000bWSxdAAG", + "StartDateTime": "2023-09-16T06:49:00.000+0000", + "EndDateTime": "2023-09-16T07:49:00.000+0000", + "Description": "Event Description", + "CreatedBy": { + "attributes": { + "type": "User", + "url": "/services/data/v58.0/sobjects/User/0055i00000AUxQHAA1" + }, + "Name": "Ashfaq Bhojani" + }, + "LastModifiedDate": "2023-09-28T04:55:12.000+0000" + } + ] + }, + "httpHeaders": {}, + "httpStatusCode": 200, + "referenceId": "getEvent" + } + ] + } + }, + "output": { + "event_detail": { + "id": "00U1e000003UPzbEAG", + "creator_name": "Ashfaq Bhojani", + "description": "Event Description", + "start_datetime": "2023-09-16T06:49:00.000+0000", + "end_datetime": "2023-09-16T07:49:00.000+0000", + "last_modified_time": "2023-09-28T04:55:12.000+00:00" + } + } + }, + { + "description": "should return error response when event id is invalid", + "input": { + "accountId": "0011e00000bWSxdAAG", + "eventId": "invalid_event_id" + }, + "mocks":{ + "makeCompositeRequest":{ + "compositeResponse": [ + { + "body": [ + { + "message": "\nLastModifiedDate FROM Event WHERE Id='invalid_event_id'\n ^\nERROR at Row:1:Column:105\ninvalid ID field: invalid_event_id", + "errorCode": "INVALID_QUERY_FILTER_OPERATOR" + } + ], + "httpHeaders": {}, + "httpStatusCode": 400, + "referenceId": "getEvent" + } + ] + } + }, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "l_ca_gaed_gsaed_pr_1", + "param_errors": [ + "invalid_account_id" + ] + } + } +] \ No newline at end of file diff --git a/src/test/resources/data/functional/controllers/accountEventController/getAccountEventsList.scenarios.json b/src/test/resources/data/functional/controllers/accountEventController/getAccountEventsList.scenarios.json new file mode 100644 index 00000000..f0f59495 --- /dev/null +++ b/src/test/resources/data/functional/controllers/accountEventController/getAccountEventsList.scenarios.json @@ -0,0 +1,228 @@ +[ + { + "description": "Should return the 5 latest Notes", + "input": { + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": { + "totalSize": 5, + "done": true, + "records": [ + { + "attributes": { + "type": "Event", + "url": "/services/data/v58.0/sobjects/Event/00T1e000007mGYaEAA" + }, + "Id": "00T1e000007mGYaEAA", + "Description": "Description 1", + "CreatedBy": { + "attributes": { + "type": "User", + "url": "/services/data/v58.0/sobjects/User/0055i00000AUxQHAA1" + }, + "Name": "Name1" + }, + "LastModifiedDate": "2023-08-24T12:09:51.000+00:00", + "StartDateTime": "2023-08-24T12:16:05.000+0000", + "EndDateTime": "2023-08-24T13:16:05.000+0000" + }, + { + "attributes": { + "type": "Event", + "url": "/services/data/v58.0/sobjects/Event/00T1e000007mGYaEAB" + }, + "Id": "00T1e000007mGYaEAB", + "Description": "Description 2", + "CreatedBy": { + "attributes": { + "type": "User", + "url": "/services/data/v58.0/sobjects/User/0055i00000AUxQHAA1" + }, + "Name": "Name2" + }, + "LastModifiedDate": "2023-08-24T12:09:51.000+00:00", + "StartDateTime": "2023-08-24T12:16:05.000+0000", + "EndDateTime": "2023-08-24T13:16:05.000+0000" + }, + { + "attributes": { + "type": "Event", + "url": "/services/data/v58.0/sobjects/Event/00T1e000007mGYaEAC" + }, + "Id": "00T1e000007mGYaEAC", + "Description": "Description 3", + "CreatedBy": { + "attributes": { + "type": "User", + "url": "/services/data/v58.0/sobjects/User/0055i00000AUxQHAA1" + }, + "Name": "Name3" + }, + "LastModifiedDate": "2023-08-24T12:09:51.000+00:00", + "StartDateTime": "2023-08-24T12:16:05.000+0000", + "EndDateTime": "2023-08-24T13:16:05.000+0000" + }, + { + "attributes": { + "type": "Event", + "url": "/services/data/v58.0/sobjects/Event/00T1e000007mGYaEAD" + }, + "Id": "00T1e000007mGYaEAD", + "Description": "Description 4", + "CreatedBy": { + "attributes": { + "type": "User", + "url": "/services/data/v58.0/sobjects/User/0055i00000AUxQHAA1" + }, + "Name": "Name4" + }, + "LastModifiedDate": "2023-08-24T12:09:51.000+00:00", + "StartDateTime": "2023-08-24T12:16:05.000+0000", + "EndDateTime": "2023-08-24T13:16:05.000+0000" + }, + { + "attributes": { + "type": "Event", + "url": "/services/data/v58.0/sobjects/Event/00T1e000007mGYaEAE" + }, + "Id": "00T1e000007mGYaEAE", + "Description": "Description 5", + "CreatedBy": { + "attributes": { + "type": "User", + "url": "/services/data/v58.0/sobjects/User/0055i00000AUxQHAA1" + }, + "Name": "Name5" + }, + "LastModifiedDate": "2023-08-24T12:09:51.000+00:00", + "StartDateTime": "2023-08-24T12:16:05.000+0000", + "EndDateTime": "2023-08-24T13:16:05.000+0000" + } + ] + }, + "httpHeaders": {}, + "httpStatusCode": 200, + "referenceId": "GetEventsList" + } + ] + } + }, + "output": { + "event_ids": [ + "00T1e000007mGYaEAA", + "00T1e000007mGYaEAB", + "00T1e000007mGYaEAC", + "00T1e000007mGYaEAD", + "00T1e000007mGYaEAE" + ], + "event_map_by_id": { + "00T1e000007mGYaEAE": { + "id": "00T1e000007mGYaEAE", + "creator_name": "Name5", + "description": "Description 5", + "start_datetime": "2023-08-24T12:16:05.000+0000", + "end_datetime": "2023-08-24T13:16:05.000+0000", + "last_modified_time": "2023-08-24T12:09:51.000+00:00" + }, + "00T1e000007mGYaEAD": { + "id": "00T1e000007mGYaEAD", + "creator_name": "Name4", + "description": "Description 4", + "start_datetime": "2023-08-24T12:16:05.000+0000", + "end_datetime": "2023-08-24T13:16:05.000+0000", + "last_modified_time": "2023-08-24T12:09:51.000+00:00" + }, + "00T1e000007mGYaEAC": { + "id": "00T1e000007mGYaEAC", + "creator_name": "Name3", + "description": "Description 3", + "start_datetime": "2023-08-24T12:16:05.000+0000", + "end_datetime": "2023-08-24T13:16:05.000+0000", + "last_modified_time": "2023-08-24T12:09:51.000+00:00" + }, + "00T1e000007mGYaEAB": { + "id": "00T1e000007mGYaEAB", + "creator_name": "Name2", + "description": "Description 2", + "start_datetime": "2023-08-24T12:16:05.000+0000", + "end_datetime": "2023-08-24T13:16:05.000+0000", + "last_modified_time": "2023-08-24T12:09:51.000+00:00" + }, + "00T1e000007mGYaEAA": { + "id": "00T1e000007mGYaEAA", + "creator_name": "Name1", + "description": "Description 1", + "start_datetime": "2023-08-24T12:16:05.000+0000", + "end_datetime": "2023-08-24T13:16:05.000+0000", + "last_modified_time": "2023-08-24T12:09:51.000+00:00" + } + } + } + }, + { + "description": "should return empty response when no events are present", + "input": { + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": { + "totalSize": 0, + "done": true, + "records": [] + }, + "httpHeaders": {}, + "httpStatusCode": 200, + "referenceId": "GetEventsList" + } + ] + } + }, + "output": { + "event_ids": [], + "event_map_by_id": {} + } + }, + { + "description": "should return error response when account id is invalid", + "input": { + "accountId": "invalid" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": [ + { + "message": "\nLastModifiedDate FROM Event WHERE WhatId='invalid' ORDER BY LastModifiedDate\n ^\nERROR at Row:1:Column:109\ninvalid ID field: abcd", + "errorCode": "INVALID_QUERY_FILTER_OPERATOR" + } + ], + "httpHeaders": {}, + "httpStatusCode": 400, + "referenceId": "GetEventsList" + } + ] + } + }, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "l_ca_gael_gsael_pr_1", + "param_errors": [ + { + "parameter": "account_id", + "param_error_identifier": "invalid_account_id", + "message": "The account id you sent is incorrect. Please double check and try again." + } + ] + } + } +] \ No newline at end of file diff --git a/src/test/resources/data/functional/controllers/accountEventController/updateAccountEvent.scenarios.json b/src/test/resources/data/functional/controllers/accountEventController/updateAccountEvent.scenarios.json new file mode 100644 index 00000000..14ca4652 --- /dev/null +++ b/src/test/resources/data/functional/controllers/accountEventController/updateAccountEvent.scenarios.json @@ -0,0 +1,127 @@ +[ + { + "description": "Should successfully update the event for given event id", + "input": { + "body": { + "description":"Create Event", + "start_datetime": "2023-07-21T13:12:17.000+0000", + "end_datetime": "2023-07-22T13:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG", + "eventId":"0691e000001X1yTAAS" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": null, + "httpHeaders": {}, + "httpStatusCode": 200, + "referenceId": "UpdateEvent" + } + ] + } + }, + "output": {} + }, + { + "description": "Should fail when event task description is not provided", + "input": { + "body": { + "start_datetime": "2023-07-21T13:12:17.000+0000", + "end_datetime": "2023-07-22T13:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + "missing_description" + ] + } + }, + { + "description": "Should fail when the event start_datetime is invalid", + "input": { + "body": { + "description":"Create Event", + "start_datetime": "2023-07-21", + "end_datetime": "2023-07-22T13:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + "invalid_start_datetime" + ] + } + }, + { + "description": "Should fail when the event end_datetime is invalid", + "input": { + "body": { + "description":"Create Event", + "start_datetime": "2023-07-22T13:12:17.000+0000", + "end_datetime": "2023-07-22T13:12.000+0000" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + "invalid_end_datetime" + ] + } + }, + { + "description": "should return error response when event id is invalid", + "input": { + "body": { + "description":"Create Event", + "start_datetime": "2023-07-21T13:12:17.000+0000", + "end_datetime": "2023-07-22T13:12:17.000+0000" + }, + "accountId": "0011e00000bWSxdAAG", + "eventId":"invalidEventId" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": [ + { + "errorCode": "NOT_FOUND", + "message": "Provided external ID field does not exist or is not accessible: INVALID_EVENT_ID" + } + ], + "httpHeaders": {}, + "httpStatusCode": 404, + "referenceId": "UpdateEvent" + } + ] + } + }, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "l_ua_uae_usae_pr_1", + "param_errors": [ + "invalid_event_id" + ] + } + } +] \ No newline at end of file diff --git a/src/test/resources/data/functional/controllers/accountNoteController/updateAccountNote.scenarios.json b/src/test/resources/data/functional/controllers/accountNoteController/updateAccountNote.scenarios.json new file mode 100644 index 00000000..b253fad6 --- /dev/null +++ b/src/test/resources/data/functional/controllers/accountNoteController/updateAccountNote.scenarios.json @@ -0,0 +1,61 @@ +[ + { + "description": "Should successfully update the note for given note id", + "input": { + "body": { + "text": "Updated Test note" + }, + "accountId": "0011e00000bWSxdAAG", + "noteId":"0691e000001X1yTAAS" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": null, + "httpHeaders": {}, + "httpStatusCode": 200, + "referenceId": "UpdateNote" + } + ] + } + }, + "output": {} + }, + { + "description": "should return error response when note id is invalid", + "input": { + "body": { + "text": "Updated Test note" + }, + "accountId": "0011e00000bWSxdAAG", + "noteId":"invalidNoteId" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": [ + { + "errorCode": "NOT_FOUND", + "message": "Provided external ID field does not exist or is not accessible: INVALID_NOTE_ID" + } + ], + "httpHeaders": {}, + "httpStatusCode": 404, + "referenceId": "UpdateNote" + } + ] + } + }, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "l_ua_uan_usan_pr_1", + "param_errors": [ + "invalid_note_id" + ] + } + } + ] \ No newline at end of file diff --git a/src/test/resources/data/functional/controllers/accountTaskController/deleteAccountTask.scenarios.json b/src/test/resources/data/functional/controllers/accountTaskController/deleteAccountTask.scenarios.json index 33f9fbac..b03d0d0c 100644 --- a/src/test/resources/data/functional/controllers/accountTaskController/deleteAccountTask.scenarios.json +++ b/src/test/resources/data/functional/controllers/accountTaskController/deleteAccountTask.scenarios.json @@ -46,7 +46,7 @@ "http_code": 400, "message": "At least one parameter is invalid or missing.", "code": "INVALID_PARAMS", - "internal_error_identifier": "l_ca_dan_dasn_pr_1", + "internal_error_identifier": "l_ca_dat_dsat_pr_1", "param_errors": [ "invalid_task_id" ] diff --git a/src/test/resources/data/functional/controllers/accountTaskController/getAccountTaskDetails.scenarios.json b/src/test/resources/data/functional/controllers/accountTaskController/getAccountTaskDetails.scenarios.json new file mode 100644 index 00000000..3853a927 --- /dev/null +++ b/src/test/resources/data/functional/controllers/accountTaskController/getAccountTaskDetails.scenarios.json @@ -0,0 +1,95 @@ +[ + { + "description": "Should return the task details for a given task id", + "input": { + "accountId": "0011e00000bWSxdAAG", + "taskId": "00T1e000007mGYaEAM" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": { + "totalSize": 1, + "done": true, + "records": [ + { + "attributes": { + "type": "Task", + "url": "/services/data/v58.0/sobjects/Task/00T1e000007mGYaEAM" + }, + "Id": "00T1e000007mGYaEAM", + "Description": "Task documentation", + "ActivityDate": "2023-12-01", + "CreatedBy": { + "attributes": { + "type": "User", + "url": "/services/data/v58.0/sobjects/User/0055i00000AUxQHAA1" + }, + "Name": "Name2" + }, + "Owner": { + "attributes": { + "type": "Name", + "url": "/services/data/v58.0/sobjects/User/0051e0000047G03AAE" + }, + "Name": "Name1", + "Id":"0055i00000AUxQHAA1" + }, + "LastModifiedDate": "2023-08-24T12:16:05.000+0000" + } + ] + }, + "httpHeaders": {}, + "httpStatusCode": 200, + "referenceId": "getTaskDetails" + } + ] + } + }, + "output": { + "task_detail": { + "id": "00T1e000007mGYaEAM", + "creator_name": "Name2", + "description": "Task documentation", + "due_date": "2023-12-01", + "crm_organization_user_name": "Name1", + "crm_organization_user_id": "0055i00000AUxQHAA1", + "last_modified_time": "2023-08-24T12:16:05.000+00:00" + } + } + }, + { + "description": "should return error response when task id is invalid", + "input": { + "account_id": "0011e00000bWSxdAAG", + "task_id": "invalid_task_id" + }, + "mocks":{ + "makeCompositeRequest":{ + "compositeResponse": [ + { + "body": [ + { + "message": "\nLastModifiedDate FROM Task WHERE Id='invalid_task_id'\n ^\nERROR at Row:1:Column:105\ninvalid ID field: invalid_task_id", + "errorCode": "INVALID_QUERY_FILTER_OPERATOR" + } + ], + "httpHeaders": {}, + "httpStatusCode": 400, + "referenceId": "GetTaskDetails" + } + ] + } + }, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "l_ca_gatd_gsatd_pr_1", + "param_errors": [ + "invalid_account_id" + ] + } + } +] \ No newline at end of file diff --git a/src/test/resources/data/functional/controllers/accountTaskController/getAccountTasksList.scenarios.json b/src/test/resources/data/functional/controllers/accountTaskController/getAccountTasksList.scenarios.json index 0d1e6afc..07f557a9 100644 --- a/src/test/resources/data/functional/controllers/accountTaskController/getAccountTasksList.scenarios.json +++ b/src/test/resources/data/functional/controllers/accountTaskController/getAccountTasksList.scenarios.json @@ -32,7 +32,8 @@ "type": "Name", "url": "/services/data/v58.0/sobjects/User/0051e0000047G03AAE" }, - "Name": "Name1" + "Name": "Name1", + "Id":"0051e0000047G03AAE" }, "LastModifiedDate": "2023-08-24T12:16:05.000+0000" }, @@ -56,7 +57,8 @@ "type": "Name", "url": "/services/data/v58.0/sobjects/User/0051e0000047G03AAE" }, - "Name": "Name1" + "Name": "Name1", + "Id":"0051e0000047G03AAE" }, "LastModifiedDate": "2023-08-24T12:09:51.000+0000" }, @@ -80,7 +82,8 @@ "type": "Name", "url": "/services/data/v58.0/sobjects/User/0051e0000047G03AAE" }, - "Name": "Name1" + "Name": "Name1", + "Id":"0051e0000047G03AAE" }, "LastModifiedDate": "2023-08-23T13:11:03.000+0000" }, @@ -104,7 +107,8 @@ "type": "Name", "url": "/services/data/v58.0/sobjects/User/0051e0000047G03AAE" }, - "Name": "Name1" + "Name": "Name1", + "Id":"0051e0000047G03AAE" }, "LastModifiedDate": "2023-08-23T07:49:23.000+0000" }, @@ -128,7 +132,8 @@ "type": "Name", "url": "/services/data/v58.0/sobjects/User/0051e0000047G03AAE" }, - "Name": "Name1" + "Name": "Name1", + "Id":"0051e0000047G03AAE" }, "LastModifiedDate": "2023-08-23T07:10:53.000+0000" } @@ -156,6 +161,7 @@ "description": "Update remaining documentations", "due_date": "2023-12-01", "crm_organization_user_name": "Name1", + "crm_organization_user_id": "0051e0000047G03AAE", "last_modified_time": "2023-08-24T12:09:51.000+00:00" }, "00T1e000007mEk9EAE": { @@ -164,6 +170,7 @@ "description": "Update remaining documentations", "due_date": "2023-12-01", "crm_organization_user_name": "Name1", + "crm_organization_user_id": "0051e0000047G03AAE", "last_modified_time": "2023-08-23T07:49:23.000+00:00" }, "00T1e000007mEfuEAE": { @@ -172,6 +179,7 @@ "description": "Update remaining documentations", "due_date": "2023-12-01", "crm_organization_user_name": "Name1", + "crm_organization_user_id": "0051e0000047G03AAE", "last_modified_time": "2023-08-23T07:10:53.000+00:00" }, "00T1e000007mF0oEAE": { @@ -180,6 +188,7 @@ "description": "Update remaining documentations", "due_date": "2023-12-01", "crm_organization_user_name": "Name1", + "crm_organization_user_id": "0051e0000047G03AAE", "last_modified_time": "2023-08-23T13:11:03.000+00:00" }, "00T1e000007mGYaEAM": { @@ -188,6 +197,7 @@ "description": "Update remaining documentations", "due_date": "2023-12-01", "crm_organization_user_name": "Name1", + "crm_organization_user_id": "0051e0000047G03AAE", "last_modified_time": "2023-08-24T12:16:05.000+00:00" } } diff --git a/src/test/resources/data/functional/controllers/accountTaskController/updateAccountTask.scenarios.json b/src/test/resources/data/functional/controllers/accountTaskController/updateAccountTask.scenarios.json new file mode 100644 index 00000000..35226689 --- /dev/null +++ b/src/test/resources/data/functional/controllers/accountTaskController/updateAccountTask.scenarios.json @@ -0,0 +1,167 @@ +[ + { + "description": "Should successfully update the task for given task id", + "input": { + "body": { + "crm_organization_user_id":"0011e00000bWSxdAA1", + "description":"Update remaining documentations", + "due_date":"2023-12-01" + }, + "accountId": "0011e00000bWSxdAAG", + "taskId":"0691e000001X1yTAAS" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": null, + "httpHeaders": {}, + "httpStatusCode": 200, + "referenceId": "UpdateTask" + } + ] + } + }, + "output": {} + }, + { + "description": "Should fail when the task description is empty", + "input": { + "body": { + "crm_organization_user_id":"0011e00000bWSxdAA1", + "description":"", + "due_date":"2023-12-01" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + "missing_description" + ] + } + }, + { + "description": "Should fail when the task description is not provided", + "input": { + "body": { + "crm_organization_user_id":"0011e00000bWSxdAA1", + "due_date":"2023-12-01" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + "missing_description" + ] + } + }, + { + "description": "Should fail when the task due_date is not provided", + "input": { + "body": { + "crm_organization_user_id":"0011e00000bWSxdAA1", + "description":"Update remaining documentations" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + "invalid_due_date" + ] + } + }, + { + "description": "Should fail when the task crm_organization_user_id is not provided", + "input": { + "body": { + "description":"Update remaining documentations", + "due_date":"2023-12-01" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + "missing_crm_organization_user_id" + ] + } + }, + { + "description": "Should fail when the task Due is not valid", + "input": { + "body": { + "crm_organization_user_id":"0011e00000bWSxdAA1", + "description":"Update remaining documentations", + "due_date":"2023-120-01" + }, + "accountId": "0011e00000bWSxdAAG" + }, + "mocks": {}, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "b_2", + "param_errors": [ + "invalid_due_date" + ] + } + }, + { + "description": "should return error response when task id is invalid", + "input": { + "body": { + "crm_organization_user_id":"0011e00000bWSxdAA1", + "description":"Update remaining documentations", + "due_date":"2023-12-01" + }, + "accountId": "0011e00000bWSxdAAG", + "taskId":"invalidTaskId" + }, + "mocks": { + "makeCompositeRequest": { + "compositeResponse": [ + { + "body": [ + { + "errorCode": "NOT_FOUND", + "message": "Provided external ID field does not exist or is not accessible: INVALID_TASK_ID" + } + ], + "httpHeaders": {}, + "httpStatusCode": 404, + "referenceId": "UpdateTask" + } + ] + } + }, + "output": { + "http_code": 400, + "message": "At least one parameter is invalid or missing.", + "code": "INVALID_PARAMS", + "internal_error_identifier": "l_ua_uat_usat_pr_1", + "param_errors": [ + "invalid_task_id" + ] + } + } + ] \ No newline at end of file diff --git a/src/test/resources/data/functional/controllers/authController/Logout.scenarios.json b/src/test/resources/data/functional/controllers/authController/Logout.scenarios.json index 6b46c398..fda8d52b 100644 --- a/src/test/resources/data/functional/controllers/authController/Logout.scenarios.json +++ b/src/test/resources/data/functional/controllers/authController/Logout.scenarios.json @@ -3,7 +3,7 @@ { "description": "Should logout user if valid cookie", "input": { - "cookie": "1:0055i00000AUxQHAA1:SALESFORCE:app:1692878227:a2xOxjcPChK/YsKCWRuY50J3gH21/tqcGlv7sWU/aPw3/UFVFPbvWn2LLzY5B5kVPXjj1gELRqa4B4ds6uuqIw==" + "cookie": "1:0055i00000AUxQHAA1:SALESFORCE:app:1702978227:3sYUB9JUTxtN1ETSlAMgTio66GodR6cGTb/gEcXWGzBcQ4D3YlaiFxq1xFv3Hnd8McSILBnVIcjI88HW+yL3Hw==" } }, { diff --git a/src/test/resources/data/functional/controllers/suggestionsController/crmActionsSuggestions.scenarios.json b/src/test/resources/data/functional/controllers/suggestionsController/crmActionsSuggestions.scenarios.json index 740e1765..33056e3d 100644 --- a/src/test/resources/data/functional/controllers/suggestionsController/crmActionsSuggestions.scenarios.json +++ b/src/test/resources/data/functional/controllers/suggestionsController/crmActionsSuggestions.scenarios.json @@ -2,13 +2,13 @@ { "description": "Should return correct suggestions for a given text", "input": { - "text": "We reviewed the tasks that the team has completed since the last meeting and discussed additional projects.\n\nHere are the main topics we discussed:\n\nJoe updated us on the calendar for editorial, advertorial and social media content.\n" + "text": "Had a call with product team. They need a pitch desk by tomorrow and need to setup another call for next week." }, "mocks":{ "makeRequest":{ - "id": "chatcmpl-0000", + "id": "chatcmpl-82Yb6OZk8wrZ1W91BDwmSi1O2spzr", "object": "chat.completion", - "created": 1692945329, + "created": 1695620340, "model": "gpt-3.5-turbo-0613", "choices": [ { @@ -18,24 +18,31 @@ "content": null, "function_call": { "name": "suggest_actions", - "arguments": "{\n \"add_task\": [\n {\n \"description\": \"Review calendar for editorial, advertorial, and social media content\",\n \"due_date\": \"2023-08-30\"\n }\n ]\n}" + "arguments": "{\n \"add_task\": [\n {\n \"description\": \"Create pitch deck\",\n \"due_date\": \"2023-09-26\"\n }\n ],\n \"add_event\": [\n {\n \"description\": \"Call with product team\",\n \"start_datetime\": \"2023-10-02T00:00:00.000+0000\"\n,\n \"end_datetime\": \"2023-10-02T01:00:00.000+0000\"\n }\n ]\n}" } }, "finish_reason": "function_call" } ], "usage": { - "prompt_tokens": 168, - "completion_tokens": 52, - "total_tokens": 220 + "prompt_tokens": 485, + "completion_tokens": 89, + "total_tokens": 574 } } }, "output": { "add_task_suggestions": [ { - "description": "Review calendar for editorial, advertorial, and social media content", - "due_date": "2023-08-30" + "description": "Create pitch deck", + "due_date": "2023-09-26" + } + ], + "add_event_suggestions": [ + { + "description": "Call with product team", + "start_datetime": "2023-10-02T00:00:00.000+0000", + "end_datetime": "2023-10-02T01:00:00.000+0000" } ] } @@ -59,7 +66,7 @@ "content": null, "function_call": { "name": "suggest_actions", - "arguments": "{\n \"add_task\": []\n}" + "arguments": "{\n \"add_task\": []\n,\"add_event\": []\n}" } }, "finish_reason": "function_call" @@ -73,7 +80,8 @@ } }, "output": { - "add_task_suggestions": [] + "add_task_suggestions": [], + "add_event_suggestions": [] } }, { @@ -114,7 +122,8 @@ "description": "Review calendar for editorial, advertorial, and social media content", "due_date": null } - ] + ], + "add_event_suggestions": [] } }, { diff --git a/src/test/resources/data/functional/controllers/userController/getCurrentUser.scenarios.json b/src/test/resources/data/functional/controllers/userController/getCurrentUser.scenarios.json index 16920d99..0d94ae76 100644 --- a/src/test/resources/data/functional/controllers/userController/getCurrentUser.scenarios.json +++ b/src/test/resources/data/functional/controllers/userController/getCurrentUser.scenarios.json @@ -2,7 +2,7 @@ { "description": "Should return current user", "input": { - "cookie": "1:0055i00000AUxQHAA1:SALESFORCE:app:1692878227:a2xOxjcPChK/YsKCWRuY50J3gH21/tqcGlv7sWU/aPw3/UFVFPbvWn2LLzY5B5kVPXjj1gELRqa4B4ds6uuqIw==" + "cookie": "1:0055i00000AUxQHAA1:SALESFORCE:app:1702978227:3sYUB9JUTxtN1ETSlAMgTio66GodR6cGTb/gEcXWGzBcQ4D3YlaiFxq1xFv3Hnd8McSILBnVIcjI88HW+yL3Hw==" }, "output": { "current_user": { diff --git a/src/test/resources/fixtures/functional/controllers/accountEventController/createAccountEvent.fixtures.json b/src/test/resources/fixtures/functional/controllers/accountEventController/createAccountEvent.fixtures.json new file mode 100644 index 00000000..a6dd0b3f --- /dev/null +++ b/src/test/resources/fixtures/functional/controllers/accountEventController/createAccountEvent.fixtures.json @@ -0,0 +1,14 @@ +{ + "createAccountEvent": { + "salesforce_users": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceUser/ActiveSalesforceUser.json" + } + ], + "salesforce_oauth_tokens": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceOauthToken/ActiveSalesforceOauthToken.json" + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/fixtures/functional/controllers/accountEventController/deleteAccountEvent.fixtures.json b/src/test/resources/fixtures/functional/controllers/accountEventController/deleteAccountEvent.fixtures.json new file mode 100644 index 00000000..51619d2e --- /dev/null +++ b/src/test/resources/fixtures/functional/controllers/accountEventController/deleteAccountEvent.fixtures.json @@ -0,0 +1,14 @@ +{ + "deleteAccountEvent": { + "salesforce_users": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceUser/ActiveSalesforceUser.json" + } + ], + "salesforce_oauth_tokens": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceOauthToken/ActiveSalesforceOauthToken.json" + } + ] + } + } \ No newline at end of file diff --git a/src/test/resources/fixtures/functional/controllers/accountEventController/getAccountEventDetails.fixtures.json b/src/test/resources/fixtures/functional/controllers/accountEventController/getAccountEventDetails.fixtures.json new file mode 100644 index 00000000..b08a0cd6 --- /dev/null +++ b/src/test/resources/fixtures/functional/controllers/accountEventController/getAccountEventDetails.fixtures.json @@ -0,0 +1,14 @@ +{ + "getAccountEventDetails": { + "salesforce_users": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceUser/ActiveSalesforceUser.json" + } + ], + "salesforce_oauth_tokens": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceOauthToken/ActiveSalesforceOauthToken.json" + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/fixtures/functional/controllers/accountEventController/getAccountEventsList.fixtures.json b/src/test/resources/fixtures/functional/controllers/accountEventController/getAccountEventsList.fixtures.json new file mode 100644 index 00000000..692a6447 --- /dev/null +++ b/src/test/resources/fixtures/functional/controllers/accountEventController/getAccountEventsList.fixtures.json @@ -0,0 +1,14 @@ +{ + "getAccountEventsList": { + "salesforce_users": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceUser/ActiveSalesforceUser.json" + } + ], + "salesforce_oauth_tokens": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceOauthToken/ActiveSalesforceOauthToken.json" + } + ] + } + } \ No newline at end of file diff --git a/src/test/resources/fixtures/functional/controllers/accountEventController/updateAccountEvent.fixtures.json b/src/test/resources/fixtures/functional/controllers/accountEventController/updateAccountEvent.fixtures.json new file mode 100644 index 00000000..11986457 --- /dev/null +++ b/src/test/resources/fixtures/functional/controllers/accountEventController/updateAccountEvent.fixtures.json @@ -0,0 +1,14 @@ +{ + "updateAccountEvent": { + "salesforce_users": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceUser/ActiveSalesforceUser.json" + } + ], + "salesforce_oauth_tokens": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceOauthToken/ActiveSalesforceOauthToken.json" + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/fixtures/functional/controllers/accountNoteController/updateAccountNote.fixtures.json b/src/test/resources/fixtures/functional/controllers/accountNoteController/updateAccountNote.fixtures.json new file mode 100644 index 00000000..37e0bf0f --- /dev/null +++ b/src/test/resources/fixtures/functional/controllers/accountNoteController/updateAccountNote.fixtures.json @@ -0,0 +1,14 @@ +{ + "updateAccountNote": { + "salesforce_users": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceUser/ActiveSalesforceUser.json" + } + ], + "salesforce_oauth_tokens": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceOauthToken/ActiveSalesforceOauthToken.json" + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/fixtures/functional/controllers/accountTaskController/getAccountTaskDetails.fixtures.json b/src/test/resources/fixtures/functional/controllers/accountTaskController/getAccountTaskDetails.fixtures.json new file mode 100644 index 00000000..ec2bddc0 --- /dev/null +++ b/src/test/resources/fixtures/functional/controllers/accountTaskController/getAccountTaskDetails.fixtures.json @@ -0,0 +1,14 @@ +{ + "getAccountTaskDetails": { + "salesforce_users": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceUser/ActiveSalesforceUser.json" + } + ], + "salesforce_oauth_tokens": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceOauthToken/ActiveSalesforceOauthToken.json" + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/fixtures/functional/controllers/accountTaskController/updateAccountTask.fixtures.json b/src/test/resources/fixtures/functional/controllers/accountTaskController/updateAccountTask.fixtures.json new file mode 100644 index 00000000..f95030fd --- /dev/null +++ b/src/test/resources/fixtures/functional/controllers/accountTaskController/updateAccountTask.fixtures.json @@ -0,0 +1,14 @@ +{ + "updateAccountTask": { + "salesforce_users": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceUser/ActiveSalesforceUser.json" + } + ], + "salesforce_oauth_tokens": [ + { + "filepath": "classpath:fixtures/common/repositories/salesforceOauthToken/ActiveSalesforceOauthToken.json" + } + ] + } +} \ No newline at end of file