-
-
Notifications
You must be signed in to change notification settings - Fork 22
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 remaining stations endpoints #20
Conversation
|
||
def delete_station(id) | ||
delete("stations/#{id}") | ||
nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dblock what would you suggest to return here? Currently it the delete
method returns as empty string (response.body
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think nil
is fine.
end | ||
|
||
def update_station(id, options = {}) | ||
OpenWeather::Models::Station.new(put("stations/#{id}", options)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why, but it seems like the API requires external_id
to be specified 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I could potentially raise an error if id
was not defined, do you have a suggestion on how to define / where to keep errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a parameter is missing, raise ArgumentError, generally I don't specialize errors unless they can happen on all APIs (e.g. incorrect HTTP proxy)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff. Comments:
CHANGELOG.md
Outdated
@@ -1,6 +1,7 @@ | |||
### 0.2.1 (Next) | |||
|
|||
* Your contribution here. | |||
* [#20](https://github.com/dblock/open-weather-ruby-client/pull/20): Add remaining stations endpoints - [@wasabigeek](https://github.com/wasabigeek). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combine these into [#20](), [#19](), ...: Add support for weather stations - ...
README.md
Outdated
@@ -222,6 +225,33 @@ To list all stations, you can call the client method: | |||
data = client.list_stations # => Array[OpenWeather::Models::Station] | |||
``` | |||
|
|||
#### Get Station | |||
|
|||
To get a stations, you can call the client method: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove "you can", it goes without saying :) same below
README.md
Outdated
|
||
To get a stations, you can call the client method: | ||
```ruby | ||
data = client.get_station('5ed2118acca8ce0001f1aeg1') # => OpenWeather::Models::Station |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: because you're not using data
, just remove it, so client.get ...
, more below like this
README.md
Outdated
``` | ||
Alternatively, call `update!` on an instance of `Station`: | ||
```ruby | ||
model = OpenWeather::Models::Station.new(external_id: 'SF_TEST001', ...).register! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put model.register!
on its own line.
end | ||
|
||
def update_station(id, options = {}) | ||
OpenWeather::Models::Station.new(put("stations/#{id}", options)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a parameter is missing, raise ArgumentError, generally I don't specialize errors unless they can happen on all APIs (e.g. incorrect HTTP proxy)
|
||
def delete_station(id) | ||
delete("stations/#{id}") | ||
nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think nil
is fine.
@@ -42,4 +42,38 @@ | |||
) | |||
end | |||
end | |||
|
|||
describe '#get_station' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be context
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I’ve been following this convention http://www.betterspecs.org/#describe (describe for the method under test, context for a scenario)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been schooled ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They’re aliases so all good either way!
Merged, nice work! Want to help out with gem maintenance? Make the next release? Drop me an email with your rubygems username/email to dblock at dblock dot org. |
Pending a "delete!" method on Station.
Next step, add measurements.