bjb-uim.php
4.99 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
<?php
// irul @ 20200522
/**
* Fake bjb UIM
* Dibuat berdasarkan Draft Spesifikasi API UIM v1.0
*/
class bjbUIM
{
public static function login()
{
// PAYLOAD:
// {
// "userId": "I816",
// "password": "eyJpdiI6IjQzK2N6NXpxVTFiTEJ0ajR0WVwva2tnPT0iLCJ2YWx1ZSI6InlyeEU4M1BibHNNTXg1XC9xU3NwS3NBUjBMXC9jdUtwejBQc0hoQU1WdnB0ST0iLCJtYWMiOiIzNDdiY2Q5MGFmZjViNGY0YWVmNDNiNzNkN2EyZmMwYzc0NzdlMjUzODRmMDlkOGM4ZDVlZWVhMGY0MGNlODA0In0=",
// "appId": 148
// }
$rawData = file_get_contents("php://input");
$payload = json_decode($rawData, true);
if (!$payload) {
self::echo_json(self::error_response());
} else {
extract($payload);
if (!isset($userId) || !isset($password) || !isset($appId)) {
self::echo_json(self::error_response());
} else {
self::echo_json(self::login_response());
}
}
}
private static function login_response()
{
$fake_response = array(
'status' => 'success',
'rc' => '00',
'response' => array(
'nama' => 'ANDRI MUHAMAD RAMADHAN SATRIA RASPATI',
'nip' => '15.88.9871',
'userId' => 'I816',
'kodeCabang' => 'P060',
'namaCabang' => 'GRUP HEAD OFFICE APPLICATION',
'kodeInduk' => 'P009',
'namaInduk' => 'DIVISI TEKNOLOGI INFORMASI',
'kodeKanwil' => 'K001',
'namaKanwil' => 'KANWIL 1',
'jabatan' => 'STAF G4',
'posisiPenempatan' => '-',
'hp' => '085624203225',
'email' => 'araspati@bankbjb.co.id',
'kodeGrade' => '0085',
'namaGrade' => 'G4',
'idFungsi' => '495',
'fungsiTambahan' => '-',
'limitDebet' => '0',
'limitKredit' => '0',
'id' => '20151002103451P0938539',
),
'message' => 'Transaction success.',
);
return $fake_response;
}
private static function error_response()
{
// error required user id
$error[] = array(
'status' => 'warning',
'rc' => '62',
'response' => array(
'userId' => array(
0 => 'The user id field is required.',
),
),
'message' => 'Expect required condition(s) but not given in the request parameter(s).',
);
// error required password
$error[] = array(
'status' => 'warning',
'rc' => '62',
'response' => array(
'password' => array(
0 => 'The password field is required when user id is present.',
),
),
'message' => 'Expect required condition(s) but not given in the request parameter(s).',
);
// error required app id
$error[] = array(
'status' => 'warning',
'rc' => '62',
'response' => array(
'appId' => array(
0 => 'The app id field is required.',
),
),
'message' => 'Expect required condition(s) but not given in the request parameter(s).',
);
// error wrong password
$error[] = array(
'status' => 'warning',
'rc' => '63',
'response' => 'not_valid_credentials',
'message' => 'Credentials is not valid. Please provide a correct credentials.',
);
// error app id is not found
$error[] = array(
'status' => 'info',
'rc' => '44',
'response' => array(),
'message' => 'The requested resource is not found.',
);
// error client not registered yet
$error[] = array(
'status' => 'warning',
'rc' => '52',
'response' => 'client_server_not_registered',
'message' => 'Unregister client server trying to access server.',
);
// error client got blacklist
$error[] = array(
'status' => 'warning',
'rc' => '43',
'response' => 'server_blacklisted',
'message' => ' Cannot continue the transaction. Forbidden Access.',
);
$random_number = rand(0, count($error) - 1);
return $error[$random_number];
}
private static function echo_json($data = array())
{
header('Content-type: application/json');
echo json_encode($data) . PHP_EOL;
}
private static function echo_text($data = '')
{
header('Content-type: text/html; charset=UTF-8');
echo $data . PHP_EOL;
}
}