-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathsubscription.js
43 lines (36 loc) · 1003 Bytes
/
subscription.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
'use strict';
let AttributeSetter = require('./attribute_setter').AttributeSetter;
let Transaction = require('./transaction').Transaction;
class Subscription extends AttributeSetter {
static initClass() {
this.Source = {
Api: 'api',
ControlPanel: 'control_panel',
Recurring: 'recurring'
};
this.Status = {
Active: 'Active',
Canceled: 'Canceled',
Expired: 'Expired',
PastDue: 'Past Due',
Pending: 'Pending',
All() {
let all = [];
for (let key in this) {
if (!this.hasOwnProperty(key)) {
continue;
}
let value = this[key];
if (key !== 'All') { all.push(value); }
}
return all;
}
};
}
constructor(attributes) {
super(attributes);
this.transactions = attributes.transactions.map((transactionAttributes) => new Transaction(transactionAttributes));
}
}
Subscription.initClass();
module.exports = {Subscription: Subscription};