2018-09-25 16:28:26 +00:00
|
|
|
import { assert } from '@ember/debug';
|
2018-04-03 14:16:57 +00:00
|
|
|
import ApplicationAdapter from './application';
|
|
|
|
|
|
|
|
export default ApplicationAdapter.extend({
|
|
|
|
namespace: 'v1',
|
|
|
|
|
|
|
|
url(/*role*/) {
|
2018-09-25 16:28:26 +00:00
|
|
|
assert('Override the `url` method to extend the SSH adapter', false);
|
2018-04-03 14:16:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
createRecord(store, type, snapshot, requestType) {
|
|
|
|
const serializer = store.serializerFor(type.modelName);
|
|
|
|
const data = serializer.serialize(snapshot, requestType);
|
|
|
|
const role = snapshot.attr('role');
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
return this.ajax(this.url(role), 'POST', { data }).then((response) => {
|
2018-04-03 14:16:57 +00:00
|
|
|
response.id = snapshot.id;
|
|
|
|
response.modelName = type.modelName;
|
|
|
|
store.pushPayload(type.modelName, response);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|