Created
March 28, 2014 02:36
-
-
Save trevordixon/9824042 to your computer and use it in GitHub Desktop.
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
ruleset foursquare_checkins { | |
meta { | |
name "Foursquare Checkins" | |
description << | |
Foursquare Checkins | |
>> | |
author "" | |
logging off | |
use module a169x701 alias CloudRain | |
use module a41x186 alias SquareTag | |
} | |
dispatch { | |
} | |
global { | |
subscription_maps = [ | |
{"cid":"E54CD51E-B5E9-11E3-AA95-ED47293232C8"}, | |
{"cid":"99B7B68C-B620-11E3-A744-EAA3E71C24E1"} | |
]; | |
} | |
rule pass_fs_checkin { | |
select when foursquare checkin | |
foreach subscription_maps setting (subscription_map) | |
event:send(subscription_map, "location", "notification") | |
with attrs = {"checkin": event:attr("checkin")}; | |
} | |
rule display_checkin is active { | |
select when web cloudAppSelected | |
pre { | |
venue = ent:venue; | |
city = ent:city; | |
shout = ent:shout; | |
createdAt = ent:createdAt; | |
my_html = << | |
<ul> | |
<li><strong>Venue</strong>: #{venue}</li> | |
<li><strong>City</strong>: #{city}</li> | |
<li><strong>Shout</strong>: #{shout}</li> | |
<li><strong>Created</strong>: #{createdAt}</li> | |
</ul> | |
>>; | |
} | |
{ | |
SquareTag:inject_styling(); | |
CloudRain:createLoadPanel("Latest Foursquare Checkin", {}, my_html); | |
} | |
} | |
rule process_fs_checkin { | |
select when foursquare checkin | |
pre { | |
checkin = event:attr("checkin").decode(); | |
venue = checkin.pick("$..venue.name"); | |
lat = checkin.pick("$..location.lat"); | |
lng = checkin.pick("$..location.lng"); | |
city = checkin.pick("$..location.city"); | |
shout = checkin.pick("$..shout", true).head(); | |
createdAt = checkin.pick("$..createdAt"); | |
} | |
send_directive(venue) | |
with checkin = venue; | |
fired { | |
set ent:venue venue; | |
set ent:lat lat; | |
set ent:lng lng; | |
set ent:city city; | |
set ent:shout shout; | |
set ent:createdAt createdAt; | |
raise pds event new_location_data with | |
key = "fs_checkin" and | |
value = { | |
"venue": venue, | |
"lat": lat, | |
"lng": lng, | |
"city": city, | |
"shout": shout, | |
"createdAt": createdAt | |
} | |
} | |
} | |
} |
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
ruleset location_catch { | |
rule location_catch { | |
select when location notification | |
always { | |
set ent:checkin event:attr("checkin").decode(); | |
} | |
} | |
rule location_show { | |
select when web cloudAppSelected | |
pre { | |
checkin = ent:checkin; | |
venue = checkin.pick("$..venue.name"); | |
lat = checkin.pick("$..location.lat"); | |
lng = checkin.pick("$..location.lng"); | |
city = checkin.pick("$..location.city"); | |
shout = checkin.pick("$..shout", true).head(); | |
} | |
notify("Last Checkin", "#{venue} in #{city}. Said #{shout}."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment