com.mx.path.model.mdx.web.controller.PayoutsController 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.payout.Payout;
import com.mx.path.model.mdx.model.payout.PayoutMethod;
import com.mx.path.model.mdx.model.payout.Recipient;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "{clientId}/users/{user_id}", produces = BaseController.MDX_MEDIA)
public class PayoutsController extends BaseController {
@RequestMapping(value = "/accounts/payout_from", method = RequestMethod.GET)
public final ResponseEntity> listPayoutFromAccounts() {
AccessorResponse> response = gateway().payouts().accounts();
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}
@RequestMapping(value = "/payouts", method = RequestMethod.POST, consumes = BaseController.MDX_MEDIA)
public final ResponseEntity createPayout(@RequestBody Payout payoutRequest) {
AccessorResponse response = gateway().payouts().create(payoutRequest);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}
@RequestMapping(value = "/payouts/{id}/cancel", method = RequestMethod.PUT)
public final ResponseEntity> cancelPayout(@PathVariable("id") String payoutId) {
AccessorResponse response = gateway().payouts().cancel(payoutId);
return new ResponseEntity<>(createMultiMapForResponse(response.getHeaders()), HttpStatus.NO_CONTENT);
}
@RequestMapping(value = "/payouts", method = RequestMethod.GET)
public final ResponseEntity> listPayouts() {
AccessorResponse> response = gateway().payouts().list();
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}
@RequestMapping(value = "/payouts/{id}", method = RequestMethod.GET)
public final ResponseEntity getPayout(@PathVariable("id") String payoutId) {
AccessorResponse response = gateway().payouts().get(payoutId);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}
@RequestMapping(value = "/recipients", method = RequestMethod.POST, consumes = BaseController.MDX_MEDIA)
public final ResponseEntity createRecipient(@RequestBody Recipient recipientRequest) {
AccessorResponse response = gateway().payouts().recipients().create(recipientRequest);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}
@RequestMapping(value = "/recipients", method = RequestMethod.GET)
public final ResponseEntity> listRecipients(@RequestParam(value = "include_payout_methods", required = false) boolean includePayoutMethods) {
AccessorResponse> response = gateway().payouts().recipients().list(includePayoutMethods);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}
@RequestMapping(value = "/recipients/{id}", method = RequestMethod.GET)
public final ResponseEntity getRecipient(@PathVariable("id") String recipientId) {
AccessorResponse response = gateway().payouts().recipients().get(recipientId);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}
@RequestMapping(value = "/recipients/{id}", method = RequestMethod.PUT, consumes = BaseController.MDX_MEDIA)
public final ResponseEntity updateRecipient(@PathVariable("id") String recipientId, @RequestBody Recipient recipientRequest) {
AccessorResponse response = gateway().payouts().recipients().update(recipientId, recipientRequest);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}
@RequestMapping(value = "/recipients/{id}", method = RequestMethod.DELETE)
public final ResponseEntity> deleteRecipient(@PathVariable("id") String recipientId) {
AccessorResponse response = gateway().payouts().recipients().delete(recipientId);
return new ResponseEntity<>(createMultiMapForResponse(response.getHeaders()), HttpStatus.NO_CONTENT);
}
@RequestMapping(value = "/recipients/{id}/payout_methods", method = RequestMethod.POST, consumes = BaseController.MDX_MEDIA)
public final ResponseEntity createPayoutMethod(@PathVariable("id") String recipientId, @RequestBody PayoutMethod payoutMethodRequest) {
AccessorResponse response = gateway().payouts().recipients().payoutMethods().create(recipientId, payoutMethodRequest);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}
@RequestMapping(value = "/recipients/{id}/payout_methods", method = RequestMethod.GET)
public final ResponseEntity> listPayoutMethods(@PathVariable("id") String recipientId) {
AccessorResponse> response = gateway().payouts().recipients().payoutMethods().list(recipientId);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}
@RequestMapping(value = "/recipients/{id}/payout_methods/{methodId}", method = RequestMethod.GET)
public final ResponseEntity getPayoutMethod(@PathVariable("id") String recipientId, @PathVariable("methodId") String methodId) {
AccessorResponse response = gateway().payouts().recipients().payoutMethods().get(recipientId, methodId);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}
@RequestMapping(value = "/recipients/{id}/payout_methods/{methodId}", method = RequestMethod.PUT, consumes = BaseController.MDX_MEDIA)
public final ResponseEntity updatePayoutMethod(@PathVariable("id") String recipientId, @PathVariable("methodId") String methodId, @RequestBody PayoutMethod payoutMethodRequest) {
AccessorResponse response = gateway().payouts().recipients().payoutMethods().update(recipientId, methodId, payoutMethodRequest);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}
@RequestMapping(value = "/recipients/{id}/payout_methods/{methodId}", method = RequestMethod.DELETE)
public final ResponseEntity> deletePayoutMethod(@PathVariable("id") String recipientId, @PathVariable("methodId") String methodId) {
AccessorResponse response = gateway().payouts().recipients().payoutMethods().delete(recipientId, methodId);
return new ResponseEntity<>(createMultiMapForResponse(response.getHeaders()), HttpStatus.NO_CONTENT);
}
@RequestMapping(value = "/payouts/enroll", method = RequestMethod.POST)
public final ResponseEntity> enroll() throws Exception {
AccessorResponse response = gateway().payouts().enroll();
return new ResponseEntity<>(createMultiMapForResponse(response.getHeaders()), HttpStatus.NO_CONTENT);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy