2020-04-08 17:03:18 +00:00
|
|
|
import Service, { inject as service } from '@ember/service';
|
|
|
|
import { setProperties } from '@ember/object';
|
|
|
|
|
2020-11-09 09:25:35 +00:00
|
|
|
export default class HttpService extends Service {
|
|
|
|
@service('settings')
|
|
|
|
settings;
|
|
|
|
|
|
|
|
@service('repository/intention')
|
|
|
|
intention;
|
|
|
|
|
|
|
|
@service('repository/kv')
|
|
|
|
kv;
|
|
|
|
|
|
|
|
@service('repository/session')
|
|
|
|
session;
|
|
|
|
|
|
|
|
prepare(sink, data, instance) {
|
2020-05-01 08:49:33 +00:00
|
|
|
return setProperties(instance, data);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
persist(sink, instance) {
|
2020-07-09 09:08:47 +00:00
|
|
|
const [, , , model] = sink.split('/');
|
2020-04-08 17:03:18 +00:00
|
|
|
const repo = this[model];
|
|
|
|
return repo.persist(instance);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
remove(sink, instance) {
|
2020-07-09 09:08:47 +00:00
|
|
|
const [, , , model] = sink.split('/');
|
2020-04-08 17:03:18 +00:00
|
|
|
const repo = this[model];
|
|
|
|
return repo.remove(instance);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
}
|