This repository was archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathbankingAPI.js
More file actions
163 lines (128 loc) · 3.51 KB
/
bankingAPI.js
File metadata and controls
163 lines (128 loc) · 3.51 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
* @author : Alexis Chretienne
* @email : alexis.chretienne@fr.ibm.com
*
* Sample code allowing to understand how to code API in Javascript
*
* @doc : https://github.com/IBM/Banking-digitalization-using-hybrid-cloud-with-zSystem
*/
//The API Developer Portal URL
var url_api_devloper_portal = "https://api.us.apiconnect.ibmcloud.com/spbodieusibmcom-prod/developer-contest";
/*
* A customer ID. Please go to
* https://github.com/IBM/Banking-digitalization-using-hybrid-cloud-with-zSystem/tree/master/identifier
* to choose one among 1000 customer IDs.
*/
var customerID = "136949483580422232";
// Your API ClientID
var IBM_CLIENT_ID = "051d0650-dc24-4ece-bac0-63f71c36deeb";
// Your API ClientSecret
var IBM_CLIENT_SECRET = "L7xM4gN3kM7jO8uJ8oU7bT4wQ6cQ1fX3vT8uR6cK6xE4uL1gY8";
/*
* JQUERY ready
*/
$(document).ready(function() {
// Customer Information API
$("#btnCustomerInformation").click(customerInformation);
$("#btnCustomerContract").click(customerContract);
// Banking Account API
$("#btnBalanceInquiry").click(balanceInquiry);
$("#btnTransactionsInquiry").click(transactionsInquiry);
$("#btnAccountDetail").click(accountDetail);
});
/*
* Banking customer information
*
*/
/**
* Function allowing to get a banking customer's information
*
* @returns customer Information
*/
function customerInformation() {
var path = "/customers/";
var data = customerID;
doGet(path, data);
}
/**
* Function allowing to get a banking customer's contracts (cards & banking
* account)
*
* @returns a list of banking contracts
*/
function customerContract() {
var path = "/customers/contracts/";
var pathParameter = $("#inputCustomerContract").val();
doGet(path, pathParameter);
}
/*
* Banking Account information
*/
/**
* Function allowing to get a banking account's balance
*
* @returns a balance
*/
function balanceInquiry() {
var path = "/accounts/";
var pathParameter = $("#inputBalanceInquiry").val();
var queryParamaeter = "?date=2017-10-10";
var data = pathParameter + queryParamaeter;
doGet(path, data);
}
/**
* Function allowing to get last banking account's transactions
*
* @returns a list of banking transactions
*/
function transactionsInquiry() {
var path = "/accounts/transactions/";
var pathParameter = $("#inputTransactionsInquiry").val();
doGet(path, pathParameter);
}
/**
* Function allowing to get banking account's details
*
* @returns details
*/
function accountDetail() {
var path = "/accounts/details/";
var pathParameter = $("#inputAccountDetail").val();
doGet(path, pathParameter);
}
/*
* Miscellaneous function
*/
/**
* Function allowing to make a AJAX call using JQuery
*
* @param path :
* customized URL path
* @param parameter :
* path parameter + query parameters
* @returns
*/
function doGet(path, parameter) {
$.ajax({
type : 'GET',
headers : {
"x-ibm-client-id" : IBM_CLIENT_ID,
"x-ibm-client-secret" : IBM_CLIENT_SECRET
},
async : true,
crossDomain : true,
cache : false,
url : url_api_devloper_portal + path + parameter,
contentType : "application/json",
success : function(data) {
var jsonPretty = JSON.stringify(data, null, 4);
$("#result").text(jsonPretty);
},
error : function(xhr, status, error) {
$("#result").text(xhr.responseText);
},
complete : function() {
console.log("complete function GET");
}
});
}