-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathtransactions.js
342 lines (334 loc) · 12.1 KB
/
transactions.js
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
var nock = require('nock');
nock('https://devapi.currencycloud.com:443')
.post('/v2/authenticate/api', {
"login_id": "[email protected]",
"api_key": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
})
.reply(200, {"auth_token": "38d5ae520d6987decfe7c12aa5ec4422"});
nock('https://devapi.currencycloud.com:443')
.post('/v2/conversions/create', {
"buy_currency": "EUR",
"sell_currency": "GBP",
"fixed_side": "buy",
"amount": "10000.23",
"reason": "Settling invoices",
"term_agreement": "true"
})
.reply(200, {
"id": "4a709856-2f20-472d-8ebf-9f2826cec174",
"settlement_date": "2017-11-01T19:36:53+00:00",
"conversion_date": "2017-11-01T19:36:53+00:00",
"short_reference": "20171027-ZGBRYR",
"creator_contact_id": "8f639ab2-2b85-4327-9eb1-01ee4f0c77bc",
"account_id": "78618e58-da3c-447f-ad59-1796accfeff9",
"currency_pair": "EURGBP",
"status": "awaiting_funds",
"buy_currency": "EUR",
"sell_currency": "GBP",
"client_buy_amount": "10000.23",
"client_sell_amount": "7215.17",
"fixed_side": "buy",
"mid_market_rate": "0.7216",
"core_rate": "0.7215",
"partner_rate": "",
"partner_buy_amount": "0.00",
"partner_sell_amount": "0.00",
"client_rate": "0.7215",
"deposit_required": false,
"deposit_amount": "0.00",
"deposit_currency": "",
"deposit_status": "not_required",
"deposit_required_at": "",
"payment_ids": [],
"created_at": "2017-11-01T19:36:53+00:00",
"updated_at": "2017-11-01T19:36:53+00:00"
});
nock('https://devapi.currencycloud.com:443')
.get('/v2/transactions/find')
.query({"order": "created_at", "order_asc_desc": "desc", "per_page": "5"})
.reply(200, {
"transactions": [{
"id": "1a96d33f-93b9-4f76-bfe7-e548db281948",
"balance_id": "07ee18e7-430e-4743-a42e-676061718a41",
"account_id": "3a7d2f90-ae1f-493c-a8d6-26ad43700259",
"currency": "GBP",
"amount": "10000.23",
"balance_amount": null,
"type": "credit",
"related_entity_type": "conversion",
"related_entity_id": "4a709856-2f20-472d-8ebf-9f2826cec174",
"related_entity_short_reference": "20171101-NXTTGQ",
"status": "pending",
"reason": "",
"settles_at": "2017-11-03T14:00:00+00:00",
"created_at": "2017-11-01T19:36:53+00:00",
"updated_at": "2017-11-01T19:36:53+00:00",
"completed_at": "",
"action": "conversion"
}, {
"id": "4dad8a06-a4e7-413d-afab-df3e7670d4eb",
"balance_id": "07ee18e7-430e-4743-a42e-676061718a41",
"account_id": "3a7d2f90-ae1f-493c-a8d6-26ad43700259",
"currency": "GBP",
"amount": "10000.23",
"balance_amount": null,
"type": "debit",
"related_entity_type": "conversion",
"related_entity_id": "dddd209d-7db7-410b-823e-f9161ec3d903",
"related_entity_short_reference": "20171101-NXTTGQ",
"status": "pending",
"reason": "",
"settles_at": "2017-11-03T14:00:00+00:00",
"created_at": "2017-11-01T19:36:53+00:00",
"updated_at": "2017-11-01T19:36:53+00:00",
"completed_at": "",
"action": "conversion"
}, {
"id": "4abcbf1a-2d4f-4210-9721-acf252de91b1",
"balance_id": "07ee18e7-430e-4743-a42e-676061718a41",
"account_id": "3a7d2f90-ae1f-493c-a8d6-26ad43700259",
"currency": "GBP",
"amount": "10000.23",
"balance_amount": null,
"type": "debit",
"related_entity_type": "conversion",
"related_entity_id": "5cf629aa-fc36-41ce-bc62-3fdad31ed3cb",
"related_entity_short_reference": "20171101-YNTJYR",
"status": "pending",
"reason": "",
"settles_at": "2017-11-03T14:00:00+00:00",
"created_at": "2017-11-01T19:35:35+00:00",
"updated_at": "2017-11-01T19:35:35+00:00",
"completed_at": "",
"action": "conversion"
}, {
"id": "79137c85-ff72-4f29-a77e-5aac02240046",
"balance_id": "07ee18e7-430e-4743-a42e-676061718a41",
"account_id": "3a7d2f90-ae1f-493c-a8d6-26ad43700259",
"currency": "GBP",
"amount": "10000.23",
"balance_amount": null,
"type": "credit",
"related_entity_type": "conversion",
"related_entity_id": "5cf629aa-fc36-41ce-bc62-3fdad31ed3cb",
"related_entity_short_reference": "20171101-YNTJYR",
"status": "pending",
"reason": "",
"settles_at": "2017-11-03T14:00:00+00:00",
"created_at": "2017-11-01T19:35:34+00:00",
"updated_at": "2017-11-01T19:35:35+00:00",
"completed_at": "",
"action": "conversion"
}, {
"id": "3f576c89-fb43-45d6-adf3-8d51b9902d6a",
"balance_id": "07ee18e7-430e-4743-a42e-676061718a41",
"account_id": "3a7d2f90-ae1f-493c-a8d6-26ad43700259",
"currency": "GBP",
"amount": "10000.23",
"balance_amount": null,
"type": "debit",
"related_entity_type": "conversion",
"related_entity_id": "ab0564af-b8ee-41d2-89ee-04d217f00b72",
"related_entity_short_reference": "20171101-FVLTRW",
"status": "pending",
"reason": "",
"settles_at": "2017-11-03T14:00:00+00:00",
"created_at": "2017-11-01T19:24:09+00:00",
"updated_at": "2017-11-01T19:24:09+00:00",
"completed_at": "",
"action": "conversion"
}],
"pagination": {
"total_entries": 57,
"total_pages": 12,
"current_page": 1,
"per_page": 5,
"previous_page": -1,
"next_page": 2,
"order": "created_at",
"order_asc_desc": "desc"
}
});
nock('https://devapi.currencycloud.com:443')
.get('/v2/transactions/1a96d33f-93b9-4f76-bfe7-e548db281948')
.reply(200, {
"id": "1a96d33f-93b9-4f76-bfe7-e548db281948",
"balance_id": "07ee18e7-430e-4743-a42e-676061718a41",
"account_id": "3a7d2f90-ae1f-493c-a8d6-26ad43700259",
"currency": "GBP",
"amount": "10000.23",
"balance_amount": null,
"type": "credit",
"related_entity_type": "conversion",
"related_entity_id": "4a709856-2f20-472d-8ebf-9f2826cec174",
"related_entity_short_reference": "20171101-NXTTGQ",
"status": "pending",
"reason": "",
"settles_at": "2017-11-03T14:00:00+00:00",
"created_at": "2017-11-01T19:36:53+00:00",
"updated_at": "2017-11-01T19:36:53+00:00",
"completed_at": "",
"action": "conversion"
});
nock('https://devapi.currencycloud.com:443')
.post('/v2/conversions/create', {
"buy_currency": "EUR",
"sell_currency": "GBP",
"fixed_side": "buy",
"amount": "10000.23",
"reason": "Settling invoices",
"term_agreement": "true"
})
.reply(200, {
"id": "d2126864-44c8-4f19-9510-79482816c65b",
"settlement_date": "2017-11-01T19:36:55+00:00",
"conversion_date": "2017-11-01T19:36:55+00:00",
"short_reference": "20171027-CMCRZC",
"creator_contact_id": "8f639ab2-2b85-4327-9eb1-01ee4f0c77bc",
"account_id": "78618e58-da3c-447f-ad59-1796accfeff9",
"currency_pair": "EURGBP",
"status": "awaiting_funds",
"buy_currency": "EUR",
"sell_currency": "GBP",
"client_buy_amount": "10000.23",
"client_sell_amount": "7215.17",
"fixed_side": "buy",
"mid_market_rate": "0.7216",
"core_rate": "0.7215",
"partner_rate": "",
"partner_buy_amount": "0.00",
"partner_sell_amount": "0.00",
"client_rate": "0.7215",
"deposit_required": false,
"deposit_amount": "0.00",
"deposit_currency": "",
"deposit_status": "not_required",
"deposit_required_at": "",
"payment_ids": [],
"created_at": "2017-11-01T19:36:55+00:00",
"updated_at": "2017-11-01T19:36:55+00:00"
});
nock('https://devapi.currencycloud.com:443')
.get('/v2/transactions/find')
.query({"order": "created_at", "order_asc_desc": "desc", "per_page": "5"})
.reply(200, {
"transactions": [{
"id": "0c5c75f6-70ea-4f04-92ee-6148860c3b2b",
"balance_id": "07ee18e7-430e-4743-a42e-676061718a41",
"account_id": "3a7d2f90-ae1f-493c-a8d6-26ad43700259",
"currency": "GBP",
"amount": "10000.23",
"balance_amount": null,
"type": "credit",
"related_entity_type": "conversion",
"related_entity_id": "d2126864-44c8-4f19-9510-79482816c65b",
"related_entity_short_reference": "20171101-FYBZPX",
"status": "pending",
"reason": "",
"settles_at": "2017-11-03T14:00:00+00:00",
"created_at": "2017-11-01T19:36:55+00:00",
"updated_at": "2017-11-01T19:36:55+00:00",
"completed_at": "",
"action": "conversion"
}, {
"id": "dc80c557-1218-4fec-82be-fc340fe882bb",
"balance_id": "07ee18e7-430e-4743-a42e-676061718a41",
"account_id": "3a7d2f90-ae1f-493c-a8d6-26ad43700259",
"currency": "GBP",
"amount": "10000.23",
"balance_amount": null,
"type": "debit",
"related_entity_type": "conversion",
"related_entity_id": "d2126864-44c8-4f19-9510-79482816c65b",
"related_entity_short_reference": "20171101-FYBZPX",
"status": "pending",
"reason": "",
"settles_at": "2017-11-03T14:00:00+00:00",
"created_at": "2017-11-01T19:36:55+00:00",
"updated_at": "2017-11-01T19:36:55+00:00",
"completed_at": "",
"action": "conversion"
}, {
"id": "1a96d33f-93b9-4f76-bfe7-e548db281948",
"balance_id": "07ee18e7-430e-4743-a42e-676061718a41",
"account_id": "3a7d2f90-ae1f-493c-a8d6-26ad43700259",
"currency": "GBP",
"amount": "10000.23",
"balance_amount": null,
"type": "credit",
"related_entity_type": "conversion",
"related_entity_id": "dddd209d-7db7-410b-823e-f9161ec3d903",
"related_entity_short_reference": "20171101-NXTTGQ",
"status": "pending",
"reason": "",
"settles_at": "2017-11-03T14:00:00+00:00",
"created_at": "2017-11-01T19:36:53+00:00",
"updated_at": "2017-11-01T19:36:53+00:00",
"completed_at": "",
"action": "conversion"
}, {
"id": "4dad8a06-a4e7-413d-afab-df3e7670d4eb",
"balance_id": "07ee18e7-430e-4743-a42e-676061718a41",
"account_id": "3a7d2f90-ae1f-493c-a8d6-26ad43700259",
"currency": "GBP",
"amount": "10000.23",
"balance_amount": null,
"type": "debit",
"related_entity_type": "conversion",
"related_entity_id": "dddd209d-7db7-410b-823e-f9161ec3d903",
"related_entity_short_reference": "20171101-NXTTGQ",
"status": "pending",
"reason": "",
"settles_at": "2017-11-03T14:00:00+00:00",
"created_at": "2017-11-01T19:36:53+00:00",
"updated_at": "2017-11-01T19:36:53+00:00",
"completed_at": "",
"action": "conversion"
}, {
"id": "4abcbf1a-2d4f-4210-9721-acf252de91b1",
"balance_id": "07ee18e7-430e-4743-a42e-676061718a41",
"account_id": "3a7d2f90-ae1f-493c-a8d6-26ad43700259",
"currency": "GBP",
"amount": "10000.23",
"balance_amount": null,
"type": "debit",
"related_entity_type": "conversion",
"related_entity_id": "5cf629aa-fc36-41ce-bc62-3fdad31ed3cb",
"related_entity_short_reference": "20171101-YNTJYR",
"status": "pending",
"reason": "",
"settles_at": "2017-11-03T14:00:00+00:00",
"created_at": "2017-11-01T19:35:35+00:00",
"updated_at": "2017-11-01T19:35:35+00:00",
"completed_at": "",
"action": "conversion"
}],
"pagination": {
"total_entries": 59,
"total_pages": 12,
"current_page": 1,
"per_page": 5,
"previous_page": -1,
"next_page": 2,
"order": "created_at",
"order_asc_desc": "desc"
}
});
nock('https://devapi.currencycloud.com:443', {"encodedQueryParams": true})
.get('/v2/transactions/sender/e68301d3-5b04-4c1d-8f8b-13a9b8437040')
.query({"id": "e68301d3-5b04-4c1d-8f8b-13a9b8437040"})
.reply(200, {
"id": "e68301d3-5b04-4c1d-8f8b-13a9b8437040",
"amount": "1701.51",
"currency": "EUR",
"additional_information": "USTRD-0001",
"value_date": "2018-07-04T00:00:00+00:00",
"sender": "FR7615589290001234567890113, CMBRFR2BARK, Debtor, FR, Centre ville",
"receiving_account_number": null,
"receiving_account_iban": "GB99OXPH94665099600083",
"created_at": "2018-07-04T14:57:38+00:00",
"updated_at": "2018-07-04T14:57:39+00:00"
});
nock('https://devapi.currencycloud.com:443')
.post('/v2/authenticate/close_session')
.reply(200, {});