-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(REST): add
vallisCycle
route. (#61)
* feat(REST): add `vallisCycle` route. * ci(rspec): use `head` for latest ruby version
- Loading branch information
Showing
7 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative './base' | ||
require_relative './attributes/id' | ||
require_relative './attributes/active' | ||
require_relative './attributes/expiry' | ||
|
||
module Warframe | ||
module Models | ||
# Model for VallisCycle data. | ||
# {https://api.warframestat.us/pc/vallisCycle /:platform/vallisCycle} | ||
class VallisCycle < Warframe::Models::Base | ||
include Warframe::Models::Attributes::ID | ||
include Warframe::Models::Attributes::Expiry | ||
include Warframe::Models::Attributes::Activation | ||
|
||
# @!attribute time_left | ||
# @return [String] time left until next cycle. | ||
attr_reader :time_left | ||
|
||
# @!attribute is_warm? | ||
# @return [Boolean] whether or not it currently is warm. | ||
attr_reader :is_warm | ||
alias is_warm? is_warm | ||
|
||
# @!attribute state | ||
# @return [String] the current world state (Cold or Warm) | ||
attr_reader :state | ||
|
||
# @!attribute short_string | ||
# @return [String] the time remaining until state change. Ex: `5m to Warm`. | ||
attr_reader :short_string | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'warframe/models/vallis_cycle' | ||
require_relative '../utils' | ||
|
||
module Warframe | ||
module REST | ||
module API | ||
# API endpoint for getting information on current VallisCycle data. | ||
# | ||
# {https://api.warframestat.us/pc/vallisCycle Example Response} | ||
module VallisCycle | ||
include Warframe::REST::Utils | ||
|
||
# Gets the current vallisCycle Data. | ||
# @return [Warframe::Models::VallisCycle] | ||
def vallis_cycle | ||
get('/vallisCycle', Warframe::Models::VallisCycle) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"id": "vallisCycle1641060420000", | ||
"expiry": "2022-01-01T18:27:08.000Z", | ||
"isWarm": false, | ||
"state": "cold", | ||
"activation": "2022-01-01T18:07:00.000Z", | ||
"timeLeft": "5m 32s", | ||
"shortString": "5m to Warm" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Warframe::Models::VallisCycle do | ||
let(:json) { load_json_file 'vallis_cycle' } | ||
|
||
it 'can be instantiated from JSON' do | ||
expect { Warframe::Models::VallisCycle.new(json) }.to_not raise_error | ||
end | ||
|
||
let(:cycle) { Warframe::Models::VallisCycle.new(json) } | ||
|
||
it 'can read VallisCycle data' do | ||
expect(cycle.state).to eq 'cold' | ||
expect(cycle.is_warm?).to eq false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters