Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Rockets endpoint #35

Merged
merged 5 commits into from
Oct 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 0.0.8 (next)

* [#35](https://github.com/rodolfobandeira/spacex/pull/35): Implement Rockets endpoint - [@invacuo](https://github.com/invacuo)
* [#28](https://github.com/rodolfobandeira/spacex/pull/28): Add ability to query all launches - [@ludamillion](https://github.com/ludamillion)
* [#26](https://github.com/rodolfobandeira/spacex/pull/26): Fix dependencies - [@harman28](https://github.com/harman28).
* [#25](https://github.com/rodolfobandeira/spacex/pull/25): Add code coverage tools - [@harman28](https://github.com/harman28).
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Ruby library that consumes SpaceX API
- [Missions](#missions)
- `SPACEX::Missions.info`
- `SPACEX::Missions.info('mission_id')`
- [Contributing](#contributing)
- [Contributing](#contributing)
- [Contributors / Changelog](#contributors)
- [Copyright](#copyright)

Expand Down Expand Up @@ -276,6 +276,12 @@ missions.first.twitter # "https://twitter.com/IridiumBoss?lang=en"
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."
```

### Rockets

- `SPACEX::Rockets.info` Retrieve all Rockets;
- `SPACEX::Rockets.info('falcon1')` Retrieve a specific rocket. Ex: `falcon1`


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for skipping the example like we did with all methods? Do you feel that it is an overhead adding examples for each method?

## Contributing

See [CONTRIBUTING](CONTRIBUTING.md).
Expand Down
1 change: 1 addition & 0 deletions lib/spacex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
require_relative 'spacex/dragon_capsules'
require_relative 'spacex/ships'
require_relative 'spacex/missions'
require_relative 'spacex/rockets'
48 changes: 48 additions & 0 deletions lib/spacex/rockets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module SPACEX
class Rockets < Hashie::Trash
include Hashie::Extensions::IgnoreUndeclared

property 'id'
property 'active'
property 'stages'
property 'boosters'
property 'cost_per_launch'
property 'success_rate_pct'
property 'first_flight'
property 'country'
property 'company'
property 'height'
property 'diameter'
property 'mass'
property 'payload_weights'
property 'first_stage'
property 'second_stage'
property 'engines'
property 'landing_legs'
property 'wikipedia'
property 'description'
property 'rocket_id'
property 'rocket_name'
property 'rocket_type'

class << self
def info(rocket_id = nil)
get(rocket_id)
end

private
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason some endpoints have this get or retrieve_all public is that at some point in the past these were exposed as the default methods. So in order to make them backwards compatible, even after we adopted the info and info(foo) as default, I decided to keep carrying them over. You'll probably see people opening PRs using get, retrieve_all instead of info (which is understandable).

I saw your other comments regarding this and I agree with you specially because our release is still at minor versions 0.0.8. Thats the reason I'm not documenting these method on README anymore. I'm planning to release a major version 1.0.0 after closing this list of PRs.

By the way, I got your twitter message. You're more than welcome to help out!


def retrieve_all
data = SPACEX::BaseRequest.call_api('rockets')
data.get.body.map { |k| SPACEX::Rockets.new(k) }
end

def get(rocket_id = nil)
return retrieve_all if rocket_id.nil?

data = SPACEX::BaseRequest.get("rockets/#{rocket_id}")
SPACEX::Rockets.new(data)
end
end
end
end
107 changes: 107 additions & 0 deletions spec/fixtures/spacex/rockets/info.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading