Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
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.account.alerts.AccountAlert;
import com.mx.path.model.mdx.model.account.alerts.DeliveryMethod;
import com.mx.path.model.mdx.model.alerts.Alert;
import com.mx.path.model.mdx.model.alerts.DeliveryMethod;

/**
* Accessor for account alert operations
*/
@GatewayClass
@API(description = "Access to account alerts", specificationUrl = "https://developer.mx.com/drafts/mdx/accounts/#accounts-alerts")
@API(description = "Access to account alerts", specificationUrl = "https://developer.mx.com/drafts/mdx/accounts/#alerts")
public abstract class AccountAlertBaseAccessor extends Accessor {

public AccountAlertBaseAccessor() {
Expand All @@ -40,7 +40,7 @@ public AccountAlertBaseAccessor(AccessorConfiguration configuration) {
*/
@GatewayAPI
@API(description = "Get account alert")
public AccessorResponse<AccountAlert> get(String accountId, String alertId) {
public AccessorResponse<Alert> get(String accountId, String alertId) {
throw new AccessorMethodNotImplementedException();
}

Expand All @@ -52,7 +52,7 @@ public AccessorResponse<AccountAlert> get(String accountId, String alertId) {
*/
@GatewayAPI
@API(description = "List account alerts")
public AccessorResponse<MdxList<AccountAlert>> list(String accountId) {
public AccessorResponse<MdxList<Alert>> list(String accountId) {
throw new AccessorMethodNotImplementedException();
}

Expand All @@ -65,7 +65,7 @@ public AccessorResponse<MdxList<AccountAlert>> list(String accountId) {
*/
@GatewayAPI
@API(description = "Update an account alert")
public AccessorResponse<AccountAlert> update(String accountId, AccountAlert accountAlert) {
public AccessorResponse<Alert> update(String accountId, Alert accountAlert) {
throw new AccessorMethodNotImplementedException();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.mx.path.model.mdx.accessor.managed_card;

import com.mx.path.core.common.accessor.API;
import com.mx.path.core.common.accessor.AccessorMethodNotImplementedException;
import com.mx.path.core.common.gateway.GatewayAPI;
import com.mx.path.core.common.gateway.GatewayClass;
import com.mx.path.gateway.accessor.Accessor;
import com.mx.path.gateway.accessor.AccessorResponse;
import com.mx.path.model.mdx.model.MdxList;
import com.mx.path.model.mdx.model.alerts.Alert;
import com.mx.path.model.mdx.model.alerts.DeliveryMethod;
import com.mx.path.model.mdx.model.managed_cards.ManagedCard;

/**
* Accessor for managed card alert operations
*/
@GatewayClass
@API(description = "Access to managed card alerts", specificationUrl = "https://developer.mx.com/drafts/mdx/managed_cards/#alerts")
public abstract class ManagedCardAlertBaseAccessor extends Accessor {
public ManagedCardAlertBaseAccessor() {
}

/**
* Get a managed card alert
*
* @param cardId
* @param alertId
* @return
*/
@GatewayAPI
@API(description = "Get managed card alert")
public AccessorResponse<Alert> get(String cardId, String alertId) {
throw new AccessorMethodNotImplementedException();
}

/**
* List managed card alerts
*
* @param cardId
* @return
*/
@GatewayAPI
@API(description = "List managed card alerts")
public AccessorResponse<MdxList<Alert>> list(String cardId) {
throw new AccessorMethodNotImplementedException();
}

/**
* Update a managed card alert
*
* @param cardId
* @param alert
* @return
*/
@GatewayAPI
@API(description = "Update a managed card alert")
public AccessorResponse<Alert> update(String cardId, Alert alert) {
throw new AccessorMethodNotImplementedException();
}

/**
* List delivery methods
*
* @param cardId
* @param alertId
* @return
*/
@GatewayAPI
@API(description = "List delivery methods")
public AccessorResponse<MdxList<DeliveryMethod>> deliveryMethods(String cardId, String alertId) {
throw new AccessorMethodNotImplementedException();
}

/**
* List managed cards eligible for alerts
*
* @return
*/
@GatewayAPI
@API(description = "List managed cards eligible for alerts")
public AccessorResponse<MdxList<ManagedCard>> cards() {
throw new AccessorMethodNotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.mx.path.model.mdx.accessor.managed_card;

import lombok.AccessLevel;
import lombok.Getter;

import com.mx.path.core.common.accessor.API;
import com.mx.path.core.common.accessor.AccessorMethodNotImplementedException;
import com.mx.path.core.common.gateway.GatewayAPI;
Expand All @@ -19,6 +22,9 @@
@GatewayClass
@API(specificationUrl = "https://developer.mx.com/drafts/mdx/managed_cards/#mdx-managed-cards")
public abstract class ManagedCardBaseAccessor extends Accessor {
@GatewayAPI
@Getter(AccessLevel.PROTECTED)
private ManagedCardAlertBaseAccessor alerts;

public ManagedCardBaseAccessor() {
}
Expand Down Expand Up @@ -170,4 +176,22 @@ public AccessorResponse<ManagedCard> update(String id, ManagedCard card) {
public AccessorResponse<NotificationPreferences> updateNotificationPreferences(String id, NotificationPreferences notificationPreferences) {
throw new AccessorMethodNotImplementedException();
}

/**
* Accessor for managed card alerts
*
* @return accessor
*/
@API
public ManagedCardAlertBaseAccessor alerts() {
return alerts;
}

/**
* Sets managed card alert accessor
* @param alerts
*/
public void setAlerts(ManagedCardAlertBaseAccessor alerts) {
this.alerts = alerts;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import com.mx.path.model.mdx.model.account.StopPaymentReason;
import com.mx.path.model.mdx.model.account.Transaction;
import com.mx.path.model.mdx.model.account.TransactionsPage;
import com.mx.path.model.mdx.model.account.alerts.AccountAlert;
import com.mx.path.model.mdx.model.account.alerts.DeliveryMethod;
import com.mx.path.model.mdx.model.ach_transfer.AchAccount;
import com.mx.path.model.mdx.model.ach_transfer.AchScheduledTransfer;
import com.mx.path.model.mdx.model.ach_transfer.AchTransfer;
import com.mx.path.model.mdx.model.alerts.Alert;
import com.mx.path.model.mdx.model.alerts.DeliveryMethod;
import com.mx.path.model.mdx.model.authorization.Authorization;
import com.mx.path.model.mdx.model.check.CheckImage;
import com.mx.path.model.mdx.model.credit_report.CreditReport;
Expand Down Expand Up @@ -285,8 +285,8 @@ public static void registerResources(GsonBuilder builder) {
registerPaymentsModels(builder);
// Register multistage transfer models
registerMultistageTransferModels(builder);
// Register account alert models
registerAccountAlertModels(builder);
// Register alert models
registerAlertModels(builder);
// Register product models
registerProductModels(builder);
// Register P2P transfer models
Expand Down Expand Up @@ -446,10 +446,10 @@ private static void registerMultistageTransferModels(GsonBuilder builder) {
}.getType(), new ModelWrappableSerializer("repayments"));
}

private static void registerAccountAlertModels(GsonBuilder builder) {
// AccountAlert
builder.registerTypeAdapter(AccountAlert.class, new ModelWrappableSerializer("alert"));
builder.registerTypeAdapter(new TypeToken<MdxList<AccountAlert>>() {
private static void registerAlertModels(GsonBuilder builder) {
// Alert
builder.registerTypeAdapter(Alert.class, new ModelWrappableSerializer("alert"));
builder.registerTypeAdapter(new TypeToken<MdxList<Alert>>() {
}.getType(), new ModelWrappableSerializer("alerts"));
// DeliveryMethod
builder.registerTypeAdapter(new TypeToken<MdxList<DeliveryMethod>>() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mx.path.model.mdx.model.account.alerts;
package com.mx.path.model.mdx.model.alerts;

import java.util.List;

Expand All @@ -10,7 +10,7 @@

@EqualsAndHashCode(callSuper = true)
@Data
public class AccountAlert extends MdxBase<AccountAlert> {
public class Alert extends MdxBase<Alert> {
private List<Challenge> challenges;
private List<AlertCriteria> criteria;
private List<String> deliveryMethodIds;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mx.path.model.mdx.model.account.alerts;
package com.mx.path.model.mdx.model.alerts;

import lombok.Data;
import lombok.EqualsAndHashCode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mx.path.model.mdx.model.account.alerts;
package com.mx.path.model.mdx.model.alerts;

import lombok.Data;
import lombok.EqualsAndHashCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
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.account.alerts.AccountAlert;
import com.mx.path.model.mdx.model.account.alerts.DeliveryMethod;
import com.mx.path.model.mdx.model.alerts.Alert;
import com.mx.path.model.mdx.model.alerts.DeliveryMethod;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -18,23 +18,23 @@
@RequestMapping(value = "{clientId}")
public class AccountAlertsController extends BaseController {
@RequestMapping(value = "/users/{userId}/accounts/{accountId}/alerts/{id}", method = RequestMethod.GET)
public final ResponseEntity<AccountAlert> getAlert(@PathVariable("accountId") String accountId, @PathVariable("id") String alertId) {
public final ResponseEntity<Alert> getAlert(@PathVariable("accountId") String accountId, @PathVariable("id") String alertId) {
ensureFeature("accounts");
AccessorResponse<AccountAlert> response = gateway().accounts().accountAlerts().get(accountId, alertId);
AccessorResponse<Alert> response = gateway().accounts().accountAlerts().get(accountId, alertId);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}

@RequestMapping(value = "/users/{userId}/accounts/{accountId}/alerts", method = RequestMethod.GET, produces = BaseController.MDX_MEDIA)
public final ResponseEntity<MdxList<AccountAlert>> getAlertList(@PathVariable("accountId") String accountId) {
public final ResponseEntity<MdxList<Alert>> getAlertList(@PathVariable("accountId") String accountId) {
ensureFeature("accounts");
AccessorResponse<MdxList<AccountAlert>> response = gateway().accounts().accountAlerts().list(accountId);
AccessorResponse<MdxList<Alert>> response = gateway().accounts().accountAlerts().list(accountId);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}

@RequestMapping(value = "/users/{userId}/accounts/{accountId}/alerts/{id}", method = RequestMethod.PUT, consumes = BaseController.MDX_MEDIA)
public final ResponseEntity<AccountAlert> updateAlert(@PathVariable("accountId") String accountId, @RequestBody AccountAlert accountAlert) {
public final ResponseEntity<Alert> updateAlert(@PathVariable("accountId") String accountId, @RequestBody Alert accountAlert) {
ensureFeature("accounts");
AccessorResponse<AccountAlert> response = gateway().accounts().accountAlerts().update(accountId, accountAlert);
AccessorResponse<Alert> response = gateway().accounts().accountAlerts().update(accountId, accountAlert);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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.alerts.Alert;
import com.mx.path.model.mdx.model.alerts.DeliveryMethod;
import com.mx.path.model.mdx.model.managed_cards.ManagedCard;

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}")
public class ManagedCardAlertsController extends BaseController {
@RequestMapping(value = "/users/{userId}/managed_cards/{cardId}/alerts/{id}", method = RequestMethod.GET)
public final ResponseEntity<Alert> getAlert(@PathVariable("cardId") String cardId, @PathVariable("id") String alertId) {
AccessorResponse<Alert> response = gateway().managedCards().alerts().get(cardId, alertId);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}

@RequestMapping(value = "/users/{userId}/managed_cards/{cardId}/alerts", method = RequestMethod.GET, produces = BaseController.MDX_MEDIA)
public final ResponseEntity<MdxList<Alert>> getAlertList(@PathVariable("cardId") String cardId) {
AccessorResponse<MdxList<Alert>> response = gateway().managedCards().alerts().list(cardId);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}

@RequestMapping(value = "/users/{userId}/managed_cards/{cardId}/alerts/{id}", method = RequestMethod.PUT, consumes = BaseController.MDX_MEDIA)
public final ResponseEntity<Alert> updateAlert(@PathVariable("cardId") String cardId, @RequestBody Alert alert) {
AccessorResponse<Alert> response = gateway().managedCards().alerts().update(cardId, alert);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}

@RequestMapping(value = "/users/{userId}/managed_cards/{cardId}/alerts/{id}/delivery_methods", method = RequestMethod.GET, produces = BaseController.MDX_MEDIA)
public final ResponseEntity<MdxList<DeliveryMethod>> getDeliveryMethods(@PathVariable("cardId") String cardId, @PathVariable("id") String alertId) {
AccessorResponse<MdxList<DeliveryMethod>> response = gateway().managedCards().alerts().deliveryMethods(cardId, alertId);
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}

@RequestMapping(value = "/users/{userId}/managed_cards/alert", method = RequestMethod.GET, produces = BaseController.MDX_MEDIA)
public final ResponseEntity<MdxList<ManagedCard>> getCards() {
AccessorResponse<MdxList<ManagedCard>> response = gateway().managedCards().alerts().cards();
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import com.mx.path.gateway.api.account.AccountAlertGateway
import com.mx.path.gateway.api.account.AccountGateway
import com.mx.path.model.mdx.model.MdxList
import com.mx.path.model.mdx.model.account.Account
import com.mx.path.model.mdx.model.account.alerts.AccountAlert
import com.mx.path.model.mdx.model.account.alerts.DeliveryMethod

import org.springframework.http.HttpStatus
import com.mx.path.model.mdx.model.alerts.Alert
import com.mx.path.model.mdx.model.alerts.DeliveryMethod

import spock.lang.Specification

Expand Down Expand Up @@ -43,10 +41,10 @@ class AccountAlertsControllerTest extends Specification {
given:
def accountId = "account-id"
def alertId = "alert-id"
def accountAlert = new AccountAlert()
def accountAlert = new Alert()

when:
doReturn(new AccessorResponse<AccountAlert>().withResult(accountAlert)).when(accountAlertGateway).get(accountId, alertId)
doReturn(new AccessorResponse<Alert>().withResult(accountAlert)).when(accountAlertGateway).get(accountId, alertId)
def response = subject.getAlert(accountId, alertId)

then:
Expand All @@ -57,11 +55,11 @@ class AccountAlertsControllerTest extends Specification {
def "getAlertList interacts with gateway"() {
given:
def accountId = "account-id"
def alerts = new MdxList<AccountAlert>()
alerts.add(new AccountAlert())
def alerts = new MdxList<Alert>()
alerts.add(new Alert())

when:
doReturn(new AccessorResponse<MdxList<AccountAlert>>().withResult(alerts)).when(accountAlertGateway).list(accountId)
doReturn(new AccessorResponse<MdxList<Alert>>().withResult(alerts)).when(accountAlertGateway).list(accountId)
def response = subject.getAlertList(accountId)

then:
Expand All @@ -72,10 +70,10 @@ class AccountAlertsControllerTest extends Specification {
def "updateAlert interacts with gateway"() {
given:
def accountId = "account-id"
def accountAlert = new AccountAlert()
def accountAlert = new Alert()

when:
doReturn(new AccessorResponse<AccountAlert>().withResult(accountAlert)).when(accountAlertGateway).update(accountId, accountAlert)
doReturn(new AccessorResponse<Alert>().withResult(accountAlert)).when(accountAlertGateway).update(accountId, accountAlert)
def response = subject.updateAlert(accountId, accountAlert)

then:
Expand Down
Loading
Loading