Skip to content

Commit 83958a5

Browse files
author
Tess Stoddard
committed
fix: replace accounts with sources for p2p transfers
1 parent 6c4983e commit 83958a5

File tree

10 files changed

+94
-37
lines changed

10 files changed

+94
-37
lines changed

mdx-models/src/main/java/com/mx/path/model/mdx/accessor/p2p_transfer/P2PTransferBaseAccessor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
public class P2PTransferBaseAccessor extends Accessor {
2222
@GatewayAPI
2323
@Getter(AccessLevel.PROTECTED)
24-
private AccountBaseAccessor accounts;
24+
private SourceBaseAccessor sources;
2525

2626
@GatewayAPI
2727
@Getter(AccessLevel.PROTECTED)
@@ -95,21 +95,21 @@ public AccessorResponse<P2PTransfer> update(String id, P2PTransfer p2pTransfer)
9595
}
9696

9797
/**
98-
* Accessor for account operations
98+
* Accessor for source operations
9999
*
100100
* @return accessor
101101
*/
102102
@API
103-
public AccountBaseAccessor accounts() {
104-
return accounts;
103+
public SourceBaseAccessor sources() {
104+
return sources;
105105
}
106106

107107
/**
108-
* Sets account accessor
109-
* @param accounts
108+
* Sets source accessor
109+
* @param sources
110110
*/
111-
public void setAccounts(AccountBaseAccessor accounts) {
112-
this.accounts = accounts;
111+
public void setSources(SourceBaseAccessor sources) {
112+
this.sources = sources;
113113
}
114114

115115
/**

mdx-models/src/main/java/com/mx/path/model/mdx/accessor/p2p_transfer/AccountBaseAccessor.java renamed to mdx-models/src/main/java/com/mx/path/model/mdx/accessor/p2p_transfer/SourceBaseAccessor.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77
import com.mx.path.gateway.accessor.Accessor;
88
import com.mx.path.gateway.accessor.AccessorResponse;
99
import com.mx.path.model.mdx.model.MdxList;
10-
import com.mx.path.model.mdx.model.account.Account;
10+
import com.mx.path.model.mdx.model.p2p_transfer.Source;
1111

1212
/**
13-
* Accessor base for P2P transfer account operations
13+
* Accessor base for P2P transfer source operations
1414
*/
1515
@GatewayClass
16-
@API(specificationUrl = "https://developer.mx.com/drafts/mdx/p2p_transfer/index.html#p2p-transfer-accounts")
17-
public class AccountBaseAccessor extends Accessor {
18-
public AccountBaseAccessor() {
16+
@API(specificationUrl = "https://developer.mx.com/drafts/mdx/p2p_transfer/index.html#sources")
17+
public class SourceBaseAccessor extends Accessor {
18+
public SourceBaseAccessor() {
1919
}
2020

2121
/**
22-
* Lists all p2p transfer accounts
22+
* Lists all p2p transfer sources
2323
*
24-
* @return MdxList&lt;Account&gt;
24+
* @return MdxList&lt;Source&gt;
2525
*/
2626
@GatewayAPI
27-
@API(description = "Lists all accounts for P2P transfers")
28-
public AccessorResponse<MdxList<Account>> list() {
27+
@API(description = "Lists all sources for P2P transfers")
28+
public AccessorResponse<MdxList<Source>> list() {
2929
throw new AccessorMethodNotImplementedException();
3030
}
3131
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import com.mx.path.model.mdx.model.p2p_transfer.Duration;
6565
import com.mx.path.model.mdx.model.p2p_transfer.P2PTransfer;
6666
import com.mx.path.model.mdx.model.p2p_transfer.RecurringP2PTransfer;
67+
import com.mx.path.model.mdx.model.p2p_transfer.Source;
6768
import com.mx.path.model.mdx.model.payment.Bill;
6869
import com.mx.path.model.mdx.model.payment.Enrollment;
6970
import com.mx.path.model.mdx.model.payment.Merchant;
@@ -402,6 +403,10 @@ private static void registerP2PTransferModels(GsonBuilder builder) {
402403
builder.registerTypeAdapter(RecurringP2PTransfer.class, new ModelWrappableSerializer("recurring_p2p_transfer"));
403404
builder.registerTypeAdapter(new TypeToken<MdxList<RecurringP2PTransfer>>() {
404405
}.getType(), new ModelWrappableSerializer("recurring_p2p_transfers"));
406+
// Sources
407+
builder.registerTypeAdapter(Source.class, new ModelWrappableSerializer("source"));
408+
builder.registerTypeAdapter(new TypeToken<MdxList<Source>>() {
409+
}.getType(), new ModelWrappableSerializer("sources"));
405410
}
406411

407412
private static void registerPaymentsModels(GsonBuilder builder) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.mx.path.model.mdx.model.p2p_transfer;
2+
3+
import java.math.BigDecimal;
4+
5+
import lombok.Data;
6+
import lombok.EqualsAndHashCode;
7+
8+
import com.mx.path.model.mdx.model.MdxBase;
9+
import com.mx.path.model.mdx.model.MdxNested;
10+
11+
@MdxNested
12+
@Data
13+
@EqualsAndHashCode(callSuper = true)
14+
public class AccountData extends MdxBase<AccountData> {
15+
private String accountId;
16+
private BigDecimal availableBalance;
17+
private BigDecimal balance;
18+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.mx.path.model.mdx.model.p2p_transfer;
2+
3+
import lombok.Data;
4+
import lombok.EqualsAndHashCode;
5+
6+
import com.mx.path.model.mdx.model.MdxBase;
7+
import com.mx.path.model.mdx.model.MdxNested;
8+
9+
@MdxNested
10+
@Data
11+
@EqualsAndHashCode(callSuper = true)
12+
public class DebitCardData extends MdxBase<DebitCardData> {
13+
private String description;
14+
private String lastFour;
15+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
@EqualsAndHashCode(callSuper = true)
1515
public class P2PTransfer extends MdxBase<P2PTransfer> {
1616
private String id;
17-
private String accountId;
1817
private BigDecimal amount;
1918
private MdxList<Challenge> challenges;
2019
private String confirmationId;
@@ -25,5 +24,6 @@ public class P2PTransfer extends MdxBase<P2PTransfer> {
2524
private String recipientVerificationQuestion;
2625
private LocalDate sendOn;
2726
private LocalDate sentOn;
27+
private String sourceId;
2828
private String status;
2929
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
@EqualsAndHashCode(callSuper = true)
1313
public class RecurringP2PTransfer extends MdxBase<RecurringP2PTransfer> {
1414
private String id;
15-
private String accountId;
1615
private BigDecimal amount;
1716
private String confirmationId;
1817
private String deliveryMethod;
@@ -24,5 +23,6 @@ public class RecurringP2PTransfer extends MdxBase<RecurringP2PTransfer> {
2423
private String recipientVerificationAnswer;
2524
private String recipientVerificationQuestion;
2625
private LocalDate startOn;
26+
private String sourceId;
2727
private String status;
2828
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.mx.path.model.mdx.model.p2p_transfer;
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 class Source extends MdxBase<Source> {
11+
private String id;
12+
private SourceType type;
13+
private AccountData accountData;
14+
private DebitCardData debitCardData;
15+
16+
public enum SourceType {
17+
ACCOUNT, DEBIT_CARD
18+
}
19+
}

mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/P2PTransferAccountsController.java renamed to mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/P2PTransferSourcesController.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.mx.path.gateway.accessor.AccessorResponse;
44
import com.mx.path.model.mdx.model.MdxList;
5-
import com.mx.path.model.mdx.model.account.Account;
5+
import com.mx.path.model.mdx.model.p2p_transfer.Source;
66

77
import org.springframework.http.HttpStatus;
88
import org.springframework.http.ResponseEntity;
@@ -12,10 +12,10 @@
1212

1313
@RestController
1414
@RequestMapping(value = "{clientId}", produces = BaseController.MDX_MEDIA)
15-
public class P2PTransferAccountsController extends BaseController {
16-
@RequestMapping(value = "/users/{userId}/accounts/p2p_transfer", method = RequestMethod.GET)
17-
public final ResponseEntity<MdxList<Account>> list() {
18-
AccessorResponse<MdxList<Account>> response = gateway().p2pTransfers().accounts().list();
15+
public class P2PTransferSourcesController extends BaseController {
16+
@RequestMapping(value = "/users/{userId}/p2p_transfers/sources", method = RequestMethod.GET)
17+
public final ResponseEntity<MdxList<Source>> list() {
18+
AccessorResponse<MdxList<Source>> response = gateway().p2pTransfers().sources().list();
1919
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
2020
}
2121
}

mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/P2PTransferAccountsControllerTest.groovy renamed to mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/P2PTransferSourcesControllerTest.groovy

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@ import static org.mockito.Mockito.verify
77

88
import com.mx.path.gateway.accessor.AccessorResponse
99
import com.mx.path.gateway.api.Gateway
10-
import com.mx.path.gateway.api.p2p_transfer.AccountGateway
1110
import com.mx.path.gateway.api.p2p_transfer.P2PTransferGateway
11+
import com.mx.path.gateway.api.p2p_transfer.SourceGateway
1212
import com.mx.path.model.mdx.model.MdxList
13-
import com.mx.path.model.mdx.model.account.Account
13+
import com.mx.path.model.mdx.model.p2p_transfer.Source
1414

1515
import org.springframework.http.HttpStatus
1616

1717
import spock.lang.Specification
1818

19-
class P2PTransferAccountsControllerTest extends Specification {
20-
P2PTransferAccountsController subject
19+
class P2PTransferSourcesControllerTest extends Specification {
20+
P2PTransferSourcesController subject
2121
Gateway gateway
2222
P2PTransferGateway p2pTransferGateway
23-
AccountGateway accountGateway
23+
SourceGateway sourceGateway
2424

2525
def setup() {
26-
subject = new P2PTransferAccountsController()
26+
subject = new P2PTransferSourcesController()
2727
p2pTransferGateway = mock(P2PTransferGateway)
28-
accountGateway = mock(AccountGateway)
28+
sourceGateway = mock(SourceGateway)
2929

30-
doReturn(accountGateway).when(p2pTransferGateway).accounts()
30+
doReturn(sourceGateway).when(p2pTransferGateway).sources()
3131
gateway = spy(Gateway.builder().clientId("client-1234").p2pTransfers(p2pTransferGateway).build())
3232
}
3333

@@ -38,17 +38,17 @@ class P2PTransferAccountsControllerTest extends Specification {
3838
def "list interacts with gateway"() {
3939
given:
4040
BaseController.setGateway(gateway)
41-
def accounts = new MdxList().tap {
42-
add(new Account())
41+
def sources = new MdxList().tap {
42+
add(new Source())
4343
}
44-
doReturn(new AccessorResponse<MdxList<Account>>().withResult(accounts)).when(accountGateway).list()
44+
doReturn(new AccessorResponse<MdxList<Source>>().withResult(sources)).when(sourceGateway).list()
4545

4646
when:
4747
def result = subject.list()
4848

4949
then:
5050
HttpStatus.OK == result.statusCode
51-
result.body == accounts
52-
verify(accountGateway).list() || true
51+
result.body == sources
52+
verify(sourceGateway).list() || true
5353
}
5454
}

0 commit comments

Comments
 (0)