@@ -6,6 +6,7 @@ import { Jwt } from '../../domain/jwt';
6
6
import { Card } from './../../domain/card' ;
7
7
import { User } from '../../domain/user' ;
8
8
import { Pagination } from 'src/app/domain/pagination' ;
9
+ import { Country } from 'src/app/domain/country' ;
9
10
10
11
@Injectable ( )
11
12
export class HttpBackendInterceptor implements HttpInterceptor {
@@ -17,28 +18,26 @@ export class HttpBackendInterceptor implements HttpInterceptor {
17
18
var data = new Date ( ) ;
18
19
data . setDate ( data . getDate ( ) + 1 ) ;
19
20
20
- let jwt : Jwt = {
21
+ let jwt = new Jwt ( {
21
22
Token : "eaea23424asdfaefwr52asdfasdf32s" ,
22
23
Timeout : data ,
23
24
Username : req . body . Email . split ( "@" ) [ 0 ] ,
24
25
Name : req . body . Email . split ( "@" ) [ 0 ] ,
25
26
Email : req . body . Email
26
- } ;
27
+ } ) ;
27
28
28
29
return of ( new HttpResponse ( { status : 200 , body : jwt } ) ) ;
29
30
}
30
31
31
32
if ( req . url . includes ( 'cards' ) && req . method === 'GET' ) {
32
33
let cards : Card [ ] = [ ] ;
33
34
34
- var card : Card = {
35
- Title : 'Card title' ,
36
- Description : 'Some quick example text to build on the card title and make up the bulk of the card\'s content.' ,
37
- Link : 'Dapibus ac facilisis in'
38
- }
39
-
40
35
for ( let i = 0 ; i < 9 ; i ++ ) {
41
- cards . push ( card ) ;
36
+ cards . push ( new Card ( {
37
+ Title : 'Card title' ,
38
+ Description : 'Some quick example text to build on the card title and make up the bulk of the card\'s content.' ,
39
+ Link : 'Dapibus ac facilisis in'
40
+ } ) ) ;
42
41
}
43
42
44
43
return of ( new HttpResponse ( { status : 200 , body : cards } ) ) ;
@@ -48,20 +47,18 @@ export class HttpBackendInterceptor implements HttpInterceptor {
48
47
let users : User [ ] = [ ] ;
49
48
50
49
var data = new Date ( ) ;
51
-
52
- var user : User = {
53
- Id : 1 ,
54
- Name : 'Gabriel Lucena' ,
55
-
56
- Document : '023.437.673-27' ,
57
- Birthdate : new Date ( '1991-04-28T12:00:00' ) ,
58
- Country : 'Brasil' ,
59
- Profile : 'Administrator' ,
60
- Active : true
61
- }
62
-
50
+
63
51
for ( let i = 0 ; i < 10 ; i ++ ) {
64
- users . push ( user ) ;
52
+ users . push ( new User ( {
53
+ Id : 1 ,
54
+ Name : 'Gabriel Lucena' ,
55
+
56
+ Document : '023.437.673-27' ,
57
+ Birthdate : new Date ( '1991-04-28T12:00:00' ) ,
58
+ Country : 'Brasil' ,
59
+ Profile : 'Administrator' ,
60
+ Active : true
61
+ } ) ) ;
65
62
}
66
63
67
64
let pagination : Pagination < User > = {
@@ -89,6 +86,17 @@ export class HttpBackendInterceptor implements HttpInterceptor {
89
86
return of ( new HttpResponse ( { status : 200 , body : user } ) ) ;
90
87
}
91
88
89
+ if ( req . url . includes ( 'countries' ) && req . method === 'GET' ) {
90
+ let countries : Country [ ] = [ ] ;
91
+
92
+ countries . push ( new Country ( { Id : 1 , Name : 'Brazil' } ) ) ;
93
+ countries . push ( new Country ( { Id : 1 , Name : 'United States of America' } ) ) ;
94
+ countries . push ( new Country ( { Id : 1 , Name : 'Thailand' } ) ) ;
95
+ countries . push ( new Country ( { Id : 1 , Name : 'Greece' } ) ) ;
96
+
97
+ return of ( new HttpResponse ( { status : 200 , body : countries } ) ) ;
98
+ }
99
+
92
100
if ( req . url . includes ( 'error' ) && req . method === 'GET' ) {
93
101
return throwError ( { error : { message : 'Error thrown.' } } ) ;
94
102
}
0 commit comments