spacex 1.0.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +26 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +6 -0
  5. data/.rubocop_todo.yml +1 -1
  6. data/CHANGELOG.md +54 -1
  7. data/CLAUDE.md +55 -0
  8. data/Dangerfile +28 -0
  9. data/Gemfile +12 -1
  10. data/README.md +52 -510
  11. data/docs/v3.md +525 -0
  12. data/docs/v4.md +179 -0
  13. data/lib/spacex/base_request.rb +8 -8
  14. data/lib/spacex/capsules.rb +10 -12
  15. data/lib/spacex/company.rb +7 -0
  16. data/lib/spacex/cores.rb +11 -14
  17. data/lib/spacex/crew.rb +15 -0
  18. data/lib/spacex/{dragon_capsules.rb → dragons.rb} +14 -16
  19. data/lib/spacex/history.rb +9 -2
  20. data/lib/spacex/landpads.rb +23 -0
  21. data/lib/spacex/launches.rb +35 -11
  22. data/lib/spacex/launchpads.rb +23 -0
  23. data/lib/spacex/models.rb +16 -0
  24. data/lib/spacex/payloads.rb +31 -2
  25. data/lib/spacex/rockets.rb +26 -3
  26. data/lib/spacex/ships.rb +22 -24
  27. data/lib/spacex/starlink.rb +16 -0
  28. data/lib/spacex/version.rb +1 -1
  29. data/lib/spacex.rb +2 -17
  30. data/spacex.gemspec +6 -9
  31. data/spec/coverage_helper.rb +5 -0
  32. data/spec/fixtures/spacex/v4/capsules/all.yml +122 -0
  33. data/spec/fixtures/spacex/v4/capsules/one.yml +89 -0
  34. data/spec/fixtures/spacex/v4/company.yml +80 -0
  35. data/spec/fixtures/spacex/v4/cores/all.yml +76 -0
  36. data/spec/fixtures/spacex/v4/cores/one.yml +75 -0
  37. data/spec/fixtures/spacex/v4/crew/all.yml +92 -0
  38. data/spec/fixtures/spacex/v4/crew/one.yml +74 -0
  39. data/spec/fixtures/spacex/v4/dragons/all.yml +101 -0
  40. data/spec/fixtures/spacex/v4/dragons/one.yml +189 -0
  41. data/spec/fixtures/spacex/v4/history/all.yml +85 -0
  42. data/spec/fixtures/spacex/v4/history/one.yml +168 -0
  43. data/spec/fixtures/spacex/v4/landpads/all.yml +85 -0
  44. data/spec/fixtures/spacex/v4/landpads/one.yml +172 -0
  45. data/spec/fixtures/spacex/v4/launches/all.yml +85 -0
  46. data/spec/fixtures/spacex/v4/launches/latest.yml +84 -0
  47. data/spec/fixtures/spacex/v4/launches/next.yml +84 -0
  48. data/spec/fixtures/spacex/v4/launches/one.yml +167 -0
  49. data/spec/fixtures/spacex/v4/launches/past.yml +85 -0
  50. data/spec/fixtures/spacex/v4/launches/upcoming.yml +97 -0
  51. data/spec/fixtures/spacex/v4/launchpads/all.yml +139 -0
  52. data/spec/fixtures/spacex/v4/launchpads/one.yml +225 -0
  53. data/spec/fixtures/spacex/v4/payloads/all.yml +85 -0
  54. data/spec/fixtures/spacex/v4/payloads/one.yml +167 -0
  55. data/spec/fixtures/spacex/v4/roadster.yml +90 -0
  56. data/spec/fixtures/spacex/v4/rockets/all.yml +76 -0
  57. data/spec/fixtures/spacex/v4/rockets/one.yml +84 -0
  58. data/spec/fixtures/spacex/v4/ships/all.yml +164 -0
  59. data/spec/fixtures/spacex/v4/ships/one.yml +248 -0
  60. data/spec/fixtures/spacex/v4/starlink/all.yml +17713 -0
  61. data/spec/fixtures/spacex/v4/starlink/one.yml +17798 -0
  62. data/spec/spacex/base_request_spec.rb +112 -0
  63. data/spec/spacex/capsules_spec.rb +19 -28
  64. data/spec/spacex/company_spec.rb +26 -0
  65. data/spec/spacex/cores_spec.rb +18 -31
  66. data/spec/spacex/crew_spec.rb +27 -0
  67. data/spec/spacex/dragons_spec.rb +39 -0
  68. data/spec/spacex/history_spec.rb +16 -40
  69. data/spec/spacex/landpads_spec.rb +35 -0
  70. data/spec/spacex/launches_spec.rb +28 -628
  71. data/spec/spacex/launchpads_spec.rb +34 -0
  72. data/spec/spacex/payloads_spec.rb +27 -51
  73. data/spec/spacex/roadster_spec.rb +5 -29
  74. data/spec/spacex/rockets_spec.rb +26 -194
  75. data/spec/spacex/ships_spec.rb +20 -51
  76. data/spec/spacex/starlink_spec.rb +28 -0
  77. data/spec/spacex/version_spec.rb +12 -0
  78. data/spec/spec_helper.rb +3 -9
  79. metadata +106 -137
  80. data/.ruby-version +0 -1
  81. data/.travis.yml +0 -21
  82. data/lib/spacex/api_info.rb +0 -7
  83. data/lib/spacex/company_info.rb +0 -7
  84. data/lib/spacex/endpoint.rb +0 -3
  85. data/lib/spacex/landing_pads.rb +0 -11
  86. data/lib/spacex/launch_pads.rb +0 -11
  87. data/lib/spacex/missions.rb +0 -18
  88. data/spec/fixtures/spacex/api_info/info.yml +0 -65
  89. data/spec/fixtures/spacex/capsules/C202.yml +0 -123
  90. data/spec/fixtures/spacex/capsules.yml +0 -83
  91. data/spec/fixtures/spacex/company_info/info.yml +0 -129
  92. data/spec/fixtures/spacex/cores/B1041.yml +0 -123
  93. data/spec/fixtures/spacex/cores.yml +0 -62
  94. data/spec/fixtures/spacex/dragon_capsules/info/dragon1.yml +0 -131
  95. data/spec/fixtures/spacex/dragon_capsules/info.yml +0 -77
  96. data/spec/fixtures/spacex/history/info/4.yml +0 -62
  97. data/spec/fixtures/spacex/history/info.yml +0 -62
  98. data/spec/fixtures/spacex/landing_pads/info/LZ-4.yml +0 -70
  99. data/spec/fixtures/spacex/landing_pads/info.yml +0 -68
  100. data/spec/fixtures/spacex/launch_pads/info/vafb_slc_4e.yml +0 -71
  101. data/spec/fixtures/spacex/launch_pads/info.yml +0 -104
  102. data/spec/fixtures/spacex/launches/68.yml +0 -69
  103. data/spec/fixtures/spacex/launches/all.yml +0 -62
  104. data/spec/fixtures/spacex/launches/info.yml +0 -62
  105. data/spec/fixtures/spacex/launches/latest.yml +0 -245
  106. data/spec/fixtures/spacex/launches/next.yml +0 -123
  107. data/spec/fixtures/spacex/launches/past.yml +0 -62
  108. data/spec/fixtures/spacex/launches/upcoming.yml +0 -64
  109. data/spec/fixtures/spacex/launches.yml +0 -62
  110. data/spec/fixtures/spacex/missions/F3364BF.yml +0 -157
  111. data/spec/fixtures/spacex/missions/info.yml +0 -62
  112. data/spec/fixtures/spacex/payloads/RatSat.yml +0 -62
  113. data/spec/fixtures/spacex/payloads/info.yml +0 -62
  114. data/spec/fixtures/spacex/roadster/info.yml +0 -133
  115. data/spec/fixtures/spacex/rockets/info/falcon1.yml +0 -139
  116. data/spec/fixtures/spacex/rockets/info/invalid.yml +0 -61
  117. data/spec/fixtures/spacex/rockets/info.yml +0 -105
  118. data/spec/fixtures/spacex/ships/info/AMERICANCHAMPION.yml +0 -125
  119. data/spec/fixtures/spacex/ships/info.yml +0 -139
  120. data/spec/spacex/api_info_spec.rb +0 -16
  121. data/spec/spacex/company_info_spec.rb +0 -27
  122. data/spec/spacex/dragon_capsules_spec.rb +0 -107
  123. data/spec/spacex/endpoint_spec.rb +0 -9
  124. data/spec/spacex/landing_pads_spec.rb +0 -72
  125. data/spec/spacex/launch_pads_spec.rb +0 -77
  126. data/spec/spacex/missions_spec.rb +0 -35
data/docs/v4.md ADDED
@@ -0,0 +1,179 @@
1
+ # V4 Usage
2
+ - [Capsules](#capsules)
3
+ - `SPACEX::V4::Capsules.info`
4
+ - `SPACEX::V4::Capsules.info('id')`
5
+ - [Cores](#cores)
6
+ - `SPACEX::V4::Cores.info`
7
+ - `SPACEX::V4::Cores.info('id')`
8
+ - [Company](#company)
9
+ - `SPACEX::V4::Company.info`
10
+ - [Crew](#crew)
11
+ - `SPACEX::V4::Crew.info`
12
+ - `SPACEX::V4::Crew.info('id')`
13
+ - [Rockets](#rockets)
14
+ - `SPACEX::V4::Rockets.info`
15
+ - `SPACEX::V4::Rockets.info('id')`
16
+
17
+ **Note:**
18
+ Return values encapsulated in `SPACEX::Response` are accessible as attribute methods e.g.
19
+
20
+ ```ruby
21
+ first_rocket.diameter # #<SPACEX::Response feet=5.5 meters=1.68>
22
+ first_rocket.diameter.feet # 5.5
23
+ first_rocket.diameter.meters # 1.68
24
+ ```
25
+
26
+ Return values encapsulated in `Hashie::Array` are accessible as regular arrays e.g.
27
+
28
+ ```ruby
29
+ first_rocket.flickr_images # #<Hashie::Array ["https://imgur.com/DaCfMsj.jpg", "https://imgur.com/azYafd8.jpg"]>
30
+ first_rocket.flickr_images[0] # "https://imgur.com/DaCfMsj.jpg"
31
+ ```
32
+
33
+ **Note:**
34
+ Return values encapsulated in `SPACEX::Response` are accessible as attribute methods e.g.
35
+ ```ruby
36
+ first_rocket.diameter # #<SPACEX::Response feet=5.5 meters=1.68>
37
+ first_rocket.diameter.feet # 5.5
38
+ first_rocket.diameter.meters # 1.68
39
+ ```
40
+ Return values encapsulated in `Hashie::Array` are accessible as regular arrays e.g.
41
+ ```ruby
42
+ first_rocket.flickr_images # #<Hashie::Array ["https://imgur.com/DaCfMsj.jpg", "https://imgur.com/azYafd8.jpg"]>
43
+ first_rocket.flickr_images[0] # "https://imgur.com/DaCfMsj.jpg"
44
+ ```
45
+
46
+ ### Capsules
47
+
48
+ - Get information for all capsules: `SPACEX::V4::Capsules.info`
49
+ - Get information about a specific capsule: `SPACEX::V4::Capsules.info('id')`
50
+
51
+ **NOTE:** As of v4, the capsules.info uses the capsule's `id` and not `serial` as it did in v3.
52
+
53
+
54
+ This example shows how to get capsules information and what the data fields are for that object:
55
+
56
+ ```ruby
57
+ capsules_info = SPACEX::V4::Capsules.info
58
+
59
+ capsules_info.first.id # '5e9e2c5bf35918ed873b2664'
60
+ capsules_info.first.land_landings # 0
61
+ capsules_info.first.last_update # 'Reentered after three weeks in orbit'
62
+ capsules_info.first.launches # #<Hashie::Array ["5eb87cdeffd86e000604b330"]>
63
+ capsules_info.first.launches.first # '5eb87cdeffd86e000604b330'
64
+ capsules_info.first.reuse_count # 1
65
+ capsules_info.first.serial # 'C101'
66
+ capsules_info.first.status # 'retired'
67
+ capsules_info.first.type # 'Dragon 1.0'
68
+ capsules_info.first.water_landings # 1
69
+ ```
70
+
71
+ ### Cores
72
+
73
+ - Get information for all cores: `SPACEX::V4::Cores.info`
74
+ - Get information about a specific core: `SPACEX::V4::Cores.info('id')`
75
+
76
+ This example shows how to get cores information and what the data fields are for that object:
77
+
78
+ ```ruby
79
+ cores_info = SPACEX::V4::Cores.info
80
+ cores_info.last.block # 5
81
+ cores_info.last.reuse_count # 0
82
+ cores_info.last.rtls_attempts # 0
83
+ cores_info.last.rtls_landings # 0
84
+ cores_info.last.asds_attempts # 1
85
+ cores_info.last.asds_landings # 1
86
+ cores_info.last.last_update # 'Landed on OCISLY* as of June 3, 2021 '
87
+ cores_info.last.launches # #<Hashie::Array ["5fe3af84b3467846b3242161"]>
88
+ cores_info.last.launches.first # '5fe3af84b3467846b3242161'
89
+ cores_info.last.serial # B1067
90
+ cores_info.last.id # '60b800111f83cc1e59f16438'
91
+ ```
92
+
93
+ ### Company
94
+
95
+ - Get SpaceX company information: `SPACEX::V4::Company.info`
96
+
97
+ This example shows how to get company information and what the data fields are for that object:
98
+
99
+ ```ruby
100
+ company_info = SPACEX::V4::Company.info
101
+ company_info.name # 'SpaceX'
102
+ company_info.founder # 'Elon Musk'
103
+ company_info.founded # 2002
104
+ company_info.employees # 9500
105
+ company_info.vehicles # 4
106
+ company_info.launch_sites # 3
107
+ company_info.test_sites # 3
108
+ company_info.ceo # 'Elon Musk'
109
+ company_info.cto # 'Elon Musk'
110
+ company_info.coo # 'Gwynne Shotwell'
111
+ company_info.cto_propulsion # 'Tom Mueller'
112
+ company_info.valuation # 74_000_000_000
113
+ company_info.headquarters.address # 'Rocket Road'
114
+ company_info.headquarters.city # 'Hawthorne'
115
+ company_info.headquarters.state # 'California'
116
+ 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.'
117
+ company_info.links.website # 'https://www.spacex.com/'
118
+ company_info.links.flickr # 'https://www.flickr.com/photos/spacex/'
119
+ company_info.links.twitter # 'https://twitter.com/SpaceX'
120
+ company_info.links.elon_twitter # 'https://twitter.com/elonmusk'
121
+ company_info.id # '5eb75edc42fea42237d7f3ed'
122
+ ### Rockets
123
+
124
+ - Get information for all rockets: `SPACEX::V4::Rockets.info`
125
+ - Get information about a specific rocket: `SPACEX::V4::Rockets.info('id')`
126
+
127
+ **NOTE:** As of v4, the rockets.info uses the rocket's `id` and not `rocket_id` as it did in v3.
128
+
129
+ This example shows how to get rockets information and what the data fields are for that object:
130
+
131
+
132
+ ```ruby
133
+ rockets = SPACEX::V4::Rockets.info
134
+ first_rocket = rockets.first
135
+
136
+ first_rocket.active # false
137
+ first_rocket.boosters # 0
138
+ first_rocket.company # "SpaceX"
139
+ first_rocket.cost_per_launch # 6700000
140
+ first_rocket.country # "Republic of the Marshall Islands"
141
+ 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."
142
+ first_rocket.diameter # #<SPACEX::Response feet=5.5 meters=1.68>
143
+ first_rocket.diameter.feet # 5.5
144
+ first_rocket.diameter.meters # 1.68
145
+ 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">
146
+ first_rocket.first_flight # "2006-03-24"
147
+ 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>>
148
+ first_rocket.flickr_images # #<Hashie::Array ["https://imgur.com/DaCfMsj.jpg", "https://imgur.com/azYafd8.jpg"]>
149
+ first_rocket.height # #<SPACEX::Response feet=73 meters=22.25>
150
+ first_rocket.id # "5e9d0d95eda69955f709d1eb"
151
+ first_rocket.landing_legs # #<SPACEX::Response material=nil number=0>
152
+ first_rocket.mass # #<SPACEX::Response kg=30146 lb=66460>
153
+ first_rocket.name # "Falcon 1"
154
+ first_rocket.payload_weights # #<Hashie::Array [#<SPACEX::Response id="leo" kg=450 lb=992 name="Low Earth Orbit">]>
155
+ 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>>
156
+ first_rocket.stages # 2
157
+ first_rocket.success_rate_pct # 40
158
+ first_rocket.type # "rocket"
159
+ first_rocket.wikipedia # "https://en.wikipedia.org/wiki/Falcon_1"
160
+ ```
161
+
162
+ ### Crew
163
+ - Get information for all crew: `SPACEX::V4::Crew.info`
164
+ - Get information about a specific crew member: `SPACEX::V4::Crew.info('id')`
165
+
166
+ This example shows how to get crew members information and what the data fields are for that object:
167
+
168
+ ```ruby
169
+ crew_members = SPACEX::V4::Crew.info
170
+ first_crew_member = crew_members.first
171
+
172
+ first_crew_member.agency # "NASA"
173
+ first_crew_member.id # "5ebf1a6e23a9a60006e03a7a"
174
+ first_crew_member.image # "https://imgur.com/0smMgMH.png"
175
+ first_crew_member.launches # #<Hashie::Array ["5eb87d46ffd86e000604b388"]>
176
+ first_crew_member.name # "Robert Behnken"
177
+ first_crew_member.status # "active"
178
+ first_crew_member.wikipedia # "https://en.wikipedia.org/wiki/Robert_L._Behnken"
179
+ ```
@@ -1,21 +1,21 @@
1
1
  module SPACEX
2
+ BASE_URI = 'https://api.spacexdata.com'.freeze
3
+
2
4
  class Response < Hashie::Mash
3
5
  disable_warnings
4
6
  end
5
7
 
6
8
  module BaseRequest
7
9
  class << self
8
- def info(path, klass = nil, params = {})
9
- response_body = get(path, params).body
10
+ def info(path, klass = nil)
11
+ response_body = get(path).body
10
12
  process(response_body, klass)
11
13
  end
12
14
 
13
15
  private
14
16
 
15
- def get(path, params)
16
- conn(path).get do |req|
17
- req.params = params
18
- end
17
+ def get(path)
18
+ conn(path).get
19
19
  end
20
20
 
21
21
  def process(response_body, klass)
@@ -42,12 +42,12 @@ module SPACEX
42
42
 
43
43
  def conn(path)
44
44
  Faraday.new(
45
- url: "#{SPACEX::ENDPOINT_URI}/#{path}",
45
+ url: "#{SPACEX::BASE_URI}/v4/#{path}",
46
46
  request: {
47
47
  params_encoder: Faraday::FlatParamsEncoder
48
48
  }
49
49
  ) do |connection|
50
- connection.use ::FaradayMiddleware::ParseJson
50
+ connection.response :json
51
51
  connection.use Faraday::Response::RaiseError
52
52
  connection.adapter ::Faraday.default_adapter
53
53
  end
@@ -1,19 +1,17 @@
1
1
  module SPACEX
2
- class Capsules < Hashie::Trash
3
- include Hashie::Extensions::IgnoreUndeclared
4
-
5
- property 'capsule_serial'
6
- property 'capsule_id'
2
+ class Capsules < SPACEX::Resource
3
+ property 'id'
4
+ property 'land_landings'
5
+ property 'last_update'
6
+ property 'launches'
7
+ property 'reuse_count'
8
+ property 'serial'
7
9
  property 'status'
8
- property 'original_launch'
9
- property 'original_launch_unix'
10
- property 'missions'
11
- property 'landings'
12
10
  property 'type'
13
- property 'details'
11
+ property 'water_landings'
14
12
 
15
- def self.info(capsule_serial = nil)
16
- SPACEX::BaseRequest.info("capsules/#{capsule_serial}", SPACEX::Capsules)
13
+ def self.info(id = nil)
14
+ SPACEX::BaseRequest.info("capsules/#{id}", SPACEX::Capsules)
17
15
  end
18
16
  end
19
17
  end
@@ -0,0 +1,7 @@
1
+ module SPACEX
2
+ module Company
3
+ def self.info
4
+ SPACEX::BaseRequest.info('company')
5
+ end
6
+ end
7
+ end
data/lib/spacex/cores.rb CHANGED
@@ -1,22 +1,19 @@
1
1
  module SPACEX
2
- class Cores < Hashie::Trash
3
- include Hashie::Extensions::IgnoreUndeclared
4
-
5
- property 'core_serial'
2
+ class Cores < SPACEX::Resource
3
+ property 'asds_attempts'
4
+ property 'asds_landings'
6
5
  property 'block'
7
- property 'status'
8
- property 'original_launch'
9
- property 'original_launch_unix'
10
- property 'missions'
6
+ property 'id'
7
+ property 'last_update'
8
+ property 'launches'
9
+ property 'reuse_count'
11
10
  property 'rtls_attempts'
12
11
  property 'rtls_landings'
13
- property 'asds_attempts'
14
- property 'asds_landings'
15
- property 'water_landing'
16
- property 'details'
12
+ property 'serial'
13
+ property 'status'
17
14
 
18
- def self.info(core_serial = nil)
19
- SPACEX::BaseRequest.info("cores/#{core_serial}", SPACEX::Cores)
15
+ def self.info(id = nil)
16
+ SPACEX::BaseRequest.info("cores/#{id}", SPACEX::Cores)
20
17
  end
21
18
  end
22
19
  end
@@ -0,0 +1,15 @@
1
+ module SPACEX
2
+ class Crew < SPACEX::Resource
3
+ property 'agency'
4
+ property 'id'
5
+ property 'image'
6
+ property 'launches'
7
+ property 'name'
8
+ property 'status'
9
+ property 'wikipedia'
10
+
11
+ def self.info(id = nil)
12
+ SPACEX::BaseRequest.info("crew/#{id}", SPACEX::Crew)
13
+ end
14
+ end
15
+ end
@@ -1,33 +1,31 @@
1
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'
2
+ class Dragons < SPACEX::Resource
8
3
  property 'active'
9
4
  property 'crew_capacity'
10
- property 'sidewall_angle_deg'
11
- property 'orbit_duration_yr'
5
+ property 'description'
6
+ property 'diameter'
12
7
  property 'dry_mass_kg'
13
8
  property 'dry_mass_lb'
14
9
  property 'first_flight'
10
+ property 'flickr_images'
15
11
  property 'heat_shield'
16
- property 'thrusters'
12
+ property 'height_w_trunk'
13
+ property 'id'
17
14
  property 'launch_payload_mass'
18
15
  property 'launch_payload_vol'
16
+ property 'name'
17
+ property 'orbit_duration_yr'
18
+ property 'pressurized_capsule'
19
19
  property 'return_payload_mass'
20
20
  property 'return_payload_vol'
21
- property 'pressurized_capsule'
21
+ property 'sidewall_angle_deg'
22
+ property 'thrusters'
22
23
  property 'trunk'
23
- property 'height_w_trunk'
24
- property 'diameter'
25
- property 'flickr_images'
24
+ property 'type'
26
25
  property 'wikipedia'
27
- property 'description'
28
26
 
29
- def self.info(dragon_id = nil)
30
- SPACEX::BaseRequest.info("dragons/#{dragon_id}", SPACEX::DragonCapsules)
27
+ def self.info(id = nil)
28
+ SPACEX::BaseRequest.info("dragons/#{id}", SPACEX::Dragons)
31
29
  end
32
30
  end
33
31
  end
@@ -1,7 +1,14 @@
1
1
  module SPACEX
2
- module History
2
+ class History < SPACEX::Resource
3
+ property 'details'
4
+ property 'event_date_unix'
5
+ property 'event_date_utc'
6
+ property 'id'
7
+ property 'links'
8
+ property 'title'
9
+
3
10
  def self.info(id = nil)
4
- SPACEX::BaseRequest.info("history/#{id}")
11
+ SPACEX::BaseRequest.info("history/#{id}", SPACEX::History)
5
12
  end
6
13
  end
7
14
  end
@@ -0,0 +1,23 @@
1
+ module SPACEX
2
+ class Landpads < SPACEX::Resource
3
+ property 'details'
4
+ property 'full_name'
5
+ property 'id'
6
+ property 'images'
7
+ property 'landing_attempts'
8
+ property 'landing_successes'
9
+ property 'latitude'
10
+ property 'launches'
11
+ property 'locality'
12
+ property 'longitude'
13
+ property 'name'
14
+ property 'region'
15
+ property 'status'
16
+ property 'type'
17
+ property 'wikipedia'
18
+
19
+ def self.info(id = nil)
20
+ SPACEX::BaseRequest.info("landpads/#{id}", SPACEX::Landpads)
21
+ end
22
+ end
23
+ end
@@ -1,27 +1,51 @@
1
1
  module SPACEX
2
- module Launches
3
- def self.info(flight_number = nil)
4
- SPACEX::BaseRequest.info("launches/#{flight_number}")
2
+ class Launches < SPACEX::Resource
3
+ property 'auto_update'
4
+ property 'capsules'
5
+ property 'cores'
6
+ property 'crew'
7
+ property 'date_local'
8
+ property 'date_precision'
9
+ property 'date_unix'
10
+ property 'date_utc'
11
+ property 'details'
12
+ property 'failures'
13
+ property 'fairings'
14
+ property 'flight_number'
15
+ property 'id'
16
+ property 'launch_library_id'
17
+ property 'launchpad'
18
+ property 'links'
19
+ property 'name'
20
+ property 'net'
21
+ property 'payloads'
22
+ property 'rocket'
23
+ property 'ships'
24
+ property 'static_fire_date_unix'
25
+ property 'static_fire_date_utc'
26
+ property 'success'
27
+ property 'tbd'
28
+ property 'upcoming'
29
+ property 'window'
30
+
31
+ def self.info(id = nil)
32
+ SPACEX::BaseRequest.info("launches/#{id}", SPACEX::Launches)
5
33
  end
6
34
 
7
35
  def self.latest
8
- SPACEX::BaseRequest.info('launches/latest')
36
+ SPACEX::BaseRequest.info('launches/latest', SPACEX::Launches)
9
37
  end
10
38
 
11
39
  def self.next
12
- SPACEX::BaseRequest.info('launches/next')
40
+ SPACEX::BaseRequest.info('launches/next', SPACEX::Launches)
13
41
  end
14
42
 
15
43
  def self.past
16
- SPACEX::BaseRequest.info('launches/past')
44
+ SPACEX::BaseRequest.info('launches/past', SPACEX::Launches)
17
45
  end
18
46
 
19
47
  def self.upcoming
20
- SPACEX::BaseRequest.info('launches/upcoming')
21
- end
22
-
23
- def self.all
24
- info
48
+ SPACEX::BaseRequest.info('launches/upcoming', SPACEX::Launches)
25
49
  end
26
50
  end
27
51
  end
@@ -0,0 +1,23 @@
1
+ module SPACEX
2
+ class Launchpads < SPACEX::Resource
3
+ property 'details'
4
+ property 'full_name'
5
+ property 'id'
6
+ property 'images'
7
+ property 'latitude'
8
+ property 'launch_attempts'
9
+ property 'launch_successes'
10
+ property 'launches'
11
+ property 'locality'
12
+ property 'longitude'
13
+ property 'name'
14
+ property 'region'
15
+ property 'rockets'
16
+ property 'status'
17
+ property 'timezone'
18
+
19
+ def self.info(id = nil)
20
+ SPACEX::BaseRequest.info("launchpads/#{id}", SPACEX::Launchpads)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ module SPACEX
2
+ autoload :Capsules, 'spacex/capsules'
3
+ autoload :Company, 'spacex/company'
4
+ autoload :Cores, 'spacex/cores'
5
+ autoload :Crew, 'spacex/crew'
6
+ autoload :Dragons, 'spacex/dragons'
7
+ autoload :History, 'spacex/history'
8
+ autoload :Landpads, 'spacex/landpads'
9
+ autoload :Launches, 'spacex/launches'
10
+ autoload :Launchpads, 'spacex/launchpads'
11
+ autoload :Payloads, 'spacex/payloads'
12
+ autoload :Roadster, 'spacex/roadster'
13
+ autoload :Rockets, 'spacex/rockets'
14
+ autoload :Ships, 'spacex/ships'
15
+ autoload :Starlink, 'spacex/starlink'
16
+ end
@@ -1,7 +1,36 @@
1
1
  module SPACEX
2
- module Payloads
2
+ class Payloads < SPACEX::Resource
3
+ property 'apoapsis_km'
4
+ property 'arg_of_pericenter'
5
+ property 'customers'
6
+ property 'dragon'
7
+ property 'eccentricity'
8
+ property 'epoch'
9
+ property 'id'
10
+ property 'inclination_deg'
11
+ property 'launch'
12
+ property 'lifespan_years'
13
+ property 'longitude'
14
+ property 'manufacturers'
15
+ property 'mass_kg'
16
+ property 'mass_lbs'
17
+ property 'mean_anomaly'
18
+ property 'mean_motion'
19
+ property 'name'
20
+ property 'nationalities'
21
+ property 'norad_ids'
22
+ property 'orbit'
23
+ property 'periapsis_km'
24
+ property 'period_min'
25
+ property 'raan'
26
+ property 'reference_system'
27
+ property 'regime'
28
+ property 'reused'
29
+ property 'semi_major_axis_km'
30
+ property 'type'
31
+
3
32
  def self.info(id = nil)
4
- SPACEX::BaseRequest.info("payloads/#{id}")
33
+ SPACEX::BaseRequest.info("payloads/#{id}", SPACEX::Payloads)
5
34
  end
6
35
  end
7
36
  end
@@ -1,7 +1,30 @@
1
1
  module SPACEX
2
- module Rockets
3
- def self.info(rocket_id = nil)
4
- SPACEX::BaseRequest.info("rockets/#{rocket_id}")
2
+ class Rockets < SPACEX::Resource
3
+ property 'active'
4
+ property 'boosters'
5
+ property 'company'
6
+ property 'cost_per_launch'
7
+ property 'country'
8
+ property 'description'
9
+ property 'diameter'
10
+ property 'engines'
11
+ property 'first_flight'
12
+ property 'first_stage'
13
+ property 'flickr_images'
14
+ property 'height'
15
+ property 'id'
16
+ property 'landing_legs'
17
+ property 'mass'
18
+ property 'name'
19
+ property 'payload_weights'
20
+ property 'second_stage'
21
+ property 'stages'
22
+ property 'success_rate_pct'
23
+ property 'type'
24
+ property 'wikipedia'
25
+
26
+ def self.info(id = nil)
27
+ SPACEX::BaseRequest.info("rockets/#{id}", SPACEX::Rockets)
5
28
  end
6
29
  end
7
30
  end
data/lib/spacex/ships.rb CHANGED
@@ -1,33 +1,31 @@
1
1
  module SPACEX
2
- class Ships < Hashie::Trash
3
- include Hashie::Extensions::IgnoreUndeclared
4
-
5
- property 'ship_id', from: 'id'
6
- property 'ship_name'
7
- property 'ship_model'
8
- property 'ship_type'
9
- property 'roles'
2
+ class Ships < SPACEX::Resource
3
+ property 'abs'
10
4
  property 'active'
5
+ property 'course_deg'
6
+ property 'home_port'
7
+ property 'id'
8
+ property 'image'
11
9
  property 'imo'
10
+ property 'last_ais_update'
11
+ property 'latitude'
12
+ property 'launches'
13
+ property 'legacy_id'
14
+ property 'link'
15
+ property 'longitude'
16
+ property 'mass_kg'
17
+ property 'mass_lbs'
12
18
  property 'mmsi'
13
- property 'abs'
14
- property 'ship_class', from: 'class'
15
- property 'weight_lbs'
16
- property 'weight_kg'
17
- property 'year_built'
18
- property 'home_port'
19
- property 'status'
19
+ property 'model'
20
+ property 'name'
21
+ property 'roles'
20
22
  property 'speed_kn'
21
- property 'course_deg'
22
- property 'position'
23
- property 'successful_landings'
24
- property 'attempted_landings'
25
- property 'missions'
26
- property 'url'
27
- property 'image'
23
+ property 'status'
24
+ property 'type'
25
+ property 'year_built'
28
26
 
29
- def self.info(ship_id = nil)
30
- SPACEX::BaseRequest.info("ships/#{ship_id}", SPACEX::Ships)
27
+ def self.info(id = nil)
28
+ SPACEX::BaseRequest.info("ships/#{id}", SPACEX::Ships)
31
29
  end
32
30
  end
33
31
  end
@@ -0,0 +1,16 @@
1
+ module SPACEX
2
+ class Starlink < SPACEX::Resource
3
+ property 'height_km'
4
+ property 'id'
5
+ property 'latitude'
6
+ property 'launch'
7
+ property 'longitude'
8
+ property 'spaceTrack'
9
+ property 'velocity_kms'
10
+ property 'version'
11
+
12
+ def self.info(id = nil)
13
+ SPACEX::BaseRequest.info("starlink/#{id}", SPACEX::Starlink)
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  module SPACEX
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '2.0.0'.freeze
3
3
 
4
4
  def self.help
5
5
  puts 'https://github.com/rodolfobandeira/spacex'