Skip to content

Latest commit

 

History

History
179 lines (149 loc) · 7.54 KB

v4.md

File metadata and controls

179 lines (149 loc) · 7.54 KB

V4 Usage

  • Capsules
    • SPACEX::V4::Capsules.info
    • SPACEX::V4::Capsules.info('id')
  • Cores
    • SPACEX::V4::Cores.info
    • SPACEX::V4::Cores.info('id')
  • Company
    • SPACEX::V4::Company.info
  • Crew
    • SPACEX::V4::Crew.info
    • SPACEX::V4::Crew.info('id')
  • Rockets
    • SPACEX::V4::Rockets.info
    • SPACEX::V4::Rockets.info('id')

Note: Return values encapsulated in SPACEX::Response are accessible as attribute methods e.g.

first_rocket.diameter # #<SPACEX::Response feet=5.5 meters=1.68>
first_rocket.diameter.feet # 5.5
first_rocket.diameter.meters # 1.68

Return values encapsulated in Hashie::Array are accessible as regular arrays e.g.

first_rocket.flickr_images # #<Hashie::Array ["https://imgur.com/DaCfMsj.jpg", "https://imgur.com/azYafd8.jpg"]>
first_rocket.flickr_images[0] # "https://imgur.com/DaCfMsj.jpg"

Note: Return values encapsulated in SPACEX::Response are accessible as attribute methods e.g.

first_rocket.diameter # #<SPACEX::Response feet=5.5 meters=1.68>
first_rocket.diameter.feet # 5.5
first_rocket.diameter.meters # 1.68

Return values encapsulated in Hashie::Array are accessible as regular arrays e.g.

first_rocket.flickr_images # #<Hashie::Array ["https://imgur.com/DaCfMsj.jpg", "https://imgur.com/azYafd8.jpg"]>
first_rocket.flickr_images[0] # "https://imgur.com/DaCfMsj.jpg"

Capsules

  • Get information for all capsules: SPACEX::V4::Capsules.info
  • Get information about a specific capsule: SPACEX::V4::Capsules.info('id')

NOTE: As of v4, the capsules.info uses the capsule's id and not serial as it did in v3.

This example shows how to get capsules information and what the data fields are for that object:

capsules_info = SPACEX::V4::Capsules.info

capsules_info.first.id # '5e9e2c5bf35918ed873b2664'
capsules_info.first.land_landings # 0
capsules_info.first.last_update # 'Reentered after three weeks in orbit'
capsules_info.first.launches # #<Hashie::Array ["5eb87cdeffd86e000604b330"]>
capsules_info.first.launches.first # '5eb87cdeffd86e000604b330'
capsules_info.first.reuse_count # 1
capsules_info.first.serial # 'C101'
capsules_info.first.status # 'retired'
capsules_info.first.type # 'Dragon 1.0'
capsules_info.first.water_landings # 1

Cores

  • Get information for all cores: SPACEX::V4::Cores.info
  • Get information about a specific core: SPACEX::V4::Cores.info('id')

This example shows how to get cores information and what the data fields are for that object:

cores_info = SPACEX::V4::Cores.info
cores_info.last.block # 5
cores_info.last.reuse_count # 0
cores_info.last.rtls_attempts # 0
cores_info.last.rtls_landings # 0
cores_info.last.asds_attempts # 1
cores_info.last.asds_landings # 1
cores_info.last.last_update # 'Landed on OCISLY* as of June 3, 2021 '
cores_info.last.launches # #<Hashie::Array ["5fe3af84b3467846b3242161"]>
cores_info.last.launches.first # '5fe3af84b3467846b3242161'
cores_info.last.serial # B1067
cores_info.last.id # '60b800111f83cc1e59f16438'

Company

  • Get SpaceX company information: SPACEX::V4::Company.info

This example shows how to get company information and what the data fields are for that object:

company_info = SPACEX::V4::Company.info
company_info.name # 'SpaceX'
company_info.founder # 'Elon Musk'
company_info.founded # 2002
company_info.employees # 9500
company_info.vehicles # 4
company_info.launch_sites # 3
company_info.test_sites # 3
company_info.ceo # 'Elon Musk'
company_info.cto # 'Elon Musk'
company_info.coo # 'Gwynne Shotwell'
company_info.cto_propulsion # 'Tom Mueller'
company_info.valuation # 74_000_000_000
company_info.headquarters.address # 'Rocket Road'
company_info.headquarters.city # 'Hawthorne'
company_info.headquarters.state # 'California'
company_info.summary # 'SpaceX designs, manufactures and launches advanced rockets and spacecraft. The company was founded in 2002 to revolutionize space technology, with the ultimate goal of enabling people to live on other planets.'
company_info.links.website # 'https://www.spacex.com/'
company_info.links.flickr # 'https://www.flickr.com/photos/spacex/'
company_info.links.twitter # 'https://twitter.com/SpaceX'
company_info.links.elon_twitter # 'https://twitter.com/elonmusk'
company_info.id # '5eb75edc42fea42237d7f3ed'
### Rockets

- Get information for all rockets: `SPACEX::V4::Rockets.info`
- Get information about a specific rocket: `SPACEX::V4::Rockets.info('id')`

**NOTE:** As of v4, the rockets.info uses the rocket's `id` and not `rocket_id` as it did in v3.

This example shows how to get rockets information and what the data fields are for that object:


```ruby
rockets = SPACEX::V4::Rockets.info
first_rocket = rockets.first

first_rocket.active # false
first_rocket.boosters # 0
first_rocket.company # "SpaceX"
first_rocket.cost_per_launch # 6700000
first_rocket.country # "Republic of the Marshall Islands"
first_rocket.description # "The Falcon 1 was an expendable launch system privately developed and manufactured by SpaceX during 2006-2009. On 28 September 2008, Falcon 1 became the first privately-developed liquid-fuel launch vehicle to go into orbit around the Earth."
first_rocket.diameter # #<SPACEX::Response feet=5.5 meters=1.68>
first_rocket.diameter.feet # 5.5
first_rocket.diameter.meters # 1.68
first_rocket.engines # #<SPACEX::Response engine_loss_max=0 isp=#<SPACEX::Response sea_level=267 vacuum=304> layout="single" number=1 propellant_1="liquid oxygen" propellant_2="RP-1 kerosene" thrust_sea_level=#<SPACEX::Response kN=420 lbf=94000> thrust_to_weight=96 thrust_vacuum=#<SPACEX::Response kN=480 lbf=110000> type="merlin" version="1C">
first_rocket.first_flight # "2006-03-24"
first_rocket.first_stage # #<SPACEX::Response burn_time_sec=169 engines=1 fuel_amount_tons=44.3 reusable=false thrust_sea_level=#<SPACEX::Response kN=420 lbf=94000> thrust_vacuum=#<SPACEX::Response kN=480 lbf=110000>>
first_rocket.flickr_images # #<Hashie::Array ["https://imgur.com/DaCfMsj.jpg", "https://imgur.com/azYafd8.jpg"]>
first_rocket.height # #<SPACEX::Response feet=73 meters=22.25>
first_rocket.id # "5e9d0d95eda69955f709d1eb"
first_rocket.landing_legs # #<SPACEX::Response material=nil number=0>
first_rocket.mass # #<SPACEX::Response kg=30146 lb=66460>
first_rocket.name # "Falcon 1"
first_rocket.payload_weights # #<Hashie::Array [#<SPACEX::Response id="leo" kg=450 lb=992 name="Low Earth Orbit">]>
first_rocket.second_stage # #<SPACEX::Response burn_time_sec=378 engines=1 fuel_amount_tons=3.38 payloads=#<SPACEX::Response composite_fairing=#<SPACEX::Response diameter=#<SPACEX::Response feet=4.9 meters=1.5> height=#<SPACEX::Response feet=11.5 meters=3.5>> option_1="composite fairing"> reusable=false thrust=#<SPACEX::Response kN=31 lbf=7000>>
first_rocket.stages # 2
first_rocket.success_rate_pct # 40
first_rocket.type # "rocket"
first_rocket.wikipedia # "https://en.wikipedia.org/wiki/Falcon_1"

Crew

  • Get information for all crew: SPACEX::V4::Crew.info
  • Get information about a specific crew member: SPACEX::V4::Crew.info('id')

This example shows how to get crew members information and what the data fields are for that object:

crew_members = SPACEX::V4::Crew.info
first_crew_member = crew_members.first

first_crew_member.agency # "NASA"
first_crew_member.id # "5ebf1a6e23a9a60006e03a7a"
first_crew_member.image # "https://imgur.com/0smMgMH.png"
first_crew_member.launches #  #<Hashie::Array ["5eb87d46ffd86e000604b388"]>
first_crew_member.name # "Robert Behnken"
first_crew_member.status # "active"
first_crew_member.wikipedia # "https://en.wikipedia.org/wiki/Robert_L._Behnken"