import Ember from 'ember';
import UriTemplate from 'uri-templates';

var isArray = Ember.isArray;

var isObject = function(object) { return typeof object === 'object'; };

export default Ember.Mixin.create({
  mergedProperties: ['urlSegments'],
  buildURL: function(type, id, snapshot, requestType, query) {
    var template = this.getTemplate(requestType);

    if (!template) {
      return this._super(...arguments);
    }

    template = this.compileTemplate(template);
    var templateResolver = this.templateResolverFor(type);
    var adapter = this;

    return template.fill(function(name) {
      var result = templateResolver.get(name);

      if (Ember.typeOf(result) === 'function') {
        return result.call(adapter, type, id, snapshot, query);
      } else {
        return result;
      }
    });
  },

  getTemplate: function(requestType) {
    return this.get(requestType + 'UrlTemplate') || this.get('urlTemplate');
  },

  compileTemplate: function(template) {
    return new UriTemplate(template);
  },

  // TODO: Add ability to customize templateResolver
  // TODO: Add reference to the adapter
  templateResolverFor: function(/* type */) {
    return Ember.Object.create(this.get('urlSegments'));
  },

  // HACK: Prevent query/queryRecord from appending query params to urls, we
  // can do that in the template.
  // TODO: Use dataForRequest when ds-improved-ajax lands
  // (https://github.com/emberjs/data/pull/3099)
  sortQueryParams: function(/* params */) {
    return {};
  },

  urlSegments: {
    host: function () { return this.get('host'); },
    namespace: function() { return this.get('namespace'); },
    pathForType: function(type) { return this.pathForType(type); },

    id: function(type, id) {
      if (id && !isArray(id) && !isObject(id)) { return id; }
    },

    query: function(type, id, snapshot, query) {
      var newQuery = Ember.copy(query);

      for (var param in newQuery) {
        if (newQuery[param] === undefined) { delete newQuery[param]; }
        if (newQuery[param] === null ) { newQuery[param] = ""; }
      }

      return newQuery;
    },

    // TODO: Support automatic relationship ids through snapshots api.
    unknownProperty: function(key) {
      return function(type, id, snapshot, query) {
        if (query && query[key]) { return query[key]; }
        if (snapshot) { return snapshot[key]; }
      };
    }
  }
});

@@ -66,108 +66,47 @@
 ';%0A%0A
-var isArray = Ember.isArray;%0A%0Avar isObject = function(object) %7B return
+const %7B isArray, copy,
  type
-of object === 'object'; %7D
+Of %7D = Ember
 ;%0A%0Ae
@@ -187,26 +187,16 @@
 buildURL
-: function
 (type, i
@@ -230,27 +230,29 @@
 uery) %7B%0A    
-var
+const
  template = 
@@ -240,32 +240,38 @@
   const template
+String
  = this.getTempl
@@ -298,32 +298,38 @@
    if (!template
+String
 ) %7B%0A      return
@@ -367,16 +367,22 @@
  %7D%0A%0A    
+const 
 template
@@ -413,26 +413,34 @@
 template
+String
 );%0A    
-var
+const
  templat
@@ -487,19 +487,21 @@
 e);%0A    
-var
+const
  adapter
@@ -539,22 +539,17 @@
 ill(
-function
 (name)
+ =%3E
  %7B%0A 
@@ -553,19 +553,21 @@
 %7B%0A      
-var
+const
  result 
@@ -607,22 +607,16 @@
     if (
-Ember.
 typeOf(r
@@ -777,26 +777,16 @@
 Template
-: function
 (request
@@ -893,26 +893,16 @@
 Template
-: function
 (templat
@@ -1064,26 +1064,16 @@
 olverFor
-: function
 (/* type
@@ -1377,26 +1377,16 @@
 ryParams
-: function
 (/* para
@@ -1444,19 +1444,8 @@
 host
-: function 
 () %7B
@@ -1486,26 +1486,16 @@
 amespace
-: function
 () %7B ret
@@ -1539,26 +1539,16 @@
 hForType
-: function
 (type) %7B
@@ -1589,26 +1589,16 @@
 %0A%0A    id
-: function
 (type, i
@@ -1681,26 +1681,16 @@
    query
-: function
 (type, i
@@ -1732,22 +1732,16 @@
 Query = 
-Ember.
 copy(que
@@ -1757,19 +1757,21 @@
    for (
-var
+const
  param i
@@ -2054,18 +2054,8 @@
 erty
-: function
 (key
@@ -2071,24 +2071,16 @@
  return 
-function
 (type, i
@@ -2090,32 +2090,35 @@
 snapshot, query)
+ =%3E
  %7B%0A        if (q
@@ -2227,12 +2227,80 @@
   %7D%0A  %7D%0A%7D);%0A
+%0Afunction isObject(object) %7B%0A  return typeof object === 'object';%0A%7D%0A

Update to es6 syntax