From 09c1778875a7c3d0e5e6d69a1828cd94b2a5431c Mon Sep 17 00:00:00 2001 From: hrbrmstr Date: Tue, 3 Dec 2019 12:24:12 -0500 Subject: [PATCH] enterprise stuff --- DESCRIPTION | 6 +++--- NAMESPACE | 2 ++ R/feedly-enterprise-profile.R | 38 ++++++++++++++++++++++++++++++++++++++ R/feedly-refresh-token.R | 29 +++++++++++++++++++++++++++++ README.Rmd | 4 +++- README.md | 17 +++++++++-------- man/feedly_collections.Rd | 3 +-- man/feedly_enterprise_profile.Rd | 17 +++++++++++++++++ man/feedly_feed_meta.Rd | 2 +- man/feedly_opml.Rd | 3 +-- man/feedly_refresh_token.Rd | 17 +++++++++++++++++ man/feedly_search_contents.Rd | 15 +++++++++++---- man/feedly_search_title.Rd | 12 ++++++++---- man/feedly_stream.Rd | 11 ++++++++--- man/feedly_subscribe.Rd | 9 +++++++-- man/global_resource_ids.Rd | 34 +++++++++++++++++----------------- man/render_stream.Rd | 9 +++++++-- man/seymour.Rd | 3 +-- 18 files changed, 180 insertions(+), 51 deletions(-) create mode 100644 R/feedly-enterprise-profile.R create mode 100644 R/feedly-refresh-token.R create mode 100644 man/feedly_enterprise_profile.Rd create mode 100644 man/feedly_refresh_token.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 7a85eac..d0c2969 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: seymour Type: Package Title: Tools to Work with the 'Feedly' 'API' -Version: 0.2.0 -Date: 2010-01-29 +Version: 0.2.5 +Date: 2019-12-03 Authors@R: c( person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5670-2640")) @@ -32,4 +32,4 @@ Imports: utils, jsonlite, magrittr -RoxygenNote: 6.1.1 +RoxygenNote: 7.0.1 diff --git a/NAMESPACE b/NAMESPACE index f5d86f6..d4a14de 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,9 +5,11 @@ export(feedly_access_token) export(feedly_categories) export(feedly_collections) export(feedly_continue) +export(feedly_enterprise_profile) export(feedly_feed_meta) export(feedly_opml) export(feedly_profile) +export(feedly_refresh_token) export(feedly_search_contents) export(feedly_search_title) export(feedly_stream) diff --git a/R/feedly-enterprise-profile.R b/R/feedly-enterprise-profile.R new file mode 100644 index 0000000..6da79cc --- /dev/null +++ b/R/feedly-enterprise-profile.R @@ -0,0 +1,38 @@ +#' Retrieve Your Feedly Enterprise Profile +#' +#' @md +#' @param feedly_token Your Feedly Developer Access Token (see [feedly_access_token()]) +#' @references () +#' @export +feedly_enterprise_profile <- function(feedly_token = feedly_access_token()) { + + httr::GET( + .seymour_ua, + url = "https://cloud.feedly.com/v3/profile", + httr::add_headers( + `Authorization` = sprintf("OAuth %s", feedly_token) + ) + ) -> res + + httr::stop_for_status(res) + + out <- httr::content(res, as="text") + + out <- jsonlite::fromJSON(out) + + ln <- names(out) + + if ("productExpiration" %in% ln) + out$productExpiration <- as.POSIXct(out$productExpiration/1000, origin = "1970-01-01") + if ("subscriptionRenewalDate" %in% ln) + out$subscriptionRenewalDate <- as.POSIXct(out$subscriptionRenewalDate/1000, origin = "1970-01-01") + if ("upgradeDate" %in% ln) + out$upgradeDate <- as.POSIXct(out$upgradeDate/1000, origin = "1970-01-01") + if ("lastChargeDate" %in% ln) + out$lastChargeDate <- as.POSIXct(out$lastChargeDate/1000, origin = "1970-01-01") + if ("nextChargeDate" %in% ln) + out$nextChargeDate <- as.POSIXct(out$nextChargeDate/1000, origin = "1970-01-01") + + out + +} diff --git a/R/feedly-refresh-token.R b/R/feedly-refresh-token.R new file mode 100644 index 0000000..1789076 --- /dev/null +++ b/R/feedly-refresh-token.R @@ -0,0 +1,29 @@ +#' Generate a Feedly Refresh Token +#' +#' Stick this into `FEEDLY_ACCESS_TOKEN` when obtained. +#' +#' @md +#' @param feedly_token Your Feedly Developer Access Token (see [feedly_access_token()]) +#' @references () +#' @export +feedly_refresh_token <- function(feedly_token = feedly_access_token()) { + + httr::POST( + seymour:::.seymour_ua, + url = "https://cloud.feedly.com/v3/auth/token", + httr::add_headers( + `Authorization` = sprintf("OAuth %s", seymour::feedly_access_token()) + ), + body = list( + refresh_token = Sys.getenv("FEEDLY_REFRESH_TOKEN"), + client_id = "feedlydev", + client_secret = "feedlydev", + grant_type = "refresh_token" + ) + ) -> res + + httr::stop_for_status(res) + + httr::content(res) + +} \ No newline at end of file diff --git a/README.Rmd b/README.Rmd index 791116e..cc5cfb5 100644 --- a/README.Rmd +++ b/README.Rmd @@ -25,9 +25,11 @@ The following API functions are implemented: - `feedly_access_token`: Retrieve the Feedly Developer Token - `feedly_collections`: Retrieve Feedly Connections - `feedly_categories`: Show Feedly Categories +- `feedly_enterprise_profile`: Retrieve Your Feedly Enterprise Profile - `feedly_feed_meta`: Retrieve Metadata for a Feed - `feedly_opml`: Retrieve Your Feedly OPML File - `feedly_profile`: Retrieve Your Feedly Profile +- `feedly_refresh_token`: Generate a Feedly Refresh Token - `feedly_search_contents`: Search content of a stream - `feedly_search_title`: Find feeds based on title, url or '#topic' - `feedly_stream`: Retrieve contents of a Feedly "stream" @@ -35,7 +37,7 @@ The following API functions are implemented: - `feedly_subscriptions`: Retrieve Feedly Subscriptions - `feedly_tags`: Retrieve List of Tags -The following helper functions are åvailable: +The following helper functions are available: - `feedly_continue`: Helper function to iterate through a `feedly_stream()` result set - `render_stream`: Render a Feedly Stream Data Frame to R Markdown diff --git a/README.md b/README.md index 0be4efe..98b3b0b 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,11 @@ The following API functions are implemented: - `feedly_access_token`: Retrieve the Feedly Developer Token - `feedly_collections`: Retrieve Feedly Connections - `feedly_categories`: Show Feedly Categories + - `feedly_enterprise_profile`: Retrieve Your Feedly Enterprise Profile - `feedly_feed_meta`: Retrieve Metadata for a Feed - `feedly_opml`: Retrieve Your Feedly OPML File - `feedly_profile`: Retrieve Your Feedly Profile + - `feedly_refresh_token`: Generate a Feedly Refresh Token - `feedly_search_contents`: Search content of a stream - `feedly_search_title`: Find feeds based on title, url or ‘\#topic’ - `feedly_stream`: Retrieve contents of a Feedly “stream” @@ -31,7 +33,7 @@ The following API functions are implemented: - `feedly_subscriptions`: Retrieve Feedly Subscriptions - `feedly_tags`: Retrieve List of Tags -The following helper functions are åvailable: +The following helper functions are available: - `feedly_continue`: Helper function to iterate through a `feedly_stream()` result set @@ -53,8 +55,8 @@ sufficient demand via Git\[la|hu\]b issues & issue votes. Neither `feedly_search_title()` nor `feedly_stream()` require authentication (i.e. you do not need a developer token) to retrieve the contents of the API call. For `feedly_stream()` You *do* need to know -the Feedly-structured feed id which is (generally) `feed/FEED_URL` (e.g. -`feed/http://feeds.feedburner.com/RBloggers`). +the Feedly-structured feed id which is (generally) `feed/FEED_URL` +(e.g. `feed/http://feeds.feedburner.com/RBloggers`). ## Installation @@ -72,7 +74,7 @@ library(tidyverse) # mostly for printing packageVersion("seymour") ``` - ## [1] '0.2.0' + ## [1] '0.2.5' ### Collections @@ -315,8 +317,7 @@ render_stream( Click on the following to see the complete render or view the [Rmd](https://rud.is/seymour/sample-report.Rmd) or -[HTML](https://rud.is/seymour/sample-report.html) in your -browser: +[HTML](https://rud.is/seymour/sample-report.html) in your browser:
@@ -332,8 +333,8 @@ cloc::cloc_pkg_md() | Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) | | :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: | -| R | 22 | 0.96 | 447 | 0.92 | 172 | 0.77 | 389 | 0.83 | -| Rmd | 1 | 0.04 | 40 | 0.08 | 52 | 0.23 | 82 | 0.17 | +| R | 24 | 0.96 | 488 | 0.92 | 184 | 0.78 | 404 | 0.83 | +| Rmd | 1 | 0.04 | 40 | 0.08 | 52 | 0.22 | 84 | 0.17 | ## Code of Conduct diff --git a/man/feedly_collections.Rd b/man/feedly_collections.Rd index 9f2150d..4cc2f7e 100644 --- a/man/feedly_collections.Rd +++ b/man/feedly_collections.Rd @@ -4,8 +4,7 @@ \alias{feedly_collections} \title{Retrieve Feedly Connections} \usage{ -feedly_collections(with_stats = FALSE, - feedly_token = feedly_access_token()) +feedly_collections(with_stats = FALSE, feedly_token = feedly_access_token()) } \arguments{ \item{with_stats}{if \code{TRUE}, return reading and tag stats for the past 31 days (default: \code{FALSE})} diff --git a/man/feedly_enterprise_profile.Rd b/man/feedly_enterprise_profile.Rd new file mode 100644 index 0000000..3bc0ef7 --- /dev/null +++ b/man/feedly_enterprise_profile.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/feedly-enterprise-profile.R +\name{feedly_enterprise_profile} +\alias{feedly_enterprise_profile} +\title{Retrieve Your Feedly Enterprise Profile} +\usage{ +feedly_enterprise_profile(feedly_token = feedly_access_token()) +} +\arguments{ +\item{feedly_token}{Your Feedly Developer Access Token (see \code{\link[=feedly_access_token]{feedly_access_token()}})} +} +\description{ +Retrieve Your Feedly Enterprise Profile +} +\references{ +(\url{https://developer.feedly.com/v3/opml/}) +} diff --git a/man/feedly_feed_meta.Rd b/man/feedly_feed_meta.Rd index b95462c..8b2ff29 100644 --- a/man/feedly_feed_meta.Rd +++ b/man/feedly_feed_meta.Rd @@ -7,7 +7,7 @@ feedly_feed_meta(feed, feedly_token = feedly_access_token()) } \arguments{ -\item{feed}{an RSS feed URL. \code{feed/} will be prepended if not present.} +\item{feed}{an RSS feed URL. \verb{feed/} will be prepended if not present.} \item{feedly_token}{Your Feedly Developer Access Token (see \code{\link[=feedly_access_token]{feedly_access_token()}})} } diff --git a/man/feedly_opml.Rd b/man/feedly_opml.Rd index 3c641b9..95e7be1 100644 --- a/man/feedly_opml.Rd +++ b/man/feedly_opml.Rd @@ -4,8 +4,7 @@ \alias{feedly_opml} \title{Retrieve Your Feedly OPML File} \usage{ -feedly_opml(as = c("text", "parsed"), - feedly_token = feedly_access_token()) +feedly_opml(as = c("text", "parsed"), feedly_token = feedly_access_token()) } \arguments{ \item{as}{one of "\code{text}" (plain character XML) or "\code{parsed}" (which will return diff --git a/man/feedly_refresh_token.Rd b/man/feedly_refresh_token.Rd new file mode 100644 index 0000000..e1c5da0 --- /dev/null +++ b/man/feedly_refresh_token.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/feedly-refresh-token.R +\name{feedly_refresh_token} +\alias{feedly_refresh_token} +\title{Generate a Feedly Refresh Token} +\usage{ +feedly_refresh_token(feedly_token = feedly_access_token()) +} +\arguments{ +\item{feedly_token}{Your Feedly Developer Access Token (see \code{\link[=feedly_access_token]{feedly_access_token()}})} +} +\description{ +Stick this into \code{FEEDLY_ACCESS_TOKEN} when obtained. +} +\references{ +(\url{https://developer.feedly.com/v3/auth/#refreshing-an-access-token}) +} diff --git a/man/feedly_search_contents.Rd b/man/feedly_search_contents.Rd index b1fa61d..07107c7 100644 --- a/man/feedly_search_contents.Rd +++ b/man/feedly_search_contents.Rd @@ -4,12 +4,19 @@ \alias{feedly_search_contents} \title{Search content of a stream} \usage{ -feedly_search_contents(query, stream_id = NULL, fields = "all", - embedded = NULL, engagement = NULL, count = 20L, locale = NULL, - feedly_token = feedly_access_token()) +feedly_search_contents( + query, + stream_id = NULL, + fields = "all", + embedded = NULL, + engagement = NULL, + count = 20L, + locale = NULL, + feedly_token = feedly_access_token() +) } \arguments{ -\item{query}{a full or partial title string, URL, or \code{#topic}} +\item{query}{a full or partial title string, URL, or \verb{#topic}} \item{stream_id}{the id of the stream; a feed id, category id, tag id or a system collection/category ids can be used as diff --git a/man/feedly_search_title.Rd b/man/feedly_search_title.Rd index 0921e06..246a9ff 100644 --- a/man/feedly_search_title.Rd +++ b/man/feedly_search_title.Rd @@ -2,13 +2,17 @@ % Please edit documentation in R/feedly-search-title.R \name{feedly_search_title} \alias{feedly_search_title} -\title{Find feeds based on title, url or \code{#topic}} +\title{Find feeds based on title, url or \verb{#topic}} \usage{ -feedly_search_title(query, count = 20L, locale = NULL, - feedly_token = feedly_access_token()) +feedly_search_title( + query, + count = 20L, + locale = NULL, + feedly_token = feedly_access_token() +) } \arguments{ -\item{query}{a full or partial title string, URL, or \code{#topic}} +\item{query}{a full or partial title string, URL, or \verb{#topic}} \item{count}{number of items to return (API default is 20)} diff --git a/man/feedly_stream.Rd b/man/feedly_stream.Rd index 4513e97..6a1d4da 100644 --- a/man/feedly_stream.Rd +++ b/man/feedly_stream.Rd @@ -4,9 +4,14 @@ \alias{feedly_stream} \title{Retrieve contents of a Feedly "stream"} \usage{ -feedly_stream(stream_id, ranked = c("newest", "oldest"), - unread_only = FALSE, count = 1000L, continuation = NULL, - feedly_token = feedly_access_token()) +feedly_stream( + stream_id, + ranked = c("newest", "oldest"), + unread_only = FALSE, + count = 1000L, + continuation = NULL, + feedly_token = feedly_access_token() +) } \arguments{ \item{stream_id}{the id of the stream} diff --git a/man/feedly_subscribe.Rd b/man/feedly_subscribe.Rd index 9b98490..cdc81c5 100644 --- a/man/feedly_subscribe.Rd +++ b/man/feedly_subscribe.Rd @@ -4,8 +4,12 @@ \alias{feedly_subscribe} \title{Subscribe to an RSS feed} \usage{ -feedly_subscribe(feed_url, categories = NULL, title = NULL, - feedly_token = feedly_access_token()) +feedly_subscribe( + feed_url, + categories = NULL, + title = NULL, + feedly_token = feedly_access_token() +) } \arguments{ \item{feed_url}{a URL to an RSS feed (this will be validated).} @@ -28,6 +32,7 @@ Authorization is \emph{required} for this API call. \dontrun{ feedly_subscribe("https://journal.r-project.org/rss.atom") feedly_subscribe("http://gh-feed.imsun.net/hrbrmstr/sergeant/issues", "git issues") +feedly_subscribe("https://rsshub.app/github/issue/hrbrmstr/sergeant", "git issues") } } \references{ diff --git a/man/global_resource_ids.Rd b/man/global_resource_ids.Rd index 89e878c..b151386 100644 --- a/man/global_resource_ids.Rd +++ b/man/global_resource_ids.Rd @@ -9,25 +9,25 @@ The following is a list of built-in categories and tags applications can take ad \section{Id List}{ \itemize{ -\item \code{user/:userId/category/global.all} -All articles from all the feeds the user subscribes to (example: \code{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.all}) -\item \code{user/:userId/category/global.uncategorized} -All the articles from all the sources the user subscribes to and are not in a category (example: \code{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.uncategorized}) -\item \code{user/:userId/category/global.must} -Users can promote sources they really love to read to must have (example: \code{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.must}) -\item \code{user/:userId/tag/global.read’ List of entries the user has recently read - limited to the feeds the users subscribes to (example: }user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.read`) -\item \code{user/:userId/tag/global.saved} -Users can save articles for later. Equivalent of starring articles in Google Reader (example: \code{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.saved}) -\item \code{user/:userId/tag/global.all} -All articles from all personal tags, including global.saved (example: \code{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.all}) -\item \code{enterprise/:enterpriseName/category/global.all} +\item \verb{user/:userId/category/global.all} +All articles from all the feeds the user subscribes to (example: \verb{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.all}) +\item \verb{user/:userId/category/global.uncategorized} +All the articles from all the sources the user subscribes to and are not in a category (example: \verb{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.uncategorized}) +\item \verb{user/:userId/category/global.must} +Users can promote sources they really love to read to must have (example: \verb{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.must}) +\item \verb{user/:userId/tag/global.read’ List of entries the user has recently read - limited to the feeds the users subscribes to (example: }user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.read`) +\item \verb{user/:userId/tag/global.saved} +Users can save articles for later. Equivalent of starring articles in Google Reader (example: \verb{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.saved}) +\item \verb{user/:userId/tag/global.all} +All articles from all personal tags, including global.saved (example: \verb{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.all}) +\item \verb{enterprise/:enterpriseName/category/global.all} All articles from all team feeds (example: \code{enterprise/acmeinc/category/global.all}) -\item \code{enterprise/:enterpriseName/tags/global.all} +\item \verb{enterprise/:enterpriseName/tags/global.all} All articles from all team tags (example: \code{enterprise/acmeinc/tags/global.all}) -\item \code{user/:userId/category/global.enterprise} -All articles from all the team categories a user is following (example: \code{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.enterprise}) -\item \code{user/:userId/tag/global.enterprise} -All articles from all the team tags a user is subscribed to (example: \code{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.enterprise}) +\item \verb{user/:userId/category/global.enterprise} +All articles from all the team categories a user is following (example: \verb{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.enterprise}) +\item \verb{user/:userId/tag/global.enterprise} +All articles from all the team tags a user is subscribed to (example: \verb{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.enterprise}) } } diff --git a/man/render_stream.Rd b/man/render_stream.Rd index 3548a77..70aebdd 100644 --- a/man/render_stream.Rd +++ b/man/render_stream.Rd @@ -4,8 +4,13 @@ \alias{render_stream} \title{Render a Feedly Stream Data Frame to RMarkdown} \usage{ -render_stream(feedly_stream, title = "Feedly Stream Summary", - include_visual = FALSE, browse = FALSE, quiet = TRUE) +render_stream( + feedly_stream, + title = "Feedly Stream Summary", + include_visual = FALSE, + browse = FALSE, + quiet = TRUE +) } \arguments{ \item{feedly_stream}{output from \code{\link[=feedly_stream]{feedly_stream()}}. Ideally, you'll filter diff --git a/man/seymour.Rd b/man/seymour.Rd index c5392a8..bcc5364 100644 --- a/man/seymour.Rd +++ b/man/seymour.Rd @@ -3,7 +3,6 @@ \docType{package} \name{seymour} \alias{seymour} -\alias{seymour-package} \title{Tools to Work with the 'Feedly' 'API'} \description{ \if{html}{ @@ -26,7 +25,7 @@ Neither \code{\link[=feedly_search]{feedly_search()}} nor \code{\link[=feedly_st (i.e. you do not need a developer token) to retrieve the contents of the API call. For \code{feedly_stream()} You \emph{do} need to know the Feedly-structured feed id which is (generally) \code{feed/FEED_URL} -(e.g. \code{feed/http://feeds.feedburner.com/RBloggers}). +(e.g. \verb{feed/http://feeds.feedburner.com/RBloggers}). \itemize{ \item URL: \url{https://gitlab.com/hrbrmstr/seymour} \item BugReports: \url{https://gitlab.com/hrbrmstr/seymour/issues}