spacex 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +8 -23
- data/CHANGELOG.md +22 -0
- data/CONTRIBUTING.md +35 -0
- data/Gemfile +3 -3
- data/README.md +122 -6
- data/lib/spacex.rb +3 -2
- data/lib/spacex/base_request.rb +16 -3
- data/lib/spacex/company_info.rb +0 -2
- data/lib/spacex/dragon_capsules.rb +47 -0
- data/lib/spacex/endpoint.rb +1 -3
- data/lib/spacex/launches.rb +0 -2
- data/lib/spacex/missions.rb +32 -0
- data/lib/spacex/resource.rb +5 -0
- data/lib/spacex/roadster.rb +1 -3
- data/lib/spacex/ships.rb +47 -0
- data/lib/spacex/version.rb +2 -4
- data/spacex.gemspec +1 -1
- data/spec/fixtures/spacex/company_info/info.yml +12 -14
- data/spec/fixtures/spacex/dragon_capsules/info.yml +77 -0
- data/spec/fixtures/spacex/dragon_capsules/info/dragon1.yml +67 -0
- data/spec/fixtures/spacex/launches/latest.yml +8 -8
- data/spec/fixtures/spacex/missions/F3364BF.yml +80 -0
- data/spec/fixtures/spacex/missions/info.yml +62 -0
- data/spec/fixtures/spacex/roadster/info.yml +2 -2
- data/spec/fixtures/spacex/ships/info.yml +139 -0
- data/spec/fixtures/spacex/ships/info/AMERICANCHAMPION.yml +64 -0
- data/spec/spacex/company_info_spec.rb +1 -1
- data/spec/spacex/dragon_capsules_spec.rb +107 -0
- data/spec/spacex/launches_spec.rb +1 -1
- data/spec/spacex/missions_spec.rb +37 -0
- data/spec/spacex/ships_spec.rb +65 -0
- metadata +30 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 507504ea67cb24744c580b4e934916cc37a782b8
|
4
|
+
data.tar.gz: 52fb07cf5aa01a14093c6b4d65a27c2df9797ba6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01da7e4f1bc94516207eadbd47f653e185a36197a3c6b4c4903dfd52461ce7bad93f82f0ce610aa97db159710d2a7afeeb1f0164d9615484313891bc18a30fd2
|
7
|
+
data.tar.gz: a20c61675ae70e9d8066d55d21fdb41ff309b819fc1cf754df90014d7f13779537fddeeb3071f73aa68d62818627b457b627e6aca0721e8d5939243a49ea8a0d
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,39 +1,24 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2018-
|
3
|
+
# on 2018-10-05 18:26:44 -0400 using RuboCop version 0.51.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
10
|
-
Lint/
|
9
|
+
# Offense count: 4
|
10
|
+
Lint/ParenthesesAsGroupedExpression:
|
11
11
|
Exclude:
|
12
|
-
- 'spec/spacex/
|
12
|
+
- 'spec/spacex/dragon_capsules_spec.rb'
|
13
|
+
- 'spec/spacex/ships_spec.rb'
|
13
14
|
|
14
|
-
# Offense count:
|
15
|
+
# Offense count: 13
|
15
16
|
# Configuration parameters: CountComments, ExcludedMethods.
|
16
17
|
Metrics/BlockLength:
|
17
|
-
Max:
|
18
|
+
Max: 100
|
18
19
|
|
19
|
-
# Offense count:
|
20
|
+
# Offense count: 42
|
20
21
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
21
22
|
# URISchemes: http, https
|
22
23
|
Metrics/LineLength:
|
23
24
|
Max: 494
|
24
|
-
|
25
|
-
# Offense count: 1
|
26
|
-
# Configuration parameters: CountComments.
|
27
|
-
Metrics/MethodLength:
|
28
|
-
Max: 11
|
29
|
-
|
30
|
-
# Offense count: 5
|
31
|
-
Style/Documentation:
|
32
|
-
Exclude:
|
33
|
-
- 'spec/**/*'
|
34
|
-
- 'test/**/*'
|
35
|
-
- 'lib/spacex/base_request.rb'
|
36
|
-
- 'lib/spacex/company_info.rb'
|
37
|
-
- 'lib/spacex/launches.rb'
|
38
|
-
- 'lib/spacex/roadster.rb'
|
39
|
-
- 'lib/spacex/version.rb'
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
### 0.0.7 (2018/10/07)
|
2
|
+
|
3
|
+
* Your contribution here.
|
4
|
+
* Refactor responses getting multiple objects like Ships, Capsules to wrap a specific object. This helps translating specific properties like `id` and `class` to `ship_id`, `ship_class` - [@rodolfobandeira](https://github.com/rodolfobandeira).
|
5
|
+
* Add ability to retrieve specific Ship via `.info('ship_id')` - [@rodolfobandeira](https://github.com/rodolfobandeira).
|
6
|
+
* Add ability to retrieve specific Dragon Capsule via `.info('dragon_id')` - [@rodolfobandeira](https://github.com/rodolfobandeira).
|
7
|
+
* [#10](https://github.com/rodolfobandeira/spacex/pull/10): Added Ships information - [@zainalmustofa](https://github.com/zainalmustofa).
|
8
|
+
* [#9](https://github.com/rodolfobandeira/spacex/pull/9): Added Dragon Capsules information - [@JackieCalapristi](https://github.com/JackieCalapristi).
|
9
|
+
* [#16](https://github.com/rodolfobandeira/spacex/pull/16): Added missions information - [@maiafernando](https://github.com/maiafernando).
|
10
|
+
|
11
|
+
### 0.0.6 (2018/08/22)
|
12
|
+
|
13
|
+
* Added Roadster information - [@rodolfobandeira](https://github.com/rodolfobandeira).
|
14
|
+
|
15
|
+
### 0.0.5 (2018/08/21)
|
16
|
+
|
17
|
+
* Added Company information and General Refactors - [@rodolfobandeira](https://github.com/rodolfobandeira).
|
18
|
+
|
19
|
+
### 0.0.4 (2018/08/21)
|
20
|
+
|
21
|
+
* Initial public release - [@rodolfobandeira](https://github.com/rodolfobandeira).
|
22
|
+
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
## How to Contribute with the SPACEX gem?
|
2
|
+
|
3
|
+
### Fork the repository
|
4
|
+
|
5
|
+
```
|
6
|
+
git clone https://github.com/rodolfobandeira/spacex.git
|
7
|
+
cd spacex
|
8
|
+
git remote add upstream https://github.com/rodolfobandeira/spacex.git
|
9
|
+
bundle install
|
10
|
+
```
|
11
|
+
|
12
|
+
### Write test
|
13
|
+
|
14
|
+
We use `rspec`. After writing your test, you can run using:
|
15
|
+
|
16
|
+
`bundle exec rspec`
|
17
|
+
|
18
|
+
|
19
|
+
### Write your code
|
20
|
+
|
21
|
+
Write your code to make your tests pass. After that, make sure you run `Rubocop`.
|
22
|
+
|
23
|
+
`bundle exec rubocop`
|
24
|
+
|
25
|
+
Sometimes errors could be fixed by running:
|
26
|
+
|
27
|
+
`bundle exec rubocop -a`
|
28
|
+
|
29
|
+
### Update the Changelog with the description of your code and your name
|
30
|
+
|
31
|
+
Update the Changelog with the description of your code and your name on the line after `"* Your contribution here"`
|
32
|
+
|
33
|
+
### Push your change and open a pull request.
|
34
|
+
|
35
|
+
Thank you!
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -11,10 +11,20 @@ Ruby library that consumes SpaceX API
|
|
11
11
|
|
12
12
|
- [Installation](#installation)
|
13
13
|
- [Usage](#usage)
|
14
|
-
- [Latest Launch](#latest-launch)
|
15
|
-
- [Company Info](#company-info)
|
16
|
-
- [Roadster](#roadster)
|
17
|
-
- [
|
14
|
+
- [Latest Launch](#latest-launch) - `SPACEX::Launches.latest`
|
15
|
+
- [Company Info](#company-info) - `SPACEX::CompanyInfo.info`
|
16
|
+
- [Roadster](#roadster) - `SPACEX::Roadster.info`
|
17
|
+
- [Dragon Capsules](#dragon-capsules)
|
18
|
+
- `SPACEX::DragonCapsules.info`
|
19
|
+
- `SPACEX::DragonCapsules.info('dragon_id')`
|
20
|
+
- [Ships](#ships)
|
21
|
+
- `SPACEX::Ships.info`
|
22
|
+
- `SPACEX::Ships.info('ship_id')`
|
23
|
+
- [Missions](#missions)
|
24
|
+
- `SPACEX::Missions.info`
|
25
|
+
- `SPACEX::Missions.info('mission_id')`
|
26
|
+
- [Contributing](#contributing)
|
27
|
+
- [Contributors / Changelog](#contributors)
|
18
28
|
- [Copyright](#copyright)
|
19
29
|
|
20
30
|
|
@@ -157,14 +167,120 @@ roadster.wikipedia # 'https://en.wikipedia.org/wiki/Elon_Musk%27s_Tesla_Roadster
|
|
157
167
|
roadster.details # "Elon Musk's Tesla Roadster is an electric sports car that served as the dummy payload for the February 2018 Falcon Heavy test flight and is now an artificial satellite of the Sun. Starman, a mannequin dressed in a spacesuit, occupies the driver's seat. The car and rocket are products of Tesla and SpaceX, both companies founded by Elon Musk. This 2008-model Roadster was previously used by Musk for commuting, and is the only consumer car sent into space."
|
158
168
|
```
|
159
169
|
|
170
|
+
### Dragon Capsules
|
171
|
+
|
172
|
+
- `SPACEX::DragonCapsules.info` Retrieve all Dragon Capsules;
|
173
|
+
- `SPACEX::DragonCapsules.info('dragon_id')` Retrieve a specific dragon capsule. Ex: `dragon1`
|
174
|
+
|
175
|
+
|
176
|
+
```ruby
|
177
|
+
dragon_capsules = SPACEX::DragonCapsules.info
|
178
|
+
|
179
|
+
dragon_capsules.first.capsule_id # "dragon1"
|
180
|
+
dragon_capsules.first.name # "Dragon 1"
|
181
|
+
dragon_capsules.first.type # "capsule"
|
182
|
+
dragon_capsules.first.active # true
|
183
|
+
dragon_capsules.first.crew_capacity # 0
|
184
|
+
dragon_capsules.first.sidewall_angle_deg # 15
|
185
|
+
dragon_capsules.first.orbit_duration_yr # 2
|
186
|
+
dragon_capsules.first.dry_mass_kg # 4200
|
187
|
+
dragon_capsules.first.dry_mass_lb # 9300
|
188
|
+
dragon_capsules.first.first_flight # "2010-12-08"
|
189
|
+
dragon_capsules.first.heat_shield['material'] # "PICA-X"
|
190
|
+
dragon_capsules.first.heat_shield['size_meters'] # 3.6
|
191
|
+
dragon_capsules.first.heat_shield['temp_degrees'] # 3000
|
192
|
+
dragon_capsules.first.heat_shield['dev_partner'] # "NASA"
|
193
|
+
dragon_capsules.first.thrusters[0]['type'] # "Draco"
|
194
|
+
dragon_capsules.first.thrusters[0]['amount'] # 18
|
195
|
+
dragon_capsules.first.thrusters[0]['pods'] # 4
|
196
|
+
dragon_capsules.first.thrusters[0]['fuel_1'] # "nitrogen tetroxide"
|
197
|
+
dragon_capsules.first.thrusters[0]['fuel_2'] # "monomethylhydrazine"
|
198
|
+
dragon_capsules.first.thrusters[0]['thrust']['kN'] # 0.4
|
199
|
+
dragon_capsules.first.thrusters[0]['thrust']['lbf'] # 90
|
200
|
+
dragon_capsules.first.launch_payload_mass['kg'] # 6000
|
201
|
+
dragon_capsules.first.launch_payload_mass['lb'] # 13228
|
202
|
+
dragon_capsules.first.launch_payload_vol['cubic_meters'] # 25
|
203
|
+
dragon_capsules.first.launch_payload_vol['cubic_feet'] # 883
|
204
|
+
dragon_capsules.first.return_payload_mass['kg'] # 3000
|
205
|
+
dragon_capsules.first.return_payload_mass['lb'] # 6614
|
206
|
+
dragon_capsules.first.return_payload_vol['cubic_meters'] # 11
|
207
|
+
dragon_capsules.first.return_payload_vol['cubic_feet'] # 388
|
208
|
+
dragon_capsules.first.pressurized_capsule['payload_volume']['cubic_meters']) # 11
|
209
|
+
dragon_capsules.first.pressurized_capsule['payload_volume']['cubic_feet'] # 388
|
210
|
+
dragon_capsules.first.trunk['trunk_volume['cubic_meters'] # 14
|
211
|
+
dragon_capsules.first.trunk['trunk_volume['cubic_feet'] # 494
|
212
|
+
dragon_capsules.first.trunk['cargo']['solar_array'] # 2
|
213
|
+
dragon_capsules.first.trunk['cargo']['unpressurized_cargo'] # true
|
214
|
+
dragon_capsules.first.height_w_trunk['meters'] # 7.2
|
215
|
+
dragon_capsules.first.height_w_trunk['feet'] # 23.6
|
216
|
+
dragon_capsules.first.diameter['meters'] # 3.7
|
217
|
+
dragon_capsules.first.diameter['feet'] # 12
|
218
|
+
dragon_capsules.first.wikipedia # "https://en.wikipedia.org/wiki/SpaceX_Dragon"
|
219
|
+
dragon_capsules.first.description # "Dragon is a reusable spacecraft developed by SpaceX, an American private space transportation company based in Hawthorne, California. Dragon is launched into space by the SpaceX Falcon 9 two-stage-to-orbit launch vehicle. The Dragon spacecraft was originally designed for human travel, but so far has only been used to deliver cargo to the International Space Station (ISS)."
|
220
|
+
```
|
221
|
+
|
222
|
+
### Ships
|
223
|
+
|
224
|
+
- `SPACEX::Ships.info` Retrieve all Ships;
|
225
|
+
- `SPACEX::Ships.info('ship_id')` Retrieve a specific ship. Ex: `AMERICANCHAMPION`
|
226
|
+
|
227
|
+
```ruby
|
228
|
+
ship = SPACEX::Ships.info('AMERICANCHAMPION')
|
229
|
+
|
230
|
+
ship.ship_id # 'AMERICANCHAMPION'
|
231
|
+
ship.ship_name # 'American Champion'
|
232
|
+
ship.ship_model # nil
|
233
|
+
ship.ship_type # 'Tug'
|
234
|
+
ship.roles # ['Support Ship', 'Barge Tug']
|
235
|
+
ship.active # false
|
236
|
+
ship.imo # 7_434_016
|
237
|
+
ship.mmsi # 367_020_820
|
238
|
+
ship.abs # 571_252
|
239
|
+
ship.ship_class # 7_604_342 # Call as array since "class" is a method in Ruby
|
240
|
+
ship.weight_lbs # 588_000
|
241
|
+
ship.weight_kg # 266_712
|
242
|
+
ship.year_built # 1976
|
243
|
+
ship.home_port # 'Port of Los Angeles'
|
244
|
+
ship.status # 'Stopped'
|
245
|
+
ship.speed_kn # 0
|
246
|
+
ship.course_deg # nil
|
247
|
+
ship.position # ({ 'latitude' => 30.52852, 'longitude' => -88.09869 })
|
248
|
+
ship.successful_landings # nil
|
249
|
+
ship.attempted_landings # nil
|
250
|
+
ship.missions # [{ 'flight' => 7, 'name' => 'COTS 1' }, { 'flight' => 8, 'name' => 'COTS 2' }]
|
251
|
+
ship.url # 'https://www.marinetraffic.com/en/ais/details/ships/shipid:434663/vessel:AMERICAN%20CHAMPION'
|
252
|
+
ship.image # 'https://i.imgur.com/woCxpkj.jpg'
|
253
|
+
```
|
254
|
+
|
255
|
+
### Missions
|
256
|
+
|
257
|
+
- `SPACEX::Missions.info` Retrieve all Missions;
|
258
|
+
- `SPACEX::Missions.info('mission_id')` Retrieve a specific mission. Ex: `F3364BF`
|
259
|
+
|
260
|
+
```ruby
|
261
|
+
missions = SPACEX::Missions.info
|
262
|
+
|
263
|
+
missions.first.mission_id # "F3364BF"
|
264
|
+
missions.first.mission_name # "Iridium NEXT"
|
265
|
+
missions.first.manufacturers # ["Orbital ATK"]
|
266
|
+
missions.first.payload_ids # ["Iridium NEXT 1", "Iridium NEXT 2", "Iridium NEXT 3", "Iridium NEXT 4", "Iridium NEXT 5", "Iridium NEXT 6", "Iridium NEXT 7"]
|
267
|
+
missions.first.wikipedia # "https://en.wikipedia.org/wiki/Iridium_satellite_constellation"
|
268
|
+
missions.first.website # "https://www.iridiumnext.com/"
|
269
|
+
missions.first.twitter # "https://twitter.com/IridiumBoss?lang=en"
|
270
|
+
missions.first.description # "In 2017, Iridium began launching Iridium NEXT, a second-generation worldwide network of telecommunications satellites, consisting of 66 active satellites, with another nine in-orbit spares and six on-ground spares. These satellites will incorporate features such as data transmission that were not emphasized in the original design. The constellation will provide L-band data speeds of up to 128 kbit/s to mobile terminals, up to 1.5 Mbit/s to Iridium Pilot marine terminals, and high-speed Ka-band service of up to 8 Mbit/s to fixed/transportable terminals. The next-generation terminals and service are expected to be commercially available by the end of 2018. However, Iridium's proposed use of its next-generation satellites has raised concerns the service will harmfully interfere with GPS devices. The satellites will incorporate a secondary payload for Aireon, a space-qualified ADS-B data receiver. This is for use by air traffic control and, via FlightAware, for use by airlines. A tertiary payload on 58 satellites is a marine AIS ship-tracker receiver, for Canadian company exactEarth Ltd. Iridium can also be used to provide a data link to other satellites in space, enabling command and control of other space assets regardless of the position of ground stations and gateways."
|
271
|
+
```
|
160
272
|
|
161
273
|
## Contributing
|
162
274
|
|
163
|
-
|
275
|
+
See [CONTRIBUTING](CONTRIBUTING.md).
|
276
|
+
|
277
|
+
## Contributors
|
278
|
+
|
279
|
+
[Awesome people that already helped this project](CHANGELOG.md).
|
164
280
|
|
165
281
|
|
166
282
|
## Copyright
|
167
283
|
|
168
|
-
Copyright (c) Rodolfo Bandeira
|
284
|
+
Copyright (c) 2018, [Rodolfo Bandeira](https://twitter.com/rodolfobandeira) and [Contributors](CHANGELOG.md).
|
169
285
|
|
170
286
|
MIT License, see [LICENSE](https://github.com/rodolfobandeira/spacex/blob/master/LICENSE) for details.
|
data/lib/spacex.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'faraday'
|
4
2
|
require 'faraday_middleware'
|
5
3
|
require 'faraday_middleware/response_middleware'
|
@@ -10,3 +8,6 @@ require_relative 'spacex/version'
|
|
10
8
|
require_relative 'spacex/launches'
|
11
9
|
require_relative 'spacex/company_info'
|
12
10
|
require_relative 'spacex/roadster'
|
11
|
+
require_relative 'spacex/dragon_capsules'
|
12
|
+
require_relative 'spacex/ships'
|
13
|
+
require_relative 'spacex/missions'
|
data/lib/spacex/base_request.rb
CHANGED
@@ -1,9 +1,23 @@
|
|
1
|
-
|
1
|
+
require 'byebug'
|
2
2
|
|
3
3
|
module SPACEX
|
4
|
+
class Response < Hashie::Mash
|
5
|
+
disable_warnings
|
6
|
+
end
|
7
|
+
|
4
8
|
module BaseRequest
|
5
9
|
def self.get(path)
|
6
|
-
data =
|
10
|
+
data = call_api(path)
|
11
|
+
SPACEX::Response.new(data.get.body)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.retrieve_all(path)
|
15
|
+
data = call_api(path)
|
16
|
+
data.get.body.map { |k| [k] }
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.call_api(path)
|
20
|
+
Faraday.new(
|
7
21
|
url: "#{SPACEX::ROOT_URI}/#{path}",
|
8
22
|
request: {
|
9
23
|
params_encoder: Faraday::FlatParamsEncoder
|
@@ -13,7 +27,6 @@ module SPACEX
|
|
13
27
|
c.use Faraday::Response::RaiseError
|
14
28
|
c.use Faraday::Adapter::NetHttp
|
15
29
|
end
|
16
|
-
Hashie::Mash.new(data.get.body)
|
17
30
|
end
|
18
31
|
end
|
19
32
|
end
|
data/lib/spacex/company_info.rb
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
module SPACEX
|
2
|
+
class DragonCapsules < Hashie::Trash
|
3
|
+
include Hashie::Extensions::IgnoreUndeclared
|
4
|
+
|
5
|
+
property 'capsule_id', from: 'id'
|
6
|
+
property 'name'
|
7
|
+
property 'type'
|
8
|
+
property 'active'
|
9
|
+
property 'crew_capacity'
|
10
|
+
property 'sidewall_angle_deg'
|
11
|
+
property 'orbit_duration_yr'
|
12
|
+
property 'dry_mass_kg'
|
13
|
+
property 'dry_mass_lb'
|
14
|
+
property 'first_flight'
|
15
|
+
property 'heat_shield'
|
16
|
+
property 'thrusters'
|
17
|
+
property 'launch_payload_mass'
|
18
|
+
property 'launch_payload_vol'
|
19
|
+
property 'return_payload_mass'
|
20
|
+
property 'return_payload_vol'
|
21
|
+
property 'pressurized_capsule'
|
22
|
+
property 'trunk'
|
23
|
+
property 'height_w_trunk'
|
24
|
+
property 'diameter'
|
25
|
+
property 'flickr_images'
|
26
|
+
property 'wikipedia'
|
27
|
+
property 'description'
|
28
|
+
|
29
|
+
class << self
|
30
|
+
def retrieve_all
|
31
|
+
data = SPACEX::BaseRequest.call_api('dragons')
|
32
|
+
data.get.body.map { |k| SPACEX::DragonCapsules.new(k) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def get(dragon_id = nil)
|
36
|
+
return retrieve_all if dragon_id.nil?
|
37
|
+
|
38
|
+
data = SPACEX::BaseRequest.get("dragons/#{dragon_id}")
|
39
|
+
SPACEX::DragonCapsules.new(data)
|
40
|
+
end
|
41
|
+
|
42
|
+
def info(dragon_id = nil)
|
43
|
+
get(dragon_id)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/spacex/endpoint.rb
CHANGED
data/lib/spacex/launches.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
module SPACEX
|
2
|
+
class Missions < Hashie::Trash
|
3
|
+
include Hashie::Extensions::IgnoreUndeclared
|
4
|
+
|
5
|
+
property 'mission_id'
|
6
|
+
property 'mission_name'
|
7
|
+
property 'manufacturers'
|
8
|
+
property 'payload_ids'
|
9
|
+
property 'wikipedia'
|
10
|
+
property 'website'
|
11
|
+
property 'twitter'
|
12
|
+
property 'description'
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def retrieve_all
|
16
|
+
data = SPACEX::BaseRequest.call_api('missions')
|
17
|
+
data.get.body.map { |k| SPACEX::Missions.new(k) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def get(mission_id = nil)
|
21
|
+
return retrieve_all if mission_id.nil?
|
22
|
+
|
23
|
+
data = SPACEX::BaseRequest.get("missions/#{mission_id}")
|
24
|
+
SPACEX::Missions.new(data)
|
25
|
+
end
|
26
|
+
|
27
|
+
def info(mission_id = nil)
|
28
|
+
get(mission_id)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|