Files
discourse-subscriptions/assets/javascripts/discourse/models/subscription.js.es6
T

29 lines
623 B
JavaScript
Raw Normal View History

2019-10-29 11:43:32 +11:00
import computed from "ember-addons/ember-computed-decorators";
2019-10-17 20:34:26 +11:00
import { ajax } from "discourse/lib/ajax";
const Subscription = Discourse.Model.extend({
2019-10-31 10:01:41 +11:00
@computed("status")
canceled(status) {
2019-10-31 13:31:24 +11:00
return status === "canceled";
2019-10-31 10:01:41 +11:00
},
2019-10-17 20:34:26 +11:00
save() {
const data = {
customer: this.customer,
plan: this.plan
};
return ajax("/s/subscriptions", { method: "post", data });
2019-10-31 13:31:24 +11:00
}
2019-10-17 20:34:26 +11:00
});
2019-10-29 11:43:32 +11:00
Subscription.reopenClass({
findAll() {
return ajax("/s/subscriptions", { method: "get" }).then(result =>
2019-11-04 16:37:21 +11:00
result.map(subscription => Subscription.create(subscription))
2019-10-29 11:43:32 +11:00
);
}
});
2019-10-17 20:34:26 +11:00
export default Subscription;