-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from johanah29/jojo
Adding capsules and lunches services
- Loading branch information
Showing
4 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { CapsulesService } from './capsules.service'; | ||
|
||
describe('CapsulesService', () => { | ||
let service: CapsulesService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(CapsulesService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient, HttpHeaders } from '@angular/common/http'; | ||
import { Observable } from 'rxjs'; | ||
|
||
const CAPSULES_API='https://api.spacexdata.com/v3/capsules' | ||
|
||
const httpOptions = { | ||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }) | ||
}; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class CapsulesService { | ||
|
||
constructor(private http: HttpClient) { } | ||
|
||
public getCapsules():Observable<any> { | ||
return this.http.get<any>(CAPSULES_API, httpOptions); | ||
} | ||
|
||
public getOneCapsule(capsule_serial:number):Observable<any> { | ||
return this.http.get<any>(CAPSULES_API+'/'+capsule_serial, httpOptions); | ||
} | ||
|
||
public getPastCapsules():Observable<any>{ | ||
return this.http.get<any>(CAPSULES_API+'/past'); | ||
} | ||
|
||
public getUpcomingCapsules():Observable<any>{ | ||
return this.http.get<any>(CAPSULES_API+'/upcoming'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { LaunchesService } from './launches.service'; | ||
|
||
describe('LaunchesService', () => { | ||
let service: LaunchesService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(LaunchesService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient, HttpHeaders } from '@angular/common/http'; | ||
import { Observable } from 'rxjs'; | ||
|
||
|
||
const LAUNCHES_API='https://api.spacexdata.com/v3/launches' | ||
|
||
const httpOptions = { | ||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }) | ||
}; | ||
|
||
|
||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class LaunchesService { | ||
|
||
constructor(private http: HttpClient) { } | ||
|
||
public getLaunches():Observable<any> { | ||
return this.http.get<any>(LAUNCHES_API, httpOptions); | ||
} | ||
|
||
public getOneLaunch(flight_number:number):Observable<any>{ | ||
return this.http.get<any>(LAUNCHES_API+'/'+flight_number); | ||
} | ||
|
||
public getPastLaunches():Observable<any>{ | ||
return this.http.get<any>(LAUNCHES_API+'/past'); | ||
} | ||
|
||
public getUpcomingLaunches():Observable<any>{ | ||
return this.http.get<any>(LAUNCHES_API+'/upcoming'); | ||
} | ||
|
||
public getLatestLaunch():Observable<any>{ | ||
return this.http.get<any>(LAUNCHES_API+'/latest'); | ||
} | ||
|
||
public getNextLaunch():Observable<any>{ | ||
return this.http.get<any>(LAUNCHES_API+'/next'); | ||
} | ||
|
||
} |