-
Notifications
You must be signed in to change notification settings - Fork 36
/
search.clj
50 lines (47 loc) · 1.64 KB
/
search.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(ns clj-slack.search
(:require [clj-slack.core :refer [slack-request stringify-keys]]))
(defn all
"Searches for messages and files matching a query.
Optional arguments are:
- sort: return matches sorted by either score or timestamp
- sort_dir: change sort direction
- highlight: enable query highlight markers
- count: number of items to return per page
- page: page number of results to return"
([connection query]
(all connection query {}))
([connection query optionals]
(->> optionals
stringify-keys
(merge {"query" query})
(slack-request connection "search.all"))))
(defn files
"Searches for files matching a query.
Optional arguments are:
- sort: return matches sorted by either score or timestamp
- sort_dir: change sort direction
- highlight: enable query highlight markers
- count: number of items to return per page
- page: page number of results to return"
([connection query]
(files connection query {}))
([connection query optionals]
(->> optionals
stringify-keys
(merge {"query" query})
(slack-request connection "search.files"))))
(defn messages
"Searches for messages matching a query.
Optional arguments are:
- sort: return matches sorted by either score or timestamp
- sort_dir: change sort direction
- highlight: enable query highlight markers
- count: number of items to return per page
- page: page number of results to return"
([connection query]
(messages connection query {}))
([connection query optionals]
(->> optionals
stringify-keys
(merge {"query" query})
(slack-request connection "search.messages"))))