forked from Mangopay/mangopay2-nodejs-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWallets.js
85 lines (75 loc) · 2.55 KB
/
Wallets.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
/**
* @module Wallets
* @desc [MangoPay Wallets API Reference](https://docs.mangopay.com/endpoints/v2.01/wallets)
*/
var Service = require('../service');
var Wallet = require('../models/Wallet');
var Transaction = require('../models/Transaction');
var Wallets = Service.extend({
/**
* Create new wallet
* @param {Object} wallet Wallet object
* @param {Function} callback Callback function
* @param {Object} options Request options
* @return {Object} Request promise
*/
create: function(wallet, callback, options) {
options = this._api._getOptions(callback, options, {
data: wallet,
dataClass: Wallet
});
return this._api.method('wallets_create', callback, options);
},
/**
* Get pay-in
* @param {number} walletId Wallet identifier
* @param {Function} callback Callback function
* @param {Object} options Request options
* @return {Object} Request promise
*/
get: function(walletId, callback, options) {
options = this._api._getOptions(callback, options, {
path: {
id: walletId
},
dataClass: Wallet
});
return this._api.method('wallets_get', callback, options);
},
/**
* Update wallet
* @param {Object} wallet Wallet object
* @param {Function} callback Callback function
* @param {Object} options Request options
* @return {Object} Request promise
*/
update: function(wallet, callback, options) {
options = this._api._getOptions(callback, options, {
path: {
id: wallet.Id
},
data: wallet,
dataClass: Wallet
});
return this._api.method('wallets_save', callback, options);
},
/**
* Get transactions for the wallet
* @param {number} walletId Wallet identifier
* @param {Function} callback Callback function
* @param {Object} options Request options
* @return {Object} Request promise
*/
getTransactions: function(walletId, callback, options) {
if (options && !options.hasOwnProperty('parameters'))
Object.assign(options, {parameters: {...options}});
options = this._api._getOptions(callback, options, {
path: {
id: walletId
},
dataClass: Transaction
});
return this._api.method('wallets_alltransactions', callback, options);
}
});
module.exports = Wallets;