All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mx.path.model.mdx.web.controller.RemoteDepositsController Maven / Gradle / Ivy

The newest version!
package com.mx.path.model.mdx.web.controller;

import com.mx.path.gateway.accessor.AccessorResponse;
import com.mx.path.model.mdx.model.MdxList;
import com.mx.path.model.mdx.model.account.Account;
import com.mx.path.model.mdx.model.remote_deposit.Limits;
import com.mx.path.model.mdx.model.remote_deposit.RemoteDeposit;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "{clientId}", produces = BaseController.MDX_MEDIA)
public class RemoteDepositsController extends BaseController {

  public RemoteDepositsController() {
  }

  @RequestMapping(value = "/users/{user_id}/remote_deposits", method = RequestMethod.POST, consumes = MDX_MEDIA)
  public final ResponseEntity createRemoteDeposit(@RequestBody RemoteDeposit remoteDepositRequest) {
    AccessorResponse response = gateway().remoteDeposits().create(remoteDepositRequest);
    RemoteDeposit result = response.getResult();
    HttpStatus status = HttpStatus.OK;
    if (result != null && result.getChallenges() != null && !result.getChallenges().isEmpty()) {
      status = HttpStatus.ACCEPTED;
    }
    return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), status);
  }

  @RequestMapping(value = "/users/{userId}/remote_deposits/{id}", method = RequestMethod.GET)
  public final ResponseEntity getRemoteDeposit(@PathVariable("id") String remoteDepositId) {
    AccessorResponse response = gateway().remoteDeposits().get(remoteDepositId);
    return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
  }

  @RequestMapping(value = "/users/{userId}/remote_deposits", method = RequestMethod.GET)
  public final ResponseEntity> getRemoteDeposits() {
    AccessorResponse> response = gateway().remoteDeposits().list();
    return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
  }

  @RequestMapping(value = "/users/{userId}/accounts/remote_deposit", method = RequestMethod.GET)
  public final ResponseEntity> getRemoteDepositAccounts() {
    AccessorResponse> response = gateway().remoteDeposits().accounts();
    return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
  }

  @RequestMapping(value = "/users/{userId}/remote_deposits/limits", method = RequestMethod.GET)
  public final ResponseEntity getRemoteDepositLimits() {
    AccessorResponse response = gateway().remoteDeposits().limits();
    return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy