all files / addon/mixins/ adapter.js

100% Statements 5/5
100% Branches 0/0
100% Functions 4/4
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52                                                                                             
import Mixin from '@ember/object/mixin';
import urlBuilder from 'ember-custom-actions/utils/url-builder';
 
export default Mixin.create({
  /**
    @public
    @method urlForCustomAction
    @param {String} modelName
    @param {(String|Null)} id single id null
    @param {DS.Snapshot} snapshot single snapshot
    @param {String} actionId name or relative path of the action
    @param {Object} queryParams object of query parameters to send for query requests
    @return {String} Full URL of custom action
  */
  urlForCustomAction(modelName, id, snapshot, actionId, queryParams) {
    let url = this._buildURL(modelName, id);
 
    return urlBuilder(url, actionId, queryParams);
  },
 
  /**
    @public
    @method methodForCustomAction
    @param {Object} params Contains method, modelId, actionId
    @return {String} Full URL of custom action
  */
  methodForCustomAction({ method }) {
    return method;
  },
 
  /**
    @public
    @method headersForCustomAction
    @param {Object} params Contains headers, modelId, actionId
    @return {Object} Custom action headers
  */
  headersForCustomAction({ headers }) {
    return headers;
  },
 
  /**
    @public
    @method dataForCustomAction
    @param {Object} params Contains data, modelId, actionId
    @return {Object} Payload for custom action
  */
  dataForCustomAction({ data }) {
    return data;
  }
});