-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from TrueSparrowSystems/create-accounts-event
New API Endpoints
- Loading branch information
Showing
103 changed files
with
4,749 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
src/main/java/com/salessparrow/api/controllers/AccountEventController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package com.salessparrow.api.controllers; | ||
|
||
import org.slf4j.Logger; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.salessparrow.api.dto.formatter.CreateEventFormatterDto; | ||
import com.salessparrow.api.dto.formatter.GetEventDetailsFormatterDto; | ||
import com.salessparrow.api.dto.formatter.GetEventsListFormatterDto; | ||
import com.salessparrow.api.dto.requestMapper.CreateAccountEventDto; | ||
import com.salessparrow.api.dto.requestMapper.UpdateAccountEventDto; | ||
import com.salessparrow.api.services.accountEvents.CreateAccountEventService; | ||
import com.salessparrow.api.services.accountEvents.DeleteAccountEventService; | ||
import com.salessparrow.api.services.accountEvents.GetAccountEventDetailsService; | ||
import com.salessparrow.api.services.accountEvents.GetAccountEventsListService; | ||
import com.salessparrow.api.services.accountEvents.UpdateAccountEventService; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.validation.Valid; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/accounts/{account_id}/events") | ||
@Validated | ||
public class AccountEventController { | ||
|
||
private Logger logger = org.slf4j.LoggerFactory.getLogger(AccountEventController.class); | ||
|
||
@Autowired | ||
private CreateAccountEventService createEventService; | ||
|
||
@Autowired | ||
private GetAccountEventsListService getAccountEventsListService; | ||
|
||
@Autowired | ||
private DeleteAccountEventService deleteEventService; | ||
|
||
@Autowired | ||
private UpdateAccountEventService updateEventService; | ||
|
||
@Autowired | ||
private GetAccountEventDetailsService getAccountEventDetailsService; | ||
|
||
@PostMapping("") | ||
public ResponseEntity<CreateEventFormatterDto> createEvent(HttpServletRequest request, | ||
@PathVariable("account_id") String accountId, @Valid @RequestBody CreateAccountEventDto createEventDto) { | ||
logger.info("Create Event Request received"); | ||
|
||
CreateEventFormatterDto createEventFormatterDto = createEventService.createEvent(request, accountId, | ||
createEventDto); | ||
|
||
return ResponseEntity.status(HttpStatus.CREATED).body(createEventFormatterDto); | ||
} | ||
|
||
@GetMapping("") | ||
public ResponseEntity<GetEventsListFormatterDto> getEventsList(HttpServletRequest request, | ||
@PathVariable("account_id") String accountId) { | ||
logger.info("Get events list request received"); | ||
|
||
GetEventsListFormatterDto getEventsListFormatterDto = getAccountEventsListService.getAccountEventsList(request, | ||
accountId); | ||
return ResponseEntity.status(HttpStatus.OK).body(getEventsListFormatterDto); | ||
} | ||
|
||
@DeleteMapping("/{event_id}") | ||
public ResponseEntity<Void> deleteEvent(HttpServletRequest request, @PathVariable("account_id") String accountId, | ||
@PathVariable("event_id") String eventId) { | ||
logger.info("Delete event request received"); | ||
|
||
deleteEventService.deleteAccountEvent(request, accountId, eventId); | ||
|
||
return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); | ||
} | ||
|
||
@PutMapping("/{event_id}") | ||
public ResponseEntity<Void> updateEvent(HttpServletRequest request, @PathVariable("account_id") String accountId, | ||
@PathVariable("event_id") String eventId, @Valid @RequestBody UpdateAccountEventDto updateEventDto) { | ||
logger.info("Update event request received"); | ||
|
||
updateEventService.updateAccountEvent(request, accountId, eventId, updateEventDto); | ||
|
||
return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); | ||
} | ||
|
||
@GetMapping("/{event_id}") | ||
public ResponseEntity<GetEventDetailsFormatterDto> getEventFromAccount(HttpServletRequest request, | ||
@PathVariable("account_id") String accountId, @PathVariable("event_id") String eventId) { | ||
logger.info("Get Event request received"); | ||
|
||
GetEventDetailsFormatterDto getEventDetailsResponse = getAccountEventDetailsService.getEventDetails(request, | ||
eventId); | ||
|
||
return ResponseEntity.ok().body(getEventDetailsResponse); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/com/salessparrow/api/dto/entities/AddEventSuggestionEntityDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.salessparrow.api.dto.entities; | ||
|
||
import com.fasterxml.jackson.databind.PropertyNamingStrategies; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
||
import lombok.Data; | ||
|
||
/** | ||
* Add Event Suggestion Entity is a DTO class for the Add Event Suggestion Entity. | ||
*/ | ||
@Data | ||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) | ||
public class AddEventSuggestionEntityDto { | ||
|
||
private String description; | ||
|
||
private String startDatetime; | ||
|
||
private String endDatetime; | ||
|
||
} |
Oops, something went wrong.