-
Notifications
You must be signed in to change notification settings - Fork 4
/
freethefiles.R
126 lines (122 loc) · 2.77 KB
/
freethefiles.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#' Retrieve market or markets
#'
#' Retrieve available markets, or a specific market
#' @rdname market
#'
#' @family freethefiles
#'
#' @param slug An optional character string containing a "slug" referring to
#' a media market.
#'
#' @inheritDotParams ppQuery -op -baseurl
#' @inheritDotParams httr::GET -url
#'
#' @author Thomas J. Leeper
#' @return The result of the query, typically a list object.
#' @export
#' @examples
#' \dontrun{
#'
#' market("new-york")
#' }
#'
market <- function(slug = NULL, ...) {
if (is.null(slug)) {
out <- ppQuery("markets", baseurl = "https://projects.propublica.org/free-the-files/", ...)
} else {
out <- ppQuery(paste("markets", slug, sep = "/"),
baseurl = "https://projects.propublica.org/free-the-files/", ...
)
}
return(out)
}
#' Retrieve station
#'
#' Retrieve station
#'
#' @rdname station
#' @family freethefiles
#'
#' @param callsign A character string containing a station callsign.
#'
#' @inheritDotParams ppQuery -op -baseurl
#' @inheritDotParams httr::GET -url
#'
#' @author Thomas J. Leeper
#' @return The result of the query, typically a list object.
#' @export
#' @examples
#' \dontrun{
#' station("WEWS-TV")
#' }
#'
station <- function(callsign, ...) {
out <- ppQuery(paste("stations", callsign, sep = "/"),
baseurl = "https://projects.propublica.org/free-the-files/",
...
)
return(out)
}
#' Retrieve committees or committee
#'
#' Retrieve available committees, or a specific committee
#'
#' @rdname committees
#' @family freethefiles
#'
#' @param slug An optional character string containing a "slug" referring to
#' a political committee.
#'
#' @inheritDotParams ppQuery -op -baseurl
#' @inheritDotParams httr::GET -url
#'
#' @author Thomas J. Leeper
#' @return The result of the query, typically a list object.
#' @export
#'
#' @examples
#' \dontrun{
#'
#' committee("warren-for-senate-2012")
#' }
#'
committee <- function(slug = NULL, ...) {
if (is.null(slug)) {
out <- ppQuery("committees",
baseurl = "https://projects.propublica.org/free-the-files/", ...
)
} else {
out <- ppQuery(paste("committees", slug, sep = "/"),
baseurl = "https://projects.propublica.org/free-the-files/", ...
)
}
return(out)
}
#' Retrieve filing
#'
#' Retrieve a specific filing, by ID
#'
#' @rdname filing
#' @family freethefiles
#'
#' @param id A character string containing a filing identification number.
#'
#' @inheritDotParams ppQuery -op -baseurl
#' @inheritDotParams httr::GET -url
#'
#' @author Thomas J. Leeper
#' @return The result of the query, typically a list object.
#' @export
#'
#' @examples
#' \dontrun{
#'
#' filing(51212)
#' }
#'
filing <- function(id, ...) {
out <- ppQuery(paste("filings", id, sep = "/"),
baseurl = "https://projects.propublica.org/free-the-files/", ...
)
return(out[[1]])
}