Skip to content

Instantly share code, notes, and snippets.

@ksol
Created October 18, 2015 15:32
Show Gist options
  • Save ksol/648002e30bb102a52ddf to your computer and use it in GitHub Desktop.
Save ksol/648002e30bb102a52ddf to your computer and use it in GitHub Desktop.
import ApplicationAdapter from './application';
import Ember from 'ember';
import UrlTemplates from "ember-data-url-templates";
const get = Ember.get;
export default ApplicationAdapter.extend(UrlTemplates, {
adapterContext: Ember.service.inject(),
queryUrlTemplate: Ember.computed('adapterContext.{company,organization}', function() {
let adapterContext = this.get('adapterContext');
if(get(adapterContext, 'company')) {
return "{+host}/companies/{companyId}/users";
} else if(get(adapterContext, 'organization')) {
return "{+host}/organizations/{organizationId}/users";
} else {
return "{+host}users/";
}
}),
urlSegments: {
companyId() {
return this.get('adapterContext.company.id');
},
organizationId() {
return this.get('adapterContext.organization.id');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment