-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathObpApiClient.java
More file actions
105 lines (82 loc) · 5.25 KB
/
ObpApiClient.java
File metadata and controls
105 lines (82 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.tesobe.obp.clientapi;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.tesobe.obp.domain.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.cloud.netflix.feign.FeignClient;
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 java.util.List;
import java.util.stream.Collectors;
@FeignClient(name="account", url="${obp.api.versionedUrl}")
public interface ObpApiClient {
//tag::my-account[]
@RequestMapping(method = RequestMethod.GET, value = "my/accounts")
Accounts getPrivateAccountsNoDetails();
default List<Account> getPrivateAccountsWithDetails() {
List<Account> accountsNoDetails = getPrivateAccountsNoDetails().getAccounts();
return accountsNoDetails.stream().map(account -> getAccount(account.getBankId(), account.getId())).collect(Collectors.toList());
}
@RequestMapping(method = RequestMethod.GET, value = "my/banks/{bankId}/accounts/{accountId}/account")
Account getAccount(@PathVariable("bankId") String bankId, @PathVariable("accountId") String accountId);
@RequestMapping(method = RequestMethod.GET, value = "banks/{bankId}/accounts/{accountId}/views")
AccountViews getViewsForAccount(@PathVariable("bankId") String bankId, @PathVariable("accountId") String accountId);
@RequestMapping(method = RequestMethod.GET, value = "banks/{bankId}/accounts/{accountId}/owner/transactions")
Transactions getTransactionsForAccount(@PathVariable("bankId") String bankId,
@PathVariable("accountId") String accountId);
@RequestMapping(method = RequestMethod.GET, value = "banks/{bankId}/accounts/{accountId}/owner/transactions/{transactionId}/transaction")
Transaction getTransactionById(@PathVariable("bankId") String bankId, @PathVariable("accountId") String accountId,
@PathVariable("transactionId") String transactionId);
@RequestMapping(method = RequestMethod.GET, value = "banks/{bankId}/accounts/{accountId}/owner/transactions")
String transferMoney(@PathVariable("bankId") String bankId, @PathVariable("accountId") String accountId, @RequestBody TransactionRequest transfer);
//end::my-account[]
@RequestMapping(method = RequestMethod.GET, value = "banks/{bankId}/accounts/{accountId}/owner/transaction-request-types")
TransactionRequestTypes getTransactionTypes(@PathVariable("bankId") String bankId, @PathVariable("accountId") String accountId);
@RequestMapping(method = RequestMethod.POST, value = "banks/{bankId}/accounts/{accountId}/owner/transaction-request-types/{transactionReqType}/transaction-requests")
String initiateTransaction(@PathVariable("bankId") String bankId, @PathVariable("accountId") String accountId,
@PathVariable("transactionReqType") String transactionReqType, @RequestBody TransactionRequest txRequest);
//tag::public-accounts[]
@RequestMapping(method = RequestMethod.GET, value = "accounts")
List<Account> getAllPublicAccountsAtAllBanks();
//end::public-accounts[]
//tag::tx-metadata[]
@RequestMapping(method = RequestMethod.POST, value = "banks/{bankId}/accounts/{accountId}/owner/transactions/{transactionId}/metadata/tags")
Transaction.Tag addTag(@PathVariable("bankId") String bankId, @PathVariable("accountId") String accountId,
@PathVariable("transactionId") String transactionId, @RequestBody Transaction.Tag tag);
@RequestMapping(method = RequestMethod.DELETE, value = "banks/{bankId}/accounts/{accountId}/owner/transactions/{transactionId}/metadata/tags/{tagId}")
void deleteTag(@PathVariable("bankId") String bankId, @PathVariable("accountId") String accountId,
@PathVariable("transactionId") String transactionId, @PathVariable("tagId") String tagId);
@RequestMapping(method = RequestMethod.POST, value = "banks/{bankId}/accounts/{accountId}/owner/transactions/{transactionId}/metadata/where")
void addLocation(@PathVariable("bankId") String bankId, @PathVariable("accountId") String accountId,
@PathVariable("transactionId") String transactionId, @RequestBody Where location);
@RequestMapping(method = RequestMethod.DELETE, value = "banks/{bankId}/accounts/{accountId}/owner/transactions/{transactionId}/metadata/where")
void deleteLocation(@PathVariable("bankId") String bankId, @PathVariable("accountId") String accountId,
@PathVariable("transactionId") String transactionId);
//end::tx-metadata[]
@Data
class Transactions {
private List<Transaction> transactions;
}
@Data
@NoArgsConstructor @AllArgsConstructor
class Where {
@JsonProperty("where")
private Location location;
}
@Data
class TransactionRequestTypes {
@JsonProperty("transaction_request_types")
private List<TransactionRequestType> transactionRequests;
}
@Data
class AccountViews {
private List<AccountView> views;
}
@Data
class Accounts {
private List<Account> accounts;
}
}