/** GET /cardTypes/:id -> get the "id" cardType. */
 @RequestMapping(
     value = "/cardTypes/{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<CardType> getCardType(@PathVariable Long id) {
   log.debug("REST request to get CardType : {}", id);
   CardType cardType = cardTypeRepository.findOne(id);
   return Optional.ofNullable(cardType)
       .map(result -> new ResponseEntity<>(result, HttpStatus.OK))
       .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
 }
 /** GET /cardTypes -> get all the cardTypes. */
 @RequestMapping(
     value = "/cardTypes",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<List<CardType>> getAllCardTypes(Pageable pageable)
     throws URISyntaxException {
   log.debug("REST request to get a page of CardTypes");
   Page<CardType> page = cardTypeRepository.findAll(pageable);
   HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/cardTypes");
   return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
 }
 /** DELETE /cardTypes/:id -> delete the "id" cardType. */
 @RequestMapping(
     value = "/cardTypes/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> deleteCardType(@PathVariable Long id) {
   log.debug("REST request to delete CardType : {}", id);
   cardTypeRepository.delete(id);
   cardTypeSearchRepository.delete(id);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityDeletionAlert("cardType", id.toString()))
       .build();
 }
 /** PUT /cardTypes -> Updates an existing cardType. */
 @RequestMapping(
     value = "/cardTypes",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<CardType> updateCardType(@Valid @RequestBody CardType cardType)
     throws URISyntaxException {
   log.debug("REST request to update CardType : {}", cardType);
   if (cardType.getId() == null) {
     return createCardType(cardType);
   }
   CardType result = cardTypeRepository.save(cardType);
   cardTypeSearchRepository.save(result);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityUpdateAlert("cardType", cardType.getId().toString()))
       .body(result);
 }
 /** POST /cardTypes -> Create a new cardType. */
 @RequestMapping(
     value = "/cardTypes",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<CardType> createCardType(@Valid @RequestBody CardType cardType)
     throws URISyntaxException {
   log.debug("REST request to save CardType : {}", cardType);
   if (cardType.getId() != null) {
     return ResponseEntity.badRequest()
         .headers(
             HeaderUtil.createFailureAlert(
                 "cardType", "idexists", "A new cardType cannot already have an ID"))
         .body(null);
   }
   CardType result = cardTypeRepository.save(cardType);
   cardTypeSearchRepository.save(result);
   return ResponseEntity.created(new URI("/api/cardTypes/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("cardType", result.getId().toString()))
       .body(result);
 }