-
Notifications
You must be signed in to change notification settings - Fork 41
/
CardRegistrations.js
64 lines (57 loc) · 2.23 KB
/
CardRegistrations.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
/**
* @module CardRegistrations
* @desc [MangoPay Card Registration API Reference](https://docs.mangopay.com/endpoints/v2.01/cards)
*/
var _ = require('underscore');
var Service = require('../service');
var CardRegistration = require('../models/CardRegistration');
var CardRegistrations = Service.extend({
/**
* Create new card registration
* @param {Object} cardRegistration CardRegistration object or properties hash
* @param {Function} callback Callback function
* @param {Object} options Request options
* @return {Object} Promise of the request
*/
create: function(cardRegistration, callback, options) {
options = this._api._getOptions(callback, options, {
data: cardRegistration,
dataClass: CardRegistration
});
return this._api.method('cardregistration_create', callback, options);
},
/**
* Get registration
* @param {number} cardRegistrationId Registration identifier
* @param {Function} callback Callback function
* @param {Object} options Request options
* @return {Object} Request promise
*/
get: function(cardRegistrationId, callback, options) {
options = this._api._getOptions(callback, options, {
path: {
id: cardRegistrationId
},
dataClass: CardRegistration
});
return this._api.method('cardregistration_get', callback, options);
},
/**
* Update card registration
* @param {Object} cardRegistration CardPreAuthorization object of properties hash
* @param {function} callback Callback function
* @param {Object} options Request options
* @return {Object} Request promise
*/
update: function(cardRegistration, callback, options) {
options = this._api._getOptions(callback, options, {
data: cardRegistration,
path: {
id: cardRegistration.Id
},
dataClass: CardRegistration
});
return this._api.method('cardregistration_save', callback, options);
}
});
module.exports = CardRegistrations;