Module: Bandshell::HardwareApi
- Defined in:
- lib/bandshell/hardware_api.rb
Class Attribute Summary collapse
-
.screen_id ⇒ Object
readonly
Returns the value of attribute screen_id.
-
.screen_url ⇒ Object
readonly
Returns the value of attribute screen_url.
Class Method Summary collapse
- .attempt_to_get_screen_data! ⇒ Object
- .auth_token ⇒ Object
- .concerto_url ⇒ Object
- .frontend_api_uri ⇒ Object
- .frontend_uri ⇒ Object
-
.get_player_info ⇒ Object
Fetch player settings from concerto-hardware TODO: clean up errors/ return values.
- .have_auth_token? ⇒ Boolean
- .have_temp_token? ⇒ Boolean
- .temp_token ⇒ Object
Class Attribute Details
.screen_id ⇒ Object (readonly)
Returns the value of attribute screen_id.
36 37 38 |
# File 'lib/bandshell/hardware_api.rb', line 36 def screen_id @screen_id end |
.screen_url ⇒ Object (readonly)
Returns the value of attribute screen_url.
36 37 38 |
# File 'lib/bandshell/hardware_api.rb', line 36 def screen_url @screen_url end |
Class Method Details
.attempt_to_get_screen_data! ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bandshell/hardware_api.rb', line 38 def attempt_to_get_screen_data! unless have_temp_token? or have_auth_token? request_temp_token! end unless have_auth_token? check_temp_token! end if have_auth_token? status = fetch_screen_data if status == :stat_badauth ConfigStore.write_config('auth_token','') request_temp_token! end else status = :stat_err end status end |
.auth_token ⇒ Object
12 13 14 |
# File 'lib/bandshell/hardware_api.rb', line 12 def auth_token Bandshell::ConfigStore.read_config('auth_token') end |
.concerto_url ⇒ Object
16 17 18 |
# File 'lib/bandshell/hardware_api.rb', line 16 def concerto_url Bandshell::ConfigStore.read_config('concerto_url', '') end |
.frontend_api_uri ⇒ Object
24 25 26 |
# File 'lib/bandshell/hardware_api.rb', line 24 def frontend_api_uri URI::join(concerto_url,'frontend.json') end |
.frontend_uri ⇒ Object
20 21 22 |
# File 'lib/bandshell/hardware_api.rb', line 20 def frontend_uri URI::join(concerto_url,'frontend') end |
.get_player_info ⇒ Object
Fetch player settings from concerto-hardware TODO: clean up errors/ return values
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/bandshell/hardware_api.rb', line 149 def get_player_info return nil if auth_token.empty? # Try to do this in one GET. player_info_uri = URI::join(concerto_url,'hardware/', 'players/','current.json') response = get_with_auth(player_info_uri, 'screen', auth_token) if response.nil? return :stat_serverr end if response.code != "200" return :stat_serverr end begin data = JSON.parse(response.body) if data.has_key? 'screen_on_off' # We actually got some data return data else return :stat_badauth end rescue return :stat_serverr end end |
.have_auth_token? ⇒ Boolean
32 33 34 |
# File 'lib/bandshell/hardware_api.rb', line 32 def have_auth_token? !auth_token.empty? end |
.have_temp_token? ⇒ Boolean
28 29 30 |
# File 'lib/bandshell/hardware_api.rb', line 28 def have_temp_token? !temp_token.empty? end |
.temp_token ⇒ Object
8 9 10 |
# File 'lib/bandshell/hardware_api.rb', line 8 def temp_token Bandshell::ConfigStore.read_config('auth_temp_token') end |