2019-10-24 17:18:16 -04:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
|
|
|
|
|
|
|
const Product = Discourse.Model.extend({});
|
|
|
|
|
|
|
|
Product.reopenClass({
|
|
|
|
findAll() {
|
2019-12-02 18:29:44 -05:00
|
|
|
return ajax("/s/products", { method: "get" }).then(result =>
|
2019-10-24 17:18:16 -04:00
|
|
|
result.map(product => Product.create(product))
|
|
|
|
);
|
2019-11-04 00:37:21 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
find(id) {
|
2019-12-02 18:29:44 -05: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
|
|
|
);
|
2019-10-24 17:18:16 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default Product;
|