import Ember from 'ember';

export default function() {
  this.get('/slack/users.list', function(db, request) {
    if (Ember.isNone(request.params.token)) {
      return { ok: false, error: 'not_authed' };
    }

    if (request.params.token === 'invalid') {
      return { ok: false, error: 'invalid_auth' };
    }

    return { ok: true, members: db.users };
  });
}

import Ember from 'ember';

function invalidTokenResponse(token) {
  if (Ember.isNone(token)) {
    return { ok: false, error: 'not_authed' };
  }

  if (token === 'invalid') {
    return { ok: false, error: 'invalid_auth' };
  }
}

export default function() {
  this.get('/slack/users.list', function(db, request) {
    let response = invalidTokenResponse(request.params.token);
    if (!Ember.isNone(response)) { return response; }

    return { ok: true, members: db.users };
  });

  this.get('/slack/users.info', function(db, request) {
    let response = invalidTokenResponse(request.params.token);
    if (!Ember.isNone(response)) { return response; }

    let user = db.users.find(request.params.user);
    if (Ember.isNone(user)) {
      return { ok: false, error: 'user_not_found' };
    }

    // FIXME: no support for errors 'user_not_visible' and 'account_inactive'

    return { ok: true, user: user };
  });
}

Add mirage route for Slack user.info endpoint
Add mirage route for Slack user.info endpoint

This is enough to support a very basic custom Ember Data adapter.
