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