discourse-subscriptions/assets/javascripts/discourse/models/product.js.es6

21 lines
455 B
Plaintext
Raw Normal View History

2019-12-17 00:31:58 -05:00
import EmberObject from "@ember/object";
2019-10-24 17:18:16 -04:00
import { ajax } from "discourse/lib/ajax";
2019-12-17 00:31:58 -05:00
const Product = EmberObject.extend({});
2019-10-24 17:18:16 -04:00
Product.reopenClass({
findAll() {
2020-09-16 10:53:50 -04:00
return ajax("/s/products", { method: "get" }).then((result) =>
result.map((product) => Product.create(product))
2019-10-24 17:18:16 -04:00
);
2019-11-04 00:37:21 -05:00
},
find(id) {
2020-09-16 10:53:50 -04:00
return ajax(`/s/products/${id}`, { method: "get" }).then((product) =>
2019-11-06 04:59:35 -05:00
Product.create(product)
2019-11-04 00:37:21 -05:00
);
2020-09-16 10:53:50 -04:00
},
2019-10-24 17:18:16 -04:00
});
export default Product;