Created
October 18, 2015 15:32
-
-
Save ksol/648002e30bb102a52ddf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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