2015-02-13 07:22:32 +03:00
|
|
|
import Ember from 'ember';
|
2016-01-12 22:23:01 +03:00
|
|
|
import RESTSerializer from 'ember-data/serializers/rest';
|
2015-10-28 14:36:45 +03:00
|
|
|
|
2016-01-23 21:12:22 +03:00
|
|
|
const {
|
|
|
|
decamelize
|
|
|
|
} = Ember.String;
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
export default RESTSerializer.extend({
|
|
|
|
serializeIntoHash(hash, type, record, options) {
|
2014-05-09 09:00:10 +04:00
|
|
|
// Our API expects an id on the posted object
|
|
|
|
options = options || {};
|
|
|
|
options.includeId = true;
|
|
|
|
|
|
|
|
// We have a plural root in the API
|
2015-10-28 14:36:45 +03:00
|
|
|
let root = Ember.String.pluralize(type.modelName);
|
|
|
|
let data = this.serialize(record, options);
|
2014-05-09 09:00:10 +04:00
|
|
|
|
|
|
|
// Don't ever pass uuid's
|
|
|
|
delete data.uuid;
|
|
|
|
|
|
|
|
hash[root] = [data];
|
2016-01-23 21:12:22 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
keyForAttribute(attr) {
|
|
|
|
return decamelize(attr);
|
2014-05-09 09:00:10 +04:00
|
|
|
}
|
2014-06-09 15:02:51 +04:00
|
|
|
});
|