Class: Agents::LiveTennisAgent
- Inherits:
-
Agent
- Object
- Agent
- Agents::LiveTennisAgent
- Defined in:
- lib/huginn_live_tennis_agent/live_tennis_agent.rb
Constant Summary collapse
- API_BASE =
'https://api.livetennisapi.com/api/public/v1'- MODES =
%w[live_scores fixtures].freeze
- TOURS =
%w[atp wta challenger itf juniors].freeze
Instance Method Summary collapse
Instance Method Details
#check ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/huginn_live_tennis_agent/live_tennis_agent.rb', line 142 def check if interpolated['mode'] == 'fixtures' check_fixtures else check_live_scores end end |
#default_options ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/huginn_live_tennis_agent/live_tennis_agent.rb', line 113 def { 'api_key' => '{% credential live_tennis_api_key %}', 'mode' => 'live_scores', 'tour' => '', 'lookup_finished' => 'true' } end |
#validate_options ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/huginn_live_tennis_agent/live_tennis_agent.rb', line 122 def errors.add(:base, 'api_key is required') unless ['api_key'].present? unless MODES.include?(['mode']) errors.add(:base, "mode must be one of: #{MODES.join(', ')}") end if ['tour'].present? && !TOURS.include?(['tour']) errors.add(:base, "tour must be one of: #{TOURS.join(', ')} (or blank for all tours)") end if ['lookup_finished'].present? && boolify(['lookup_finished']).nil? errors.add(:base, 'lookup_finished must be true or false') end end |
#working? ⇒ Boolean
138 139 140 |
# File 'lib/huginn_live_tennis_agent/live_tennis_agent.rb', line 138 def working? !recent_error_logs? end |