Skip to content

Commit e377868

Browse files
committed
CS-2170: Renamed response and types
1 parent b06d400 commit e377868

File tree

7 files changed

+48
-48
lines changed

7 files changed

+48
-48
lines changed

src/main/java/co/dapi/ACH.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package co.dapi;
22

3-
import co.dapi.response.CreatePullResponse;
4-
import co.dapi.response.GetPullResponse;
3+
import co.dapi.response.CreateACHPullResponse;
4+
import co.dapi.response.GetACHPullResponse;
55
import co.dapi.types.UserInput;
66
import com.google.gson.JsonSyntaxException;
77

@@ -17,7 +17,7 @@ public ACH(Config config) {
1717
this.config = config;
1818
}
1919

20-
public CreatePullResponse createPull(PullTransfer transfer, String accessToken, String userSecret, String operationID, UserInput[] userInputs) throws IOException {
20+
public CreateACHPullResponse createPull(PullTransfer transfer, String accessToken, String userSecret, String operationID, UserInput[] userInputs) throws IOException {
2121

2222
// Create the request body of this call
2323
CreatePullRequest bodyObj = new CreatePullRequest(transfer, this.config.getAppSecret(), userSecret,
@@ -35,9 +35,9 @@ public CreatePullResponse createPull(PullTransfer transfer, String accessToken,
3535

3636

3737
// Convert the got response to the wanted response type
38-
CreatePullResponse resp = null;
38+
CreateACHPullResponse resp = null;
3939
try {
40-
resp = DapiRequest.jsonAgent.fromJson(respJson, CreatePullResponse.class);
40+
resp = DapiRequest.jsonAgent.fromJson(respJson, CreateACHPullResponse.class);
4141
} catch (JsonSyntaxException e) {
4242
// Empty catch, cause the handling code is below
4343
}
@@ -46,13 +46,13 @@ public CreatePullResponse createPull(PullTransfer transfer, String accessToken,
4646
if (resp == null || (resp.getStatus() == null && !resp.getType().isPresent())) {
4747
// If the got response wasn't a JSON string, resp will be null, and if
4848
// it didn't have the 'status' field, getStatus() will return null.
49-
return new CreatePullResponse("UNEXPECTED_RESPONSE", "Unexpected response body");
49+
return new CreateACHPullResponse("UNEXPECTED_RESPONSE", "Unexpected response body");
5050
}
5151

5252
return resp;
5353
}
5454

55-
public GetPullResponse getPull(String accessToken, String userSecret, String operationID, UserInput[] userInputs) throws IOException {
55+
public GetACHPullResponse getPull(String accessToken, String userSecret, String operationID, UserInput[] userInputs) throws IOException {
5656

5757
// Create the request body of this call
5858
GetPullRequest bodyObj = new GetPullRequest(this.config.getAppSecret(), userSecret, operationID, userInputs);
@@ -68,9 +68,9 @@ public GetPullResponse getPull(String accessToken, String userSecret, String ope
6868
String respJson = DapiRequest.Do(bodyJson, DapiRequest.Dapi_URL + "/v2" + bodyObj.action, headers);
6969

7070
// Convert the got response to the wanted response type
71-
GetPullResponse resp = null;
71+
GetACHPullResponse resp = null;
7272
try {
73-
resp = DapiRequest.jsonAgent.fromJson(respJson, GetPullResponse.class);
73+
resp = DapiRequest.jsonAgent.fromJson(respJson, GetACHPullResponse.class);
7474
} catch (JsonSyntaxException e) {
7575
// Empty catch, cause the handling code is below
7676
}
@@ -79,7 +79,7 @@ public GetPullResponse getPull(String accessToken, String userSecret, String ope
7979
if (resp == null || (resp.getStatus() == null && !resp.getType().isPresent())) {
8080
// If the got response wasn't a JSON string, resp will be null, and if
8181
// it didn't have the 'status' field, getStatus() will return null.
82-
return new GetPullResponse("UNEXPECTED_RESPONSE", "Unexpected response body");
82+
return new GetACHPullResponse("UNEXPECTED_RESPONSE", "Unexpected response body");
8383
}
8484

8585
return resp;

src/main/java/co/dapi/DapiApp.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,10 @@ public GetAccountsMetadataResponse getAccountsMetadata(String accessToken, Strin
308308
* @param userSecret retrieved from the user login.
309309
* @param operationID retrieved from the previous call's response.
310310
* @param userInputs built from the previous call's response, and the required user input.
311-
* @return an {@link CreatePullResponse}.
311+
* @return an {@link CreateACHPullResponse}.
312312
* @throws IOException in case of trouble happened while executing the request or reading the response.
313313
*/
314-
public CreatePullResponse createACHPull(ACH.PullTransfer transfer, String accessToken, String userSecret, String operationID, UserInput[] userInputs) throws IOException {
314+
public CreateACHPullResponse createACHPull(ACH.PullTransfer transfer, String accessToken, String userSecret, String operationID, UserInput[] userInputs) throws IOException {
315315
return this.ach.createPull(transfer, accessToken, userSecret, operationID, userInputs);
316316
}
317317

@@ -323,10 +323,10 @@ public CreatePullResponse createACHPull(ACH.PullTransfer transfer, String access
323323
* @param userSecret retrieved from the user login.
324324
* @param operationID OperationID of the createACHPull request
325325
* @param userInputs built from the previous call's response, and the required user input.
326-
* @return an {@link GetPullResponse}.
326+
* @return an {@link GetACHPullResponse}.
327327
* @throws IOException in case of trouble happened while executing the request or reading the response.
328328
*/
329-
public GetPullResponse getACHPull(String accessToken, String userSecret, String operationID, UserInput[] userInputs) throws IOException {
329+
public GetACHPullResponse getACHPull(String accessToken, String userSecret, String operationID, UserInput[] userInputs) throws IOException {
330330
return this.ach.getPull(accessToken, userSecret, operationID, userInputs);
331331
}
332332

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package co.dapi.response;
2+
3+
public class CreateACHPullResponse extends BaseResponse {
4+
CreateACHPullResponse() {
5+
super();
6+
}
7+
8+
public CreateACHPullResponse(String errType, String errMsg) {
9+
super(errType, errMsg);
10+
}
11+
}

src/main/java/co/dapi/response/CreatePullResponse.java

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package co.dapi.response;
2+
3+
import co.dapi.types.ACHPullTransferInfo;
4+
5+
import java.util.Optional;
6+
7+
public class GetACHPullResponse extends BaseResponse {
8+
private ACHPullTransferInfo transfer;
9+
10+
GetACHPullResponse() {
11+
super();
12+
}
13+
14+
public GetACHPullResponse(String errType, String errMsg) {
15+
super(errType, errMsg);
16+
}
17+
18+
public Optional<ACHPullTransferInfo> getTransfer() {
19+
return Optional.ofNullable(transfer);
20+
}
21+
}

src/main/java/co/dapi/response/GetPullResponse.java

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/main/java/co/dapi/types/PullTransfer.java renamed to src/main/java/co/dapi/types/ACHPullTransferInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package co.dapi.types;
22

3-
public class PullTransfer {
3+
public class ACHPullTransferInfo {
44
private final Float amount;
55
private final String status;
66
private final Currency currency;
77

8-
public PullTransfer(Float amount, String status, Currency currency) {
8+
public ACHPullTransferInfo(Float amount, String status, Currency currency) {
99
this.amount = amount;
1010
this.status = status;
1111
this.currency = currency;

0 commit comments

Comments
 (0)