-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathReports.js
61 lines (52 loc) · 1.86 KB
/
Reports.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
/**
* @module Reports
* @desc [MangoPay Reports API Reference](https://docs.mangopay.com/endpoints/v2.01/reporting)
*/
var Service = require('../service');
var Report = require('../models/Report');
var Reports = Service.extend({
/**
* Create a report
* @param {Object} report Report Data
* @param {Function} callback Callback function
* @param {Object} options Request options
* @return {Object} Request promise
*/
create: function(report, callback, options) {
options = this._api._getOptions(callback, options, {
data: report,
dataClass: Report
});
if (!report.ReportType) {
throw new Error('Please specify ReportType in the report data (ex: "TRANSACTIONS", "WALLETS")')
}
var reportType = report.ReportType.toLowerCase();
return this._api.method('reports_' + report.ReportType.toLowerCase() + '_create', callback, options);
},
/**
* Get a report
* @param {number} reportId Report Id
* @param {Function} callback Callback function
* @param {Object} options Request options
* @return {Object} Request promise
*/
get: function(reportId, callback, options) {
options = this._api._getOptions(callback, options, {
path: {
id: reportId
},
dataClass: Report
});
return this._api.method('reports_get', callback, options);
},
/**
* Get all reports
* @param {Function} callback Callback function
* @param {Object} options Request options
* @return {Object} Request promise
*/
getAll: function(callback, options) {
return this._api.method('reports_all', callback, options);
}
});
module.exports = Reports;