UNPKG

4.39 kBPlain TextView Raw
1
2interface IError {
3 code: string;
4 name: string;
5 message: string;
6 action: string
7}
8
9const errorsMap = [
10 // General Errors
11 {
12 code : '001',
13 name : 'unauthorizedAccess',
14 message: 'Unauthorized Access'
15 },
16 {
17 code : '002',
18 name : 'databaseError',
19 message: 'Database error'
20 },
21 {
22 code : '003',
23 name : 'inputParameterIsInvalid',
24 message: 'Input parameter is invalid'
25 },
26 {
27 code : '004',
28 name : 'systemError',
29 message: 'System error'
30 },
31 {
32 code : '005',
33 name : 'invalidMerchantID',
34 message: 'Invalid Merchant ID'
35 }, {
36 code : '006',
37 name : 'invalidPlayerPIN',
38 message: 'Invalid Player PIN'
39 },
40 {
41 code : '007',
42 name : 'unableToFindConnectionIdFromPaymentToken',
43 message: 'Unable to find connection ID from Payment Token'
44 },
45 {
46 code : '008',
47 name : 'sessionTimedOut',
48 message: 'Session timed out'
49 },
50 {
51 code : '009',
52 name : 'invalidStoreId',
53 message: 'Invalid Store ID'
54 },
55 {
56 code : '010',
57 name : 'unableToProcessThePreAuthorization',
58 message: 'Unable to process the Pre-Authorization'
59 },
60 {
61 code : '011',
62 name : 'errorAtCreateAlias', //TODO J.P its not decided if its gonna be used or not
63 message: 'Error at create alias'
64 },
65 {
66 code : '012',
67 name : 'invalidPlayerId', //TODO J.P its not decided if its gonna be used or not
68 message: 'Invalid playerId'
69 },
70 {
71 code : '013',
72 name : 'ticketValidationError',
73 message: 'The tickets validations has error(s)'
74 },
75 {
76 code : '014',
77 name : 'playerHasLiveToken',
78 message: 'Player has LIVE token'
79 },
80 {
81 code : '015',
82 name : 'unableToProcessSmartPick',
83 message: 'Unable to process the smart pick from feed'
84 },
85 //Authentication Errors
86 {
87 code : '101',
88 name : 'invalidCredentials',
89 message: 'Invalid Credentials'
90 },
91 {
92 code : '102',
93 name : 'unableToGetAuthToken',
94 message: 'Unable to get Auth Token'
95 },
96 {
97 code : '103',
98 name : 'accountLockedDueToSeveralUnsuccessfulLoginAttempts',
99 message: 'Account locked due to several unsuccessful login attempts'
100 },
101 {
102 code : '104',
103 name : 'playerIsNotEnrolled',
104 message: 'Player is not enrolled'
105 },
106 {
107 code : '105',
108 name : 'playerAccountIsNotActive',
109 message: 'Player account is not active'
110 }, {
111 code : '106',
112 name : 'unableToCancelTransaction',
113 message: 'Unable to cancel transaction'
114 },
115 {
116 code : '107',
117 name : 'unableToConnectToBPPHost ',
118 message: 'Unable to connect to BPP host'
119 },
120
121 //Payment Errors
122 {
123 code : '201',
124 name : 'invalidOrExpiredPaymentToken',
125 message: 'Invalid or Expired Payment Token'
126 },
127 {
128 code : '202',
129 name : 'errorProcessingPaymentTransaction',
130 message: 'Error processing payment transaction'
131 },
132 {
133 code : '203',
134 name : 'paymentTokenIsNotValidAtStoreMOPLocation',
135 message: 'Payment Token is not valid at store MOP location'
136 },
137 {
138 code : '204',
139 name : 'amountDoesNotMatch',
140 message: 'Amount does not match'
141 },
142 {
143 code : '205',
144 name : 'InsufficientFunds',
145 message: 'Insufficient Funds'
146 }, {
147 code : '206',
148 name : 'unableToCancelFundsAuthorization',
149 message: 'Unable to cancel funds authorization'
150 },
151 {
152 code : '207',
153 name : 'wrongAmountValue', //TODO J.P its not decided if its gonna be used or not
154 message: 'Wrong amount value'
155 },
156 {
157 code : '208',
158 name : 'paymentTransactionCouldNotBeCreated', //TODO J.P its not decided if its gonna be used or not
159 message: 'The payment transaction could not be created. An Unknown error occurred'
160 },
161 {
162 code : '209',
163 name : 'invalidTransaction', //TODO J.P its not decided if its gonna be used or not
164 message: 'Invalid Transaction'
165 },
166 {
167 code : '210',
168 name : 'errorsAtGetCreditCards',
169 message: 'Getting the cards and bank info could not be retrieved'
170 }
171
172];
173
174export class Errors {
175 private errorsMap: Array<any>;
176
177 constructor() {
178 this.errorsMap = errorsMap;
179 }
180
181 getErrorByName(name: string) {
182
183 const respFilter = this.errorsMap.find(error => error.name === name);
184
185 if (respFilter) {
186 return respFilter;
187 }
188
189 return name;
190
191 }
192
193}