import { Response } from 'ember-cli-mirage';

export default function() {

  // These comments are here to help you get started. Feel free to delete them.

  /*
    Config (with defaults).

    Note: these only affect routes defined *after* them!
  */

  // this.urlPrefix = '';    // make this `http://localhost:8080`, for example, if your API is on a different server
  // this.namespace = '';    // make this `api`, for example, if your API is namespaced
  // this.timing = 400;      // delay for each request, automatically set to 0 during testing

  /*
    Shorthand cheatsheet:

    this.get('/posts');
    this.post('/posts');
    this.get('/posts/:id');
    this.put('/posts/:id'); // or this.patch
    this.del('/posts/:id');

    http://www.ember-cli-mirage.com/docs/v0.2.x/shorthands/
  */

  this.get('/v1/user/exists-by-attribute', (schema, {queryParams}) => {
    return {
      preferred_username: queryParams.preferred_username === 'taken' ? 'taken' : ''
    };
  });
  this.get('/users', schema => schema.users.first());
  this.post('/users', {data: {
    type: 'user',
    id: 'current',
    attributes: {}
  }});
  this.patch('/users/:id', () => new Response(401, {}, {
    "error": {
      "code": "AccountExists",
      "message": "Account with email exists. Please try another."
    }
  }));

  this.post('/check-password', () => new Response(401, {}, {
    "error": {
      "code": "InvalidCredentials",
      "message": "Incorrect username or password."
    }
  }));
  this.get('/pledges', {timing: 2000});
  this.get('/member-status');
}

@@ -867,16 +867,60 @@
 %7D) =%3E %7B%0A
+    if (queryParams.preferred_username) %7B%0A  
     retu
@@ -924,16 +924,18 @@
 eturn %7B%0A
+  
       pr
@@ -1018,10 +1018,192 @@
     
+  %7D;%0A    %7D else if (queryParams.email) %7B%0A      return %7B%0A        email: queryParams.email === 'taken@example.com' ? 'taken@example.com' : ''%0A      %7D;%0A    %7D else %7B%0A      return %7B%7D;%0A    
 %7D
-;
 %0A  %7D
@@ -1737,24 +1737,8 @@
 ges'
-, %7Btiming: 2000%7D
 );%0A 

Update mirage config for member center checks