Skip to content

Commit 95070e5

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

File tree

8 files changed

+80
-23
lines changed

8 files changed

+80
-23
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
* Accessor base for P2P transfer account 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
/**

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+
}
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
15+
public class P2PTransferSourcesController extends BaseController {
16+
@RequestMapping(value = "/users/{userId}/p2p_transfers/sources", method = RequestMethod.GET)
1717
public final ResponseEntity<MdxList<Account>> list() {
18-
AccessorResponse<MdxList<Account>> response = gateway().p2pTransfers().accounts().list();
18+
AccessorResponse<MdxList<Account>> 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: 9 additions & 9 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
1313
import com.mx.path.model.mdx.model.account.Account
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

@@ -41,14 +41,14 @@ class P2PTransferAccountsControllerTest extends Specification {
4141
def accounts = new MdxList().tap {
4242
add(new Account())
4343
}
44-
doReturn(new AccessorResponse<MdxList<Account>>().withResult(accounts)).when(accountGateway).list()
44+
doReturn(new AccessorResponse<MdxList<Account>>().withResult(accounts)).when(sourceGateway).list()
4545

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

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

0 commit comments

Comments
 (0)