Basic infrastructure for elevators
This commit is contained in:
parent
4fd6a5ee25
commit
ed15a2a5a7
@ -20,7 +20,11 @@ export class Subscription {
|
||||
this.handleError.bind(this));
|
||||
*/
|
||||
|
||||
api.bind('/bartstations', 'PUT', api.authTokens.ship, 'bartinfo',
|
||||
api.bind("/elevators", "PUT", api.authTokens.ship, "bartinfo",
|
||||
this.handleEvent.bind(this),
|
||||
this.handleError.bind(this));
|
||||
|
||||
api.bind("/bartstations", "PUT", api.authTokens.ship, 'bartinfo',
|
||||
this.handleEvent.bind(this),
|
||||
this.handleError.bind(this));
|
||||
|
||||
|
@ -79,6 +79,12 @@
|
||||
=/ req bart-api-request-stations:cc
|
||||
[%pass /bartstationrequest %arvo %i %request req out]
|
||||
[~[bart-station-request] this]
|
||||
?: ?=([%elevators *] path)
|
||||
=/ elevator-status-request
|
||||
=/ out *outbound-config:iris
|
||||
=/ req bart-api-elevator-status:cc
|
||||
[%pass /elevators %arvo %i %request req out]
|
||||
[~[elevator-status-request] this]
|
||||
?: ?=([%http-response *] path)
|
||||
`this
|
||||
?. =(/ path)
|
||||
@ -99,6 +105,12 @@
|
||||
?> ?=(%o -.value)
|
||||
=/ update=json (pairs:enjs:format [update+o+p.value ~])
|
||||
[%give %fact ~[/bartstations] %json !>(update)]~
|
||||
::
|
||||
[%elevators *]
|
||||
=/ value=json (parse-elevator-status-response:cc client-response.sign-arvo)
|
||||
?> ?=(%o -.value)
|
||||
=/ update=json (pairs:enjs:format [update+o+p.value ~])
|
||||
[%give %fact ~[/elevators] %json !>(update)]~
|
||||
==
|
||||
[http-moves this]
|
||||
?. ?=(%bound +<.sign-arvo)
|
||||
@ -154,6 +166,17 @@
|
||||
(pairs:enjs [name+s+p.name abbr+s+p.abbr ~])
|
||||
(pairs:enjs [[%stations %a abbr-and-name] ~])
|
||||
::
|
||||
++ bart-api-elevator-status
|
||||
^- request:http
|
||||
=/ url (crip "{bart-api-url-base}/stn.aspx?cmd=stns&key={bart-api-key}&json=y")
|
||||
=/ headers [['Accept' 'application/json']]~
|
||||
[%'GET' url headers *(unit octs)]
|
||||
++ parse-elevator-status-response
|
||||
|= response=client-response:iris
|
||||
^- json
|
||||
=, format
|
||||
(pairs:enjs [[%yolo %b %.y] ~])
|
||||
::
|
||||
++ poke-handle-http-request
|
||||
|= =inbound-request:eyre
|
||||
^- simple-payload:http
|
||||
|
Loading…
Reference in New Issue
Block a user