Skip to content

Commit c479c55

Browse files
authored
Merge pull request #141 from rladies/pro fix #118 #112
rewrite PRO functions to query GraphQL
2 parents cd999d7 + 8acc117 commit c479c55

33 files changed

+931
-11345
lines changed

.Rbuildignore

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
^~/\.local/share/meetupr/meetupr-token\.rds$
1717
^codecov\.yml$
1818
^LICENSE\.md$
19+
^~/Library/Application Support/meetupr/meetupr-token\.rds$

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ vignettes/*.html
1010
docs
1111
tests/testthat/.meetup_token.rds
1212
~/.local/share/meetupr/meetupr-token.rds
13+
~/Library/Application Support/meetupr/meetupr-token.rds

DESCRIPTION

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Imports:
2929
purrr,
3030
gh,
3131
progress,
32-
tibble,
3332
rlang,
3433
rappdirs,
3534
glue,

NAMESPACE

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(find_groups)
4-
export(get_boards)
54
export(get_event_attendees)
65
export(get_event_comments)
76
export(get_event_rsvps)
87
export(get_events)
98
export(get_members)
9+
export(get_pro_events)
10+
export(get_pro_groups)
1011
export(meetup_auth)
1112
export(meetup_deauth)
1213
export(meetup_query)

R/find_groups.R

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
#' @param lat Latitude. An integer
77
#' @param lon Longitutde. An integer
88
#' @param radius Radius. An integer
9-
#' @param extra_graphql A graphql object. Extra objects to return
10-
#' @param token Meetup token
9+
#' @param ... Should be empty. Used for parameter expansion
10+
#' @template extra_graphql
11+
#' @template token
1112
#' @importFrom anytime anytime
1213
#' @export
1314
find_groups <- function(

R/get_boards.R

+41-41
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
#' Get the discussion boards from a meetup group
2-
#'
3-
#' @template urlname
4-
#' @template verbose
5-
#' @return A tibble with the following columns:
6-
#' * id
7-
#' * name
8-
#' * description
9-
#' * created
10-
#' * updated
11-
#' * post_count
12-
#' * discussion_count
13-
#' * latest_reply_created
14-
#' * latest_reply_member_name
15-
#' * resource
16-
#'
17-
#' @references
18-
#' \url{https://www.meetup.com/meetup_api/docs/:urlname/boards/}
19-
#'@examples
20-
#' \dontrun{
21-
#' urlname <- "rladies-nashville"
22-
#' meetup_boards <- get_boards(urlname = urlname)
23-
#'}
24-
#' @export
25-
get_boards <- function(urlname,
26-
verbose = meetupr_verbose()) {
27-
api_path <- paste0(urlname, "/boards")
28-
res <- .fetch_results(api_path = api_path, verbose = verbose)
29-
tibble::tibble(
30-
id = purrr::map_int(res, "id"),
31-
name = purrr::map_chr(res, "name"),
32-
description = purrr::map_chr(res, "description"),
33-
created = .date_helper(purrr::map_dbl(res, "created")),
34-
updated = .date_helper(purrr::map_dbl(res, "updated")),
35-
post_count = purrr::map_int(res, "post_count", .default = NA),
36-
discussion_count = purrr::map_int(res, "discussion_count", .default = NA),
37-
latest_reply_created = .date_helper(purrr::map_dbl(res, c("latest_reply", "created"), .default = NA)),
38-
latest_reply_member_name = purrr::map_chr(res, c("latest_reply", "member", "name"), .default = NA),
39-
resource = res
40-
)
41-
}
1+
#' #' Get the discussion boards from a meetup group
2+
#' #'
3+
#' #' @template urlname
4+
#' #' @template verbose
5+
#' #' @return A tibble with the following columns:
6+
#' #' * id
7+
#' #' * name
8+
#' #' * description
9+
#' #' * created
10+
#' #' * updated
11+
#' #' * post_count
12+
#' #' * discussion_count
13+
#' #' * latest_reply_created
14+
#' #' * latest_reply_member_name
15+
#' #' * resource
16+
#' #'
17+
#' #' @references
18+
#' #' \url{https://www.meetup.com/meetup_api/docs/:urlname/boards/}
19+
#' #'@examples
20+
#' #' \dontrun{
21+
#' #' urlname <- "rladies-nashville"
22+
#' #' meetup_boards <- get_boards(urlname = urlname)
23+
#' #'}
24+
#' #' @export
25+
#' get_boards <- function(urlname,
26+
#' verbose = meetupr_verbose()) {
27+
#' api_path <- paste0(urlname, "/boards")
28+
#' res <- .fetch_results(api_path = api_path, verbose = verbose)
29+
#' tibble::tibble(
30+
#' id = purrr::map_int(res, "id"),
31+
#' name = purrr::map_chr(res, "name"),
32+
#' description = purrr::map_chr(res, "description"),
33+
#' created = .date_helper(purrr::map_dbl(res, "created")),
34+
#' updated = .date_helper(purrr::map_dbl(res, "updated")),
35+
#' post_count = purrr::map_int(res, "post_count", .default = NA),
36+
#' discussion_count = purrr::map_int(res, "discussion_count", .default = NA),
37+
#' latest_reply_created = .date_helper(purrr::map_dbl(res, c("latest_reply", "created"), .default = NA)),
38+
#' latest_reply_member_name = purrr::map_chr(res, c("latest_reply", "member", "name"), .default = NA),
39+
#' resource = res
40+
#' )
41+
#' }

R/get_event_attendees.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#'
33
#' @param id Required event ID
44
#' @param ... Should be empty. Used for parameter expansion
5-
#' @param extra_graphql A graphql object. Extra objects to return
6-
#' @param token Meetup token
5+
#' @template extra_graphql
6+
#' @template token
77
#' @return A tibble with the following columns:
88
#' * id
99
#' * name

R/get_event_comments.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#' Get the comments for a specified event
22
#'
3-
#' @param id Required event ID
3+
#' @template id
44
#' @param ... Should be empty. Used for parameter expansion
5-
#' @param extra_graphql A graphql object. Extra objects to return
6-
#' @param token Meetup token
5+
#' @template extra_graphql
6+
#' @template token
77
#' @return A tibble with the following columns:
88
#' * id
99
#' * comment

R/get_events.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#' Get the events from a meetup group
22
#'
3-
#' @param urlname Required urlname of the Meetup group
3+
#' @template urlname
44
#' @param ... Should be empty. Used for parameter expansion
5-
#' @param extra_graphql A graphql object. Extra objects to return
6-
#' @param token Meetup token
5+
#' @template extra_graphql
6+
#' @template token
77
#' @export
88
get_events <- function(
99
urlname,

R/get_members.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#' Get the current meetup members from a meetup group
22
#'
3-
#' @param urlname Required urlname of the Meetup group
3+
#' @template urlname
44
#' @param ... Should be empty. Used for parameter expansion
5-
#' @param extra_graphql A graphql object. Extra objects to return
6-
#' @param token Meetup token
5+
#' @template extra_graphql
6+
#' @template token
77
#' @return A tibble with the following columns:
88
#' * id
99
#' * name

R/get_pro.R

+90-75
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,96 @@
1-
#' #' Meetup pro functions
2-
#' #'
3-
#' #' The pro functions only work if the querying users
4-
#' #' had a meetup pro account.
5-
#' #'
6-
#' #' \describe{
7-
#' #' \item{get_pro_groups}{Get the current meetup members from a pro meetup group}
8-
#' #' \item{get_pro_events}{Get pro group events for the enxt 30 days}
9-
#' #' }
10-
#' #'
11-
#' #' @template urlname
12-
#' #' @template verbose
13-
#' #'
14-
#' #' @references
15-
#' #' \url{https://www.meetup.com/meetup_api/docs/pro/:urlname/groups/}
16-
#' #' \url{https://www.meetup.com/meetup_api/docs/:urlname/events/#list}
17-
#' #'
18-
#' #' @examples
19-
#' #' \dontrun{
20-
#' #' urlname <- "rladies"
21-
#' #' members <- get_pro_groups(urlname)
22-
#' #'
23-
#' #' past_events <- get_events(urlname = urlname,
24-
#' #' event_status = "past")
25-
#' #' upcoming_events <- get_events(urlname = urlname,
26-
#' #' event_status = "upcoming")
27-
#' #'}
28-
#' #'
29-
#' #' @return A tibble with meetup information
1+
#' Meetup pro functions
302
#'
3+
#' The pro functions only work if the querying users
4+
#' had a meetup pro account.
315
#'
32-
#' #' @rdname meetup_pro
33-
#' #' @export
34-
#' #' @importFrom purrr map_int map_chr map_dbl
35-
#' #' @importFrom tibble tibble
36-
#' get_pro_groups <- function(
37-
#' urlname,
38-
#' ...,
39-
#' extra_graphql = NULL,
40-
#' token = meetup_token()
41-
#' ) {
42-
#' ellipsis::check_dots_empty()
6+
#' @template urlname
7+
#' @param ... Should be empty. Used for parameter expansion
8+
#' @template extra_graphql
9+
#' @template token
10+
#' @param status Which status the events should have.
4311
#'
44-
#' dt <- gql_events(
45-
#' urlname = urlname,
46-
#' .extra_graphql = extra_graphql,
47-
#' .token = token
48-
#' )
12+
#' @references
13+
#' \url{https://www.meetup.com/api/schema/#ProNetwork}
4914
#'
50-
#' tibble(
51-
#' group_sorter(res),
52-
#' created = .date_helper(map_dbl(res, "founded_date")),
53-
#' members = map_chr(res, "member_count"),
54-
#' upcoming_events = map_int(res, "upcoming_events"),
55-
#' past_events = map_int(res, "past_events"),
56-
#' res = res
57-
#' )
58-
#' }
59-
#'
60-
#'
61-
#' #' @rdname meetup_pro
62-
#' #' @importFrom tibble tibble
63-
#' #' @export
64-
#' get_pro_events <- function(urlname,
65-
#' verbose = meetupr_verbose()
66-
#' ){
67-
#'
68-
#' api_path <- sprintf("pro/%s/events", urlname)
69-
#' res <- .fetch_results(api_path = api_path, verbose = verbose)
70-
#'
71-
#' group <- lapply(res, function(x) x[["chapter"]])
72-
#' group <- tibble(group_sorter(group), res = group)
73-
#' names(group) <- paste0("group_", names(group))
74-
#'
75-
#' events <- lapply(res, function(x) x[[1]])
15+
#' @examples
16+
#' \dontrun{
17+
#' urlname <- "rladies"
18+
#' members <- get_pro_groups(urlname)
7619
#'
77-
#' tibble(
78-
#' event_sorter(events),
79-
#' group
80-
#' )
20+
#' past_events <- get_pro_events(urlname = urlname,
21+
#' status = "PAST")
22+
#' upcoming_events <- get_pro_events(urlname = urlname,
23+
#' status = "UPCOMING")
24+
#' all_events <- get_pro_events(urlname = urlname)
8125
#' }
26+
#' @name meetup_pro
27+
#' @return A tibble with meetup pro information
28+
NULL
29+
30+
#' Get pro groups information
31+
#' @export
32+
#' @describeIn meetup_pro retrieve groups in a pro network
33+
get_pro_groups <- function(
34+
urlname,
35+
...,
36+
extra_graphql = NULL,
37+
token = meetup_token()
38+
) {
39+
ellipsis::check_dots_empty()
40+
41+
dt <- gql_get_pro_groups(
42+
urlname = urlname,
43+
.extra_graphql = extra_graphql,
44+
.token = token
45+
)
46+
dt <- rename(dt,
47+
created = foundedDate,
48+
members = memberships.count,
49+
join_mode = joinMode,
50+
category_id = category.id,
51+
category_name = category.name,
52+
country = country_name,
53+
past_events_count = pastEvents.count,
54+
upcoming_events_count = upcomingEvents.count,
55+
membership_status = membershipMetadata.status,
56+
is_private = isPrivate
57+
58+
)
59+
60+
dt$created <- anytime::anytime(dt$created)
61+
dt
62+
}
63+
64+
#' Get pro events information
65+
#' @export
66+
#' @describeIn meetup_pro retrieve events from a pro network
67+
get_pro_events <- function(
68+
urlname,
69+
status = NULL,
70+
...,
71+
extra_graphql = NULL,
72+
token = meetup_token()
73+
) {
74+
ellipsis::check_dots_empty()
75+
76+
dt <- gql_get_pro_events(
77+
urlname = urlname,
78+
status = status,
79+
.extra_graphql = extra_graphql,
80+
.token = token
81+
)
82+
if(nrow(dt) == 0) return(NULL)
83+
84+
# replace dot with underscore
85+
names(dt) <- gsub("\\.", "_", names(dt))
86+
87+
dt <- rename(dt,
88+
link = eventUrl,
89+
event_type = eventType,
90+
venue_zip = venue_postalCode
91+
)
92+
dt$time <- anytime::anytime(dt$dateTime)
93+
94+
remove(dt,
95+
dateTime)
96+
}

0 commit comments

Comments
 (0)