Skip to content

Commit

Permalink
feat: adding new enrollment and Settings api in controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishna Potluri committed Sep 21, 2023
1 parent a4ccb8f commit 4cafa6a
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
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.payment.Enrollment;
import com.mx.path.model.mdx.model.payment.Payment;
import com.mx.path.model.mdx.model.payment.Settings;

/**
* Accessor base for payment operations
Expand Down Expand Up @@ -51,6 +53,54 @@ public PaymentBaseAccessor(AccessorConfiguration configuration) {
super(configuration);
}

/**
* Enrollment status
*
* @param enrollmentRequest
* @return
*/
@GatewayAPI
@API(description = "Get the Enrollment status")
public AccessorResponse<Enrollment> enrollmentStatus(Enrollment enrollmentRequest) {
throw new AccessorMethodNotImplementedException();
}

/**
* Update Enrollment status
*
* @param enrollmentRequest
* @return
*/
@GatewayAPI
@API(description = "Update the Enrollment status")
public AccessorResponse<Enrollment> updateEnrollmentStatus(Enrollment enrollmentRequest) {
throw new AccessorMethodNotImplementedException();
}

/**
* Get Payment Settings
*
* @param settings
* @return
*/
@GatewayAPI
@API(description = "Get the current Payment Settings")
public AccessorResponse<Settings> settings(Settings settings) {
throw new AccessorMethodNotImplementedException();
}

/**
* Update Payment Settings
*
* @param settings
* @return
*/
@GatewayAPI
@API(description = "Update the Payment Settings")
public AccessorResponse<Settings> updateSettings(Settings settings) {
throw new AccessorMethodNotImplementedException();
}

/**
* List accounts to pay from
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@
import com.mx.path.model.mdx.model.ondemand.mixins.TransactionsPageMixin;
import com.mx.path.model.mdx.model.origination.Origination;
import com.mx.path.model.mdx.model.payment.Bill;
import com.mx.path.model.mdx.model.payment.Enrollment;
import com.mx.path.model.mdx.model.payment.Merchant;
import com.mx.path.model.mdx.model.payment.MerchantCategory;
import com.mx.path.model.mdx.model.payment.Payee;
import com.mx.path.model.mdx.model.payment.Payment;
import com.mx.path.model.mdx.model.payment.RecurringPayment;
import com.mx.path.model.mdx.model.payment.Settings;
import com.mx.path.model.mdx.model.payout.Challenge;
import com.mx.path.model.mdx.model.payout.ChallengeAnswer;
import com.mx.path.model.mdx.model.payout.Option;
Expand Down Expand Up @@ -341,6 +343,8 @@ private static void registerPaymentsModels(GsonBuilder builder) {
builder.registerTypeAdapter(new TypeToken<MdxList<Bill>>() {
}.getType(), new ModelWrappableSerializer("bills"));
// Payment
builder.registerTypeAdapter(Enrollment.class, new ModelWrappableSerializer("enrollment"));
builder.registerTypeAdapter(Settings.class, new ModelWrappableSerializer("settings"));
builder.registerTypeAdapter(Payment.class, new ModelWrappableSerializer("payment"));
builder.registerTypeAdapter(new TypeToken<MdxList<Payment>>() {
}.getType(), new ModelWrappableSerializer("payments"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.mx.path.model.mdx.model.payment;

import java.util.List;

import com.google.gson.annotations.SerializedName;
import com.mx.path.model.mdx.model.MdxBase;
import com.mx.path.model.mdx.model.id.MfaChallenge;

public final class Enrollment extends MdxBase<Enrollment> {
@SerializedName("is_active")
private Boolean isActive;

private List<MfaChallenge> challenges;

public Enrollment() {
}

public Boolean getActive() {
return isActive;
}

public void setActive(Boolean active) {
isActive = active;
}

public List<MfaChallenge> getChallenges() {
return challenges;
}

public void setChallenges(List<MfaChallenge> challenges) {
this.challenges = challenges;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.mx.path.model.mdx.model.payment;

import java.util.List;

import com.mx.path.model.mdx.model.MdxBase;
import com.mx.path.model.mdx.model.id.MfaChallenge;

public final class Settings extends MdxBase<Settings> {
private List<MfaChallenge> challenges;

public Settings() {
}

public List<MfaChallenge> getChallenges() {
return challenges;
}

public void setChallenges(List<MfaChallenge> challenges) {
this.challenges = challenges;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
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.payment.Enrollment;
import com.mx.path.model.mdx.model.payment.Payment;
import com.mx.path.model.mdx.model.payment.Settings;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -17,6 +19,30 @@
@RequestMapping(value = "{clientId}/users/{user_id}", produces = BaseController.MDX_MEDIA)
public class PaymentsController extends BaseController {

@RequestMapping(value = "/payments/enrollment", method = RequestMethod.GET, consumes = BaseController.MDX_MEDIA)
public final ResponseEntity<Enrollment> getPaymentEnrollStatus(@RequestBody Enrollment enrollmentRequest) {
AccessorResponse<Enrollment> response = gateway().payments().enrollmentStatus(enrollmentRequest);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}

@RequestMapping(value = "/payments/enrollment", method = RequestMethod.PUT, consumes = BaseController.MDX_MEDIA)
public final ResponseEntity<Enrollment> setPaymentEnrollStatus(@RequestBody Enrollment enrollmentRequest) {
AccessorResponse<Enrollment> response = gateway().payments().updateEnrollmentStatus(enrollmentRequest);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}

@RequestMapping(value = "/payments/settings", method = RequestMethod.GET, consumes = BaseController.MDX_MEDIA)
public final ResponseEntity<Settings> getPaymentSettings(@RequestBody Settings settingsRequest) {
AccessorResponse<Settings> response = gateway().payments().settings(settingsRequest);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}

@RequestMapping(value = "/payments/settings", method = RequestMethod.PUT, consumes = BaseController.MDX_MEDIA)
public final ResponseEntity<Settings> setPaymentSettings(Settings settingsRequest) {
AccessorResponse<Settings> response = gateway().payments().updateSettings(settingsRequest);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}

@RequestMapping(value = "/payments", method = RequestMethod.POST, consumes = BaseController.MDX_MEDIA)
public final ResponseEntity<Payment> createPayment(@RequestBody Payment paymentRequest) {
AccessorResponse<Payment> response = gateway().payments().create(paymentRequest);
Expand Down

0 comments on commit 4cafa6a

Please sign in to comment.