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

Add a history endpoint #45

Merged
merged 1 commit into from
Oct 19, 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
### 1.0.1 (next)
* [#45](https://github.com/rodolfobandeira/spacex/pull/45): Implement History endpoint [@invacuo](http://github.com/invacuo).

* Your contribution here.

### 1.0.0 (2018/10/15)

* [#41](https://github.com/rodolfobandeira/spacex/pull/41): General Refactor cleaning endpoint classes [@invacuo](http://github.com/invacuo).
* [#44](https://github.com/rodolfobandeira/spacex/pull/44): Add flickr_images key into rockets endpoint [@Dfenniak](https://github.com/Dfenniak).
* [#42](https://github.com/rodolfobandeira/spacex/pull/42): Add pry gem to debug - [@Dfenniak](https://github.com/Dfenniak).
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,35 @@ dragon_capsules.first.wikipedia # "https://en.wikipedia.org/wiki/SpaceX_Dragon"
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)."
```

### History

- Get information for all historical events: `SPACEX::History.info`
- Get information about a specific historical event: (e.g., `4`: `SPACEX::History.info('4')`

```ruby
require 'spacex'
historical_events = SPACEX::History.info

first_event = historical_events.first
first_event.id # 1
first_event.title # Falcon 1 Makes History
first_event.event_date_utc # 2008-09-28T23:15:00Z
first_event.event_date_unix # 1222643700
first_event.flight_number # 4
first_event.details # Falcon 1 becomes the first privately developed liquid fuel rocket to reach Earth orbit.
first_event.links['reddit'] # nil
first_event.links['article'] # http://www.spacex.com/news/2013/02/11/flight-4-launch-update-0
first_event.links['wikipedia'] # https://en.wikipedia.org/wiki/Falcon_1
```

### Launches

- Get information on all launches: `SPACEX::Launches.info`
- Get information on the next launch: `SPACEX::Launches.next`
- Get the latest launch information: `SPACEX::Launches.latest`

The following code snippet shows the latest launch information and the data fields available on the Launch object:

```ruby
require 'spacex'
latest_launch = SPACEX::Launches.latest
Expand Down
13 changes: 7 additions & 6 deletions lib/spacex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
require 'hashie'

require_relative 'spacex/base_request'
require_relative 'spacex/version'
require_relative 'spacex/launches'
require_relative 'spacex/capsules'
require_relative 'spacex/company_info'
require_relative 'spacex/roadster'
require_relative 'spacex/cores'
require_relative 'spacex/dragon_capsules'
require_relative 'spacex/ships'
require_relative 'spacex/history'
require_relative 'spacex/launches'
require_relative 'spacex/missions'
require_relative 'spacex/roadster'
require_relative 'spacex/rockets'
require_relative 'spacex/capsules'
require_relative 'spacex/cores'
require_relative 'spacex/ships'
require_relative 'spacex/version'
7 changes: 7 additions & 0 deletions lib/spacex/history.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module SPACEX
module History
def self.info(id = nil)
SPACEX::BaseRequest.info("history/#{id}")
end
end
end
62 changes: 62 additions & 0 deletions spec/fixtures/spacex/history/info.yml

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

Loading