Skip to content

Instantly share code, notes, and snippets.

@jordanrobinson
Last active March 21, 2018 22:00
Show Gist options
  • Select an option

  • Save jordanrobinson/d5383dde0b9c1be1fd0f9ac409965eb3 to your computer and use it in GitHub Desktop.

Select an option

Save jordanrobinson/d5383dde0b9c1be1fd0f9ac409965eb3 to your computer and use it in GitHub Desktop.
Some clj files for the blog post
((if (= updated (read-updated-date user))
(log-output user)
(write-update user schedule))
(defn read-updated-date
"reads in the last updated details from the filesystem for comparison"
[user]
(if (.exists (io/as-file (str user ".clj")))
(let [updated-date (get (read-string (slurp (str user ".clj"))) :updated_at)]
(get (clojure.string/split updated-date #":") 0))))
(defn hit-api
"calls our api, parses it and returns the result"
[endpoint username password]
(parse-string
(get
(client/get (str endpoint)
{:basic-auth [username password]})
:body)
true))
(defn send-slack-message
"sends a slack message detailing the changes to that endpoint"
[username body slackurl]
(println (str "sending message to " username "..."))
(client/post slackurl
{:form-params {:payload (json/write-str {:text body :channel (str "@" username)})}}))
(defn write-update
"writes out the latest details to file for later checking"
[user slackuser message]
(spit (str user ".clj") (prn-str data))
(println (str "updated user " user " at " (now)))
(send-slack-message slackuser message))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment