-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathTransfers.js
87 lines (76 loc) · 2.74 KB
/
Transfers.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
/**
* @module Transfers
* @desc [MangoPay Transfers API Reference](https://docs.mangopay.com/endpoints/v2.01/transfers)
*/
var Service = require('../service');
var Transfer = require('../models/Transfer');
var Refund = require('../models/Refund');
var Transfers = Service.extend({
/**
* Create new transfer
* @param {Object} transfer Transfer object
* @param {Function} callback Callback function
* @param {Object} options Request options
* @return {Object} Request promise
*/
create: function(transfer, callback, options) {
options = this._api._getOptions(callback, options, {
data: transfer,
dataClass: Transfer
});
return this._api.method('transfers_create', callback, options);
},
/**
* Get transfer
* @param {number} transferId Transfer identifier
* @param {Function} callback Callback function
* @param {Object} options Request options
* @return {Object} Request promise
*/
get: function(transferId, callback, options) {
options = this._api._getOptions(callback, options, {
path: {
id: transferId
},
dataClass: Transfer
});
return this._api.method('transfers_get', callback, options);
},
/**
* Create refund for transfer object
* @param {number} transferId Transfer identifier
* @param {Object} refund Refund object
* @param {Function} callback Callback function
* @param {Object} options Request options
* @return {Object} Request promise
*/
createRefund: function(transferId, refund, callback, options) {
options = this._api._getOptions(callback, options, {
data: refund,
path: {
id: transferId
},
dataClass: Refund
});
return this._api.method('transfers_createrefunds', callback, options);
},
/**
* Gets list of Refunds of a Transfer
* @param {number} transferId Transfer identifier
* @param {function} callback Callback function
* @param {Object} options Request options
* @return {Object} Request promise
*/
getRefunds: function(transferId, callback, options) {
if (options && !options.hasOwnProperty('parameters'))
Object.assign(options, {parameters: {...options}});
options = this._api._getOptions(callback, options, {
path: {
id: transferId
},
dataClass: Refund
});
return this._api.method('refunds_get_for_transfer', callback, options);
}
});
module.exports = Transfers;