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