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

com.mx.path.model.mdx.web.controller.RecurringPayoutsController 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.Frequency;
import com.mx.path.model.mdx.model.MdxList;
import com.mx.path.model.mdx.model.payout.RecurringPayout;

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 RecurringPayoutsController extends BaseController {

  @RequestMapping(value = "/users/{user_id}/recurring_payouts", method = RequestMethod.POST, consumes = BaseController.MDX_MEDIA)
  public final ResponseEntity createRecurringPayout(@RequestBody RecurringPayout recurringPayoutRequest) {
    AccessorResponse response = gateway().payouts().recurring().create(recurringPayoutRequest);
    return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
  }

  @RequestMapping(value = "/users/{user_id}/recurring_payouts/{id}/cancel", method = RequestMethod.PUT)
  public final ResponseEntity cancelRecurringPayout(@PathVariable("id") String recurringPayoutId) {
    AccessorResponse response = gateway().payouts().recurring().cancel(recurringPayoutId);
    return new ResponseEntity<>(createMultiMapForResponse(response.getHeaders()), HttpStatus.NO_CONTENT);
  }

  @RequestMapping(value = "/users/{user_id}/recurring_payouts", method = RequestMethod.GET)
  public final ResponseEntity> listRecurringPayouts() {
    AccessorResponse> response = gateway().payouts().recurring().list();
    return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
  }

  @RequestMapping(value = "/users/{user_id}/recurring_payouts/{id}", method = RequestMethod.GET)
  public final ResponseEntity getRecurringPayout(@PathVariable("id") String recurringPayoutId) {
    AccessorResponse response = gateway().payouts().recurring().get(recurringPayoutId);
    return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
  }

  @RequestMapping(value = "/users/{user_id}/recurring_payouts/{id}", method = RequestMethod.PUT, consumes = BaseController.MDX_MEDIA)
  public final ResponseEntity updateRecurringPayout(@PathVariable("id") String recurringPayoutId, @RequestBody RecurringPayout recurringPayout) {
    recurringPayout.setId(recurringPayoutId);
    AccessorResponse response = gateway().payouts().recurring().update(recurringPayoutId, recurringPayout);
    return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
  }

  @RequestMapping(value = "/users/{user_id}/recurring_payouts/{id}/skip_next", method = RequestMethod.PUT, consumes = BaseController.MDX_MEDIA)
  public final ResponseEntity skipNextRecurringPayout(@PathVariable("id") String recurringPayoutId) {
    AccessorResponse response = gateway().payouts().recurring().skipNext(recurringPayoutId);
    return new ResponseEntity<>(createMultiMapForResponse(response.getHeaders()), HttpStatus.NO_CONTENT);
  }

  @RequestMapping(value = "/frequencies/recurring_payout", method = RequestMethod.GET)
  public final ResponseEntity> listRecurringFrequencies() {
    AccessorResponse> response = gateway().payouts().recurring().frequencies();
    return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy