diff --git a/src/main/java/de/rwth/swc/sqa/api/CustomerController.java b/src/main/java/de/rwth/swc/sqa/api/CustomerController.java index 6038813ee03c05324efd805c075c64ed1543fefa..22f6ba22b70029239e5c9429dbf7fa794f298f33 100644 --- a/src/main/java/de/rwth/swc/sqa/api/CustomerController.java +++ b/src/main/java/de/rwth/swc/sqa/api/CustomerController.java @@ -1,7 +1,52 @@ package de.rwth.swc.sqa.api; +import de.rwth.swc.sqa.model.DiscountCard; +import io.swagger.annotations.ApiParam; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.net.http.HttpResponse; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; @Controller +@RequestMapping("/customers") public class CustomerController implements CustomersApi{ + + @PostMapping("/{customerId}/discountcards") + public ResponseEntity<DiscountCard> addDiscountCardToCustomer(@ApiParam(value = "ID of customer",required = true) @PathVariable("customerId") Long customerId, @ApiParam(value = "DiscountCard object that needs to be added to the customer",required = true) @RequestBody @Valid DiscountCard body) { + this.getRequest().ifPresent((request) -> { + Iterator var1 = MediaType.parseMediaTypes(request.getHeader("Accept")).iterator(); + + while(var1.hasNext()) { + MediaType mediaType = (MediaType)var1.next(); + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"validFor\" : \"30d\", \"customerId\" : 6, \"id\" : 0, \"validFrom\" : \"1992-01-01\", \"type\" : 1 }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + + }); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + @GetMapping("/{customerId}/discountcards") + public ResponseEntity<List<DiscountCard>> getCustomerDiscountCards(@ApiParam(value = "ID of customer to search for discount cards",required = true) @PathVariable("customerId") Long customerId) { + List<DiscountCard> customerDiscountCards = new ArrayList<DiscountCard>(); + + DiscountCard testCard = new DiscountCard(); + testCard.setCustomerId(new Long(55443327)); + testCard.setType(1); + + customerDiscountCards.add(testCard); + + return ResponseEntity.ok().body(customerDiscountCards); + } + } diff --git a/src/main/java/de/rwth/swc/sqa/api/TicketController.java b/src/main/java/de/rwth/swc/sqa/api/TicketController.java index c2dacebeb7cafe8527b53aae01b6b5f779db3c95..e41d626cba9320128973aee6579550b5968f9090 100644 --- a/src/main/java/de/rwth/swc/sqa/api/TicketController.java +++ b/src/main/java/de/rwth/swc/sqa/api/TicketController.java @@ -1,7 +1,9 @@ package de.rwth.swc.sqa.api; +import de.rwth.swc.sqa.model.Customer; import org.springframework.stereotype.Controller; @Controller public class TicketController implements TicketsApi{ + Customer customer; }