Skip to content

Commit ae2a242

Browse files
feat: add managed card update notification preferences
1 parent 9761fb2 commit ae2a242

6 files changed

Lines changed: 67 additions & 2 deletions

File tree

.vogue.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,22 @@ defaultRules: {}
33
packageRules:
44
- package: "com.github.mxenabled.coppuccino:com.github.mxenabled.coppuccino.gradle.plugin"
55
rules: {}
6-
suppressUntil: "2026-02-09"
6+
suppressUntil: "2026-02-28"
77
- package: "com.github.mxenabled.vogue:com.github.mxenabled.vogue.gradle.plugin"
88
rules: {}
9-
suppressUntil: "2026-02-09"
9+
suppressUntil: "2026-02-28"
10+
- package: "com.mx.path-core:gateway"
11+
rules: {}
12+
suppressUntil: "2026-02-28"
13+
- package: "com.mx.path-core:gateway-generator"
14+
rules: {}
15+
suppressUntil: "2026-02-28"
16+
- package: "com.mx.path-core:http"
17+
rules: {}
18+
suppressUntil: "2026-02-28"
19+
- package: "com.mx.path-core:platform"
20+
rules: {}
21+
suppressUntil: "2026-02-28"
22+
- package: "com.mx.path-core:testing"
23+
rules: {}
24+
suppressUntil: "2026-02-28"

mdx-models/src/main/java/com/mx/path/model/mdx/accessor/managed_card/ManagedCardBaseAccessor.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.mx.path.gateway.accessor.AccessorResponse;
1010
import com.mx.path.model.mdx.model.MdxList;
1111
import com.mx.path.model.mdx.model.managed_cards.ManagedCard;
12+
import com.mx.path.model.mdx.model.managed_cards.NotificationPreferences;
1213

1314
/**
1415
* Accessor base for managed card operations
@@ -158,4 +159,15 @@ public AccessorResponse<ManagedCard> setPin(String id, ManagedCard card) {
158159
public AccessorResponse<ManagedCard> update(String id, ManagedCard card) {
159160
throw new AccessorMethodNotImplementedException();
160161
}
162+
163+
/**
164+
* Update a managed card's notification preferences
165+
*
166+
* @return
167+
*/
168+
@GatewayAPI
169+
@API(description = "Update a managed card's notification preferences")
170+
public AccessorResponse<NotificationPreferences> updateNotificationPreferences(NotificationPreferences notificationPreferences) {
171+
throw new AccessorMethodNotImplementedException();
172+
}
161173
}

mdx-models/src/main/java/com/mx/path/model/mdx/model/Resources.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import com.mx.path.model.mdx.model.location.Location;
4545
import com.mx.path.model.mdx.model.managed_cards.Destination;
4646
import com.mx.path.model.mdx.model.managed_cards.ManagedCard;
47+
import com.mx.path.model.mdx.model.managed_cards.NotificationPreferences;
4748
import com.mx.path.model.mdx.model.managed_cards.TravelSchedule;
4849
import com.mx.path.model.mdx.model.ondemand.MdxListWrapper;
4950
import com.mx.path.model.mdx.model.ondemand.MdxOnDemandDeserializer;
@@ -255,6 +256,7 @@ public static void registerResources(GsonBuilder builder) {
255256
builder.registerTypeAdapter(ManagedCard.class, new ModelWrappableSerializer("managed_card"));
256257
builder.registerTypeAdapter(new TypeToken<MdxList<ManagedCard>>() {
257258
}.getType(), new ModelWrappableSerializer("managed_cards"));
259+
builder.registerTypeAdapter(NotificationPreferences.class, new ModelWrappableSerializer("notification_preferences"));
258260
// RemoteDeposit
259261
builder.registerTypeAdapter(RemoteDeposit.class, new ModelWrappableSerializer("remote_deposit"));
260262
builder.registerTypeAdapter(new TypeToken<MdxList<RemoteDeposit>>() {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.mx.path.model.mdx.model.managed_cards;
2+
3+
import lombok.Data;
4+
import lombok.EqualsAndHashCode;
5+
6+
import com.mx.path.model.mdx.model.MdxBase;
7+
8+
@Data
9+
@EqualsAndHashCode(callSuper = true)
10+
public final class NotificationPreferences extends MdxBase<NotificationPreferences> {
11+
12+
private Boolean allowPushNotification;
13+
}

mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/ManagedCardsController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.mx.path.gateway.accessor.AccessorResponse;
44
import com.mx.path.model.mdx.model.MdxList;
55
import com.mx.path.model.mdx.model.managed_cards.ManagedCard;
6+
import com.mx.path.model.mdx.model.managed_cards.NotificationPreferences;
67

78
import org.springframework.http.HttpStatus;
89
import org.springframework.http.ResponseEntity;
@@ -89,4 +90,9 @@ public final ResponseEntity<ManagedCard> getCvv(@PathVariable("id") String id) t
8990
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
9091
}
9192

93+
@RequestMapping(value = "/users/{userId}/managed_cards/{id}/notification_preferences", method = RequestMethod.PUT, consumes = MDX_MEDIA)
94+
public final ResponseEntity<?> updateNotificationPreferences(@RequestBody NotificationPreferences notificationPreferencesRequest) throws Exception {
95+
AccessorResponse<NotificationPreferences> response = gateway().managedCards().updateNotificationPreferences(notificationPreferencesRequest);
96+
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
97+
}
9298
}

mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/ManagedCardsControllerTest.groovy

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.mx.path.gateway.api.managed_card.ManagedCardGateway
1010
import com.mx.path.model.mdx.model.MdxList
1111
import com.mx.path.model.mdx.model.challenges.Challenge
1212
import com.mx.path.model.mdx.model.managed_cards.ManagedCard
13+
import com.mx.path.model.mdx.model.managed_cards.NotificationPreferences
1314

1415
import org.springframework.http.HttpStatus
1516

@@ -205,4 +206,20 @@ class ManagedCardsControllerTest extends Specification {
205206
verify(managedCardGateway).getUnmaskedCardNumber(managedCard.id) || true
206207
response.body == managedCard
207208
}
209+
210+
def "update notification preferences interacts with gateway"() {
211+
given:
212+
NotificationPreferences notificationPreferences = new NotificationPreferences().tap {
213+
setAllowPushNotification(false)
214+
}
215+
doReturn(new AccessorResponse<NotificationPreferences>().withResult(notificationPreferences)).when(managedCardGateway).updateNotificationPreferences(notificationPreferences)
216+
217+
when:
218+
def response = subject.updateNotificationPreferences(notificationPreferences)
219+
220+
then:
221+
verify(managedCardGateway).updateNotificationPreferences(notificationPreferences) || true
222+
response.body == notificationPreferences
223+
HttpStatus.OK == response.statusCode
224+
}
208225
}

0 commit comments

Comments
 (0)