1
+ import Mirage from "ember-cli-mirage" ;
2
+
1
3
export default function ( ) {
4
+ this . post ( "/api/auth/sign_in" , function ( schema , request ) {
5
+ const user = schema . users . find ( 1 ) ;
6
+ return new Mirage . Response (
7
+ 200 ,
8
+ { "access-token" :
"adssafsdafsdsfd" , "client" :
"asdfasdfasafs" , "uid" :
"[email protected] " } ,
9
+ { "data" :{ "id" :`${ user . id } ` , "type" :"users" , "links" :{ "self" :`/api/v1/users/${ user . id } ` } , "attributes" :{ "name" :user . name , "email" :user . email } } }
10
+ ) ;
11
+ } ) ;
12
+
2
13
this . namespace = "/api/v1" ;
3
14
4
15
this . delete ( "/announcements/:id" ) ;
5
- this . get ( "/announcements" ) ;
6
16
this . get ( "/announcements/:id" ) ;
7
17
this . patch ( "/announcements/:id" ) ;
8
18
this . post ( "/announcements" ) ;
9
19
10
- this . get ( "/bulletins" ) ;
11
20
this . get ( "/bulletins/:id" ) ;
12
21
this . get ( "/bulletins/:id/sermon" ) ;
13
22
this . patch ( "/bulletins/:id" ) ;
@@ -23,6 +32,24 @@ export default function() {
23
32
this . patch ( "/sermons/:id" ) ;
24
33
this . post ( "/sermons" ) ;
25
34
35
+ this . get ( "/bulletins" , function ( schema , request ) {
36
+ if ( schema . bulletins . all ( ) . models . length > 0 &&
37
+ request . queryParams [ "filter[latest_for_group]" ] ) {
38
+ return schema . bulletins . find ( [ 1 ] ) ;
39
+ }
40
+
41
+ return schema . bulletins . all ( ) ;
42
+ } ) ;
43
+
44
+ this . get ( "/announcements" , function ( schema , request ) {
45
+ if ( schema . announcements . all ( ) . models . length > 0 &&
46
+ request . queryParams [ "filter[latest_for_group]" ] ) {
47
+ return schema . announcements . find ( [ 1 , 2 , 3 ] ) ;
48
+ }
49
+
50
+ return schema . announcements . all ( ) ;
51
+ } ) ;
52
+
26
53
this . get ( "/posts" , function ( schema , request ) {
27
54
const groupId = request . queryParams [ "filter[group]" ] ;
28
55
0 commit comments