2020-05-28 11:32:57 -04:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2019-10-17 05:34:26 -04:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
2020-05-06 18:06:14 -04:00
|
|
|
import EmberObject from "@ember/object";
|
2019-10-17 05:34:26 -04:00
|
|
|
|
2020-05-06 18:06:14 -04:00
|
|
|
const Subscription = EmberObject.extend({
|
2020-05-28 11:32:57 -04:00
|
|
|
@discourseComputed("status")
|
2019-10-30 19:01:41 -04:00
|
|
|
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 = {
|
2020-10-21 14:36:31 -04:00
|
|
|
source: this.source,
|
2020-09-16 10:53:50 -04:00
|
|
|
plan: this.plan,
|
2021-01-07 16:25:44 -05:00
|
|
|
promo: this.promo,
|
2023-05-05 13:20:35 -04:00
|
|
|
cardholder_name: this.cardholderName,
|
|
|
|
cardholder_address: this.cardholderAddress,
|
2019-10-17 05:34:26 -04:00
|
|
|
};
|
|
|
|
|
2020-10-21 14:36:31 -04:00
|
|
|
return ajax("/s/create", { method: "post", data });
|
2020-09-16 10:53:50 -04:00
|
|
|
},
|
2019-10-17 05:34:26 -04:00
|
|
|
});
|
|
|
|
|
2019-10-28 20:43:32 -04:00
|
|
|
Subscription.reopenClass({
|
2020-10-21 14:36:31 -04:00
|
|
|
show(id) {
|
|
|
|
return ajax(`/s/${id}`, { method: "get" });
|
2020-09-16 10:53:50 -04:00
|
|
|
},
|
2019-10-28 20:43:32 -04:00
|
|
|
});
|
|
|
|
|
2019-10-17 05:34:26 -04:00
|
|
|
export default Subscription;
|