-
Notifications
You must be signed in to change notification settings - Fork 9
/
search_resource.R
107 lines (99 loc) · 3.06 KB
/
search_resource.R
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#' Search Trello
#'
#' Search for resources.
#'
#' Search can be narrowed down by resource type and will return a single data
#' frame per each type (if anything is found). The value of the `resource`
#' argument is passed on `modelTypes` - see other attributes
#' at [search API reference](https://developer.atlassian.com/cloud/trello/rest/#api-search-get).
#'
#' @param string Text to search for.
#' @param resource Type of resource to return; typically `"cards"`. Defaults to
#' `"all"`.
#' @param boards Boards to limit the search to - defaults to `"mine"`.
#' @param partial Should partial matching be used? Defaults to `FALSE`.
#' @param query Name list of additional query parameters; consult [search API reference](https://developer.atlassian.com/cloud/trello/rest/#api-search-get)
#' @param ... Additional arguments passed to [get_resource()].
#' @param modeltype Deprecated, use `resource` instead.
#'
#' @seealso [get_resource()], [get_token()]
#'
#' @return A data frame.
#'
#' @name search_resource
#' @examples
#'
#' \dontrun{
#'
#' search_resource("Anything with this text")
#' search_cards("A card with this text")
#'
#' }
NULL
#' @export
#' @rdname search_resource
search_resource = function(string, resource = "all", boards = "mine",
partial = FALSE, query = list(), modeltype, ...) {
if (!missing(modeltype)) {
message("`modeltype` is deprecated. Use `resource` instead.")
resource = modeltype
}
get_resource(
parent = "search",
query = c(
list(
query = string,
modelTypes = paste(resource, collapse = ","),
idBoards = paste(boards, collapse = ","),
partial = tolower(partial)
),
query
),
...
)
}
#' @export
#' @rdname search_resource
search_cards = function(string, boards = "mine", partial = FALSE,
query = list(), ...) {
search_resource(
string = string, resource = "cards", boards = boards,
partial = partial, query = query, ...
)
}
#' @export
#' @rdname search_resource
search_actions = function(string, boards = "mine", partial = FALSE,
query = list(), ...) {
search_resource(
string = string, resource = "actions", boards = boards,
partial = partial, query = query, ...
)
}
#' @export
#' @rdname search_resource
search_boards = function(string, boards = "mine", partial = FALSE,
query = list(), ...) {
search_resource(
string = string, resource = "boards", boards = boards,
partial = partial, query = query, ...
)
}
#' @export
#' @rdname search_resource
search_members = function(string, boards = "mine", partial = FALSE,
query = list(), ...) {
search_resource(
string = string, resource = "members", boards = boards,
partial = partial, query = query, ...
)
}
#' @export
#' @rdname search_resource
search_teams = function(string, boards = "mine", partial = FALSE,
query = list(), ...) {
search_resource(
string = string, resource = "organizations", boards = boards,
partial = partial, query = query, ...
)
}