-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
102 lines (93 loc) · 2.22 KB
/
app.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
const yargs = require('yargs')
const utils = require('./utils/utils.js')
if (!process.env.GC_ACCESS_TOKEN) {
console.log('Make sure you define your access token in .env file!')
process.exit()
}
//Create getPayment Status Command
yargs.command({
command: 'getPayment',
describe: 'Get current status for payment ID',
builder: {
id: {
describe: 'Payment ID',
demandOption: true,
type: 'string'
}
},
handler(argv) {
utils.getPayment(argv.id)
}
})
//Create createPayment Status Command
yargs.command({
command: 'createPayment',
describe: 'Processes a new payment',
builder: {
mandate: {
describe: 'Mandate ID',
demandOption: true,
type: 'string'
},
amount: {
describe: 'Payment amount',
demandOption: true,
type: 'string'
},
currency: {
describe: 'Payment currency',
demandOption: true,
type: 'string'
}
},
handler(argv) {
utils.createPayment(argv.mandate, argv.amount, argv.currency)
}
})
// Create listPayments Command
yargs.command({
command: 'listPayments',
describe: 'Lists the last 5 payment IDs',
handler(argv) {
utils.listPayments()
}
})
// Create createCustomer Command
yargs.command({
command: 'createCustomer',
describe: 'Creates customer object',
handler(argv) {
utils.createCustomer()
}
})
//Create createCustomerBankAccount Status Command
yargs.command({
command: 'createCustomerBankAccount',
describe: 'Add a bank account',
builder: {
customer: {
describe: 'Customer ID',
demandOption: true,
type: 'string'
}
},
handler(argv) {
utils.createCustomerBankAccount(argv.customer)
}
})
//Create createMandate Status Command
yargs.command({
command: 'createMandate',
describe: 'Add a mandate',
builder: {
bankAccount: {
describe: 'Bank Account ID',
demandOption: true,
type: 'string'
}
},
handler(argv) {
utils.createMandate(argv.bankAccount)
}
})
yargs.parse()