forked from Mangopay/mangopay2-nodejs-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CardPreAuthorizations.js
75 lines (66 loc) · 2.66 KB
/
CardPreAuthorizations.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
/**
* @module CardPreAuthorizations
* @desc [MangoPay Card Pre-Authorizations API Reference](https://docs.mangopay.com/endpoints/v2.01/preauthorizations)
*/
var _ = require('underscore');
var Service = require('../service');
var CardPreAuthorization = require('../models/CardPreAuthorization');
var Transaction = require('../models/Transaction');
var CardPreAuthorizations = Service.extend({
/**
* Create new pre-authorization
* @param {Object} cardPreAuthorization CardPreAuthorization object or properties hash
* @param {Function} callback Callback function
* @param {Object} options Request options
* @return {Object} Promise of the request
*/
create: function(cardPreAuthorization, callback, options) {
options = this._api._getOptions(callback, options, {
data: cardPreAuthorization,
dataClass: CardPreAuthorization
});
return this._api.method('preauthorization_create', callback, options);
},
/**
* Get pre-authorization object
* @param {number} cardPreAuthorizationId PreAuthorization identifier
* @param {Function} callback Callback function
* @param {Object} options Request options
* @return {Object} Request promise
*/
get: function(cardPreAuthorizationId, callback, options) {
options = this._api._getOptions(callback, options, {
path: {
id: cardPreAuthorizationId
},
dataClass: CardPreAuthorization
});
return this._api.method('preauthorization_get', callback, options);
},
/**
* Update pre-authorization object
* @param {Object} cardPreAuthorization CardPreAuthorization object of properties hash
* @param {function} callback
* @param {Object} options
* @return {Object} Request promise
*/
update: function(cardPreAuthorization, callback, options) {
options = this._api._getOptions(callback, options, {
data: cardPreAuthorization,
path: {
id: cardPreAuthorization.Id
},
dataClass: CardPreAuthorization
});
return this._api.method('preauthorization_save', callback, options);
},
getTransactions: function(cardPreAuthorizationId, callback, options) {
options = this._api._getOptions(callback, options, {
path: {
id: cardPreAuthorizationId
}
});
return this._api.method('preauthorization_transactions_get', callback, options);
},
});
module.exports = CardPreAuthorizations;