Compare commits
No commits in common. '84e8663b3b8c9b228e491f2062c8d2e04aeb81d4' and '22c606824510bd6d72272288c0e97c9d65e8598d' have entirely different histories.
84e8663b3b
...
22c6068245
23 changed files with 520 additions and 2 deletions
@ -0,0 +1,26 @@ |
|||
^.vscode$ |
|||
^.*\.Rproj$ |
|||
^\.Rproj\.user$ |
|||
^\.travis\.yml$ |
|||
^README\.*Rmd$ |
|||
^README\.*html$ |
|||
^NOTES\.*Rmd$ |
|||
^NOTES\.*html$ |
|||
^\.codecov\.yml$ |
|||
^README_files$ |
|||
^doc$ |
|||
^docs$ |
|||
^tmp$ |
|||
^notes$ |
|||
^CONDUCT.*$ |
|||
^CODE.*$ |
|||
^\.gitlab-ci\.yml$ |
|||
^\.vscode$ |
|||
^CRAN-RELEASE$ |
|||
^appveyor\.yml$ |
|||
^tools$ |
|||
^LICENSE\.md$ |
|||
^bld$ |
|||
^node_modules^ |
|||
^package-lock\.json$ |
|||
^\.github$ |
@ -0,0 +1 @@ |
|||
comment: false |
@ -0,0 +1,26 @@ |
|||
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. |
|||
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions |
|||
on: |
|||
push: |
|||
branches: |
|||
- batman |
|||
pull_request: |
|||
branches: |
|||
- batmsn |
|||
|
|||
name: R-CMD-check |
|||
|
|||
jobs: |
|||
R-CMD-check: |
|||
runs-on: macOS-latest |
|||
steps: |
|||
- uses: actions/checkout@v2 |
|||
- uses: r-lib/actions/setup-r@master |
|||
- name: Install dependencies |
|||
run: | |
|||
install.packages(c("remotes", "rcmdcheck")) |
|||
remotes::install_deps(dependencies = TRUE) |
|||
shell: Rscript {0} |
|||
- name: Check |
|||
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error") |
|||
shell: Rscript {0} |
@ -0,0 +1,9 @@ |
|||
.DS_Store |
|||
.Rproj.user |
|||
.Rhistory |
|||
.RData |
|||
.Rproj |
|||
README_cache |
|||
src/*.o |
|||
src/*.so |
|||
src/*.dll |
@ -0,0 +1,12 @@ |
|||
language: R |
|||
sudo: false |
|||
cache: packages |
|||
|
|||
before_install: |
|||
- echo "options(repos = c(CRAN = 'https://packagemanager.rstudio.com/all/__linux__/xenial/latest'))" >> ~/.Rprofile.site |
|||
- echo "options(HTTPUserAgent = paste0('R/', getRversion(), ' R (', |
|||
paste(getRversion(), R.version['platform'], R.version['arch'], R.version['os']), |
|||
')'))" >> ~/.Rprofile.site |
|||
|
|||
after_success: |
|||
- Rscript -e 'covr::codecov()' |
@ -0,0 +1,25 @@ |
|||
# Contributor Code of Conduct |
|||
|
|||
As contributors and maintainers of this project, we pledge to respect all people who |
|||
contribute through reporting issues, posting feature requests, updating documentation, |
|||
submitting pull requests or patches, and other activities. |
|||
|
|||
We are committed to making participation in this project a harassment-free experience for |
|||
everyone, regardless of level of experience, gender, gender identity and expression, |
|||
sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. |
|||
|
|||
Examples of unacceptable behavior by participants include the use of sexual language or |
|||
imagery, derogatory comments or personal attacks, trolling, public or private harassment, |
|||
insults, or other unprofessional conduct. |
|||
|
|||
Project maintainers have the right and responsibility to remove, edit, or reject comments, |
|||
commits, code, wiki edits, issues, and other contributions that are not aligned to this |
|||
Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed |
|||
from the project team. |
|||
|
|||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by |
|||
opening an issue or contacting one or more of the project maintainers. |
|||
|
|||
This Code of Conduct is adapted from the Contributor Covenant |
|||
(http:contributor-covenant.org), version 1.0.0, available at |
|||
http://contributor-covenant.org/version/1/0/0/ |
@ -0,0 +1,24 @@ |
|||
Package: clearbit |
|||
Type: Package |
|||
Title: Tools to Query Clearbit |
|||
Version: 0.1.0 |
|||
Date: 2021-07-09 |
|||
Authors@R: c( |
|||
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), |
|||
comment = c(ORCID = "0000-0001-5670-2640")) |
|||
) |
|||
Maintainer: Bob Rudis <bob@rud.is> |
|||
Description: Clearbit provides an interface to perform queries on organizations and people. |
|||
URL: https://git.rud.is/hrbrmstr/clearbit |
|||
BugReports: https://git.rud.is/hrbrmstr/clearbit/issues |
|||
Encoding: UTF-8 |
|||
License: MIT + file LICENSE |
|||
Suggests: |
|||
covr, tinytest |
|||
Depends: |
|||
R (>= 3.6.0) |
|||
Imports: |
|||
httr, |
|||
jsonlite |
|||
Roxygen: list(markdown = TRUE) |
|||
RoxygenNote: 7.1.1 |
@ -0,0 +1,2 @@ |
|||
YEAR: 2021 |
|||
COPYRIGHT HOLDER: clearbit authors |
@ -0,0 +1,21 @@ |
|||
# MIT License |
|||
|
|||
Copyright (c) 2021 clearbit authors |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to deal |
|||
in the Software without restriction, including without limitation the rights |
|||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in all |
|||
copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|||
SOFTWARE. |
@ -0,0 +1,7 @@ |
|||
# Generated by roxygen2: do not edit by hand |
|||
|
|||
export(clearbit_api_key) |
|||
export(domain_to_org) |
|||
export(name_to_domain) |
|||
import(httr) |
|||
importFrom(jsonlite,fromJSON) |
@ -0,0 +1,2 @@ |
|||
0.1.0 |
|||
* Initial release |
@ -0,0 +1,9 @@ |
|||
#' ... |
|||
#' |
|||
#' @md |
|||
#' @name clearbit |
|||
#' @keywords internal |
|||
#' @author Bob Rudis (bob@@rud.is) |
|||
#' @import httr |
|||
#' @importFrom jsonlite fromJSON |
|||
"_PACKAGE" |
@ -0,0 +1,139 @@ |
|||
httr::user_agent( |
|||
sprintf( |
|||
"clearbit R package v%s: (<%s>)", |
|||
utils::packageVersion("clearbit"), |
|||
utils::packageDescription("clearbit")$URL |
|||
) |
|||
) -> .CLEARBIT_UA |
|||
|
|||
#' Get or set CLEARBIT_API_KEY value |
|||
#' |
|||
#' @param force Force setting a new Rapid7 Open Data API key for the current environment? |
|||
#' @return atomic character vector containing the Clearbit API key |
|||
#' @export |
|||
clearbit_api_key <- function(force = FALSE) { |
|||
|
|||
env <- Sys.getenv('CLEARBIT_API_KEY') |
|||
if (!identical(env, "") && !force) return(env) |
|||
|
|||
if (!interactive()) { |
|||
stop("Please set env var CLEARBIT_API_KEY to your Clearbit API key", |
|||
call. = FALSE) |
|||
} |
|||
|
|||
message("Couldn't find env var CLEARBIT_API_KEY See ?clearbit_api_key for more details.") |
|||
message("Please enter your Clearbit API key and press enter:") |
|||
pat <- readline(": ") |
|||
|
|||
if (identical(pat, "")) { |
|||
stop("Clearbit API key entry failed", call. = FALSE) |
|||
} |
|||
|
|||
message("Updating CLEARBIT_API_KEY env var...") |
|||
Sys.setenv(CLEARBIT_API_KEY = pat) |
|||
|
|||
pat |
|||
|
|||
} |
|||
|
|||
#' The Company Name to Domain API lets you convert the exact name of a company |
|||
#' to a website domain, and a logo. |
|||
#' |
|||
#' Clearbit matches based on exact company name, and returns the company with the most |
|||
#' website traffic. It’s worth noting, that since a company name is not a unique |
|||
#' identifier, you should be prepared for some inherent inaccuracy in the results. |
|||
#' |
|||
#' @param name name of the company to look for |
|||
#' @param api_key Clearbit API key. See [clearbit_api_key()] |
|||
#' @return data frame containing `domain`, `logo`, and `name` if found. `NULL` if not |
|||
#' @export |
|||
name_to_domain <- function(name, api_key = clearbit_api_key()) { |
|||
|
|||
httr::GET( |
|||
url = "https://company.clearbit.com/v1/domains/find", |
|||
httr::authenticate( |
|||
user = api_key, |
|||
password = "" |
|||
), |
|||
query = list( |
|||
name = name[1] |
|||
), |
|||
.CLEARBIT_UA |
|||
) -> res |
|||
|
|||
status <- httr::status_code(res) |
|||
|
|||
if (status == 200) { |
|||
|
|||
out <- httr::content(res, as = "text", encoding = "UTF-8") |
|||
out <- jsonlite::fromJSON(out) |
|||
as.data.frame(out) |
|||
|
|||
} else if (status == 404) { |
|||
|
|||
warning("Company not found.") |
|||
NULL |
|||
|
|||
} else if (status == 422) { |
|||
|
|||
warning("Company name is invalid.") |
|||
NULL |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
#' The Company Name to Domain API lets you convert the exact name of a company |
|||
#' to a website domain, and a logo. |
|||
#' |
|||
#' The Company API allows you to look up a company by their domain. Alongside |
|||
#' the domain you may also provide any additional attributes you have about the |
|||
#' company, such as their company name or twitter handle. Including more detail |
|||
#' will help us be more accurate when searching. |
|||
#' |
|||
#' @param domain name of the company to look for |
|||
#' @param api_key Clearbit API key. See [clearbit_api_key()] |
|||
#' @return data frame if found. `NULL` if not |
|||
#' @export |
|||
domain_to_org <- function(domain, api_key = clearbit_api_key()) { |
|||
|
|||
httr::GET( |
|||
url = "https://company.clearbit.com/v2/companies/find", |
|||
httr::authenticate( |
|||
user = api_key, |
|||
password = "" |
|||
), |
|||
query = list( |
|||
domain = domain[1] |
|||
), |
|||
.CLEARBIT_UA |
|||
) -> res |
|||
|
|||
status <- httr::status_code(res) |
|||
|
|||
if (status == 200) { |
|||
|
|||
out <- httr::content(res, as = "text", encoding = "UTF-8") |
|||
out <- jsonlite::fromJSON(out) |
|||
out |
|||
|
|||
} else if (status == 202) { |
|||
|
|||
out <- httr::content(res, as = "text", encoding = "UTF-8") |
|||
out <- jsonlite::fromJSON(out) |
|||
out |
|||
|
|||
} else if (status == 404) { |
|||
|
|||
warning("Company not found.") |
|||
NULL |
|||
|
|||
} else if (status == 422) { |
|||
|
|||
warning("Domain name is invalid.") |
|||
NULL |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,51 @@ |
|||
--- |
|||
output: rmarkdown::github_document |
|||
editor_options: |
|||
chunk_output_type: console |
|||
--- |
|||
```{r pkg-knitr-opts, include=FALSE} |
|||
hrbrpkghelpr::global_opts() |
|||
``` |
|||
|
|||
```{r badges, results='asis', echo=FALSE, cache=FALSE} |
|||
hrbrpkghelpr::stinking_badges() |
|||
``` |
|||
|
|||
```{r description, results='asis', echo=FALSE, cache=FALSE} |
|||
hrbrpkghelpr::yank_title_and_description() |
|||
``` |
|||
|
|||
## What's Inside The Tin |
|||
|
|||
The following functions are implemented: |
|||
|
|||
```{r ingredients, results='asis', echo=FALSE, cache=FALSE} |
|||
hrbrpkghelpr::describe_ingredients() |
|||
``` |
|||
|
|||
## Installation |
|||
|
|||
```{r install-ex, results='asis', echo=FALSE, cache=FALSE} |
|||
hrbrpkghelpr::install_block() |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
```{r lib-ex} |
|||
library(clearbit) |
|||
|
|||
# current version |
|||
packageVersion("clearbit") |
|||
|
|||
``` |
|||
|
|||
## clearbit Metrics |
|||
|
|||
```{r cloc, echo=FALSE} |
|||
cloc::cloc_pkg_md() |
|||
``` |
|||
|
|||
## Code of Conduct |
|||
|
|||
Please note that this project is released with a Contributor Code of Conduct. |
|||
By participating in this project you agree to abide by its terms. |
@ -1,2 +0,0 @@ |
|||
# clearbit |
|||
|
@ -0,0 +1,52 @@ |
|||
# DO NOT CHANGE the "init" and "install" sections below |
|||
|
|||
# Download script file from GitHub |
|||
init: |
|||
ps: | |
|||
= "Stop" |
|||
Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" |
|||
Import-Module '..\appveyor-tool.ps1' |
|||
|
|||
install: |
|||
ps: Bootstrap |
|||
|
|||
cache: |
|||
- C:\RLibrary |
|||
|
|||
environment: |
|||
NOT_CRAN: true |
|||
# env vars that may need to be set, at least temporarily, from time to time |
|||
# see https://github.com/krlmlr/r-appveyor#readme for details |
|||
# USE_RTOOLS: true |
|||
# R_REMOTES_STANDALONE: true |
|||
|
|||
# Adapt as necessary starting from here |
|||
|
|||
build_script: |
|||
- travis-tool.sh install_deps |
|||
|
|||
test_script: |
|||
- travis-tool.sh run_tests |
|||
|
|||
on_failure: |
|||
- 7z a failure.zip *.Rcheck\* |
|||
- appveyor PushArtifact failure.zip |
|||
|
|||
artifacts: |
|||
- path: '*.Rcheck\**\*.log' |
|||
name: Logs |
|||
|
|||
- path: '*.Rcheck\**\*.out' |
|||
name: Logs |
|||
|
|||
- path: '*.Rcheck\**\*.fail' |
|||
name: Logs |
|||
|
|||
- path: '*.Rcheck\**\*.Rout' |
|||
name: Logs |
|||
|
|||
- path: '\*_*.tar.gz' |
|||
name: Bits |
|||
|
|||
- path: '\*_*.zip' |
|||
name: Bits |
@ -0,0 +1,21 @@ |
|||
Version: 1.0 |
|||
|
|||
RestoreWorkspace: Default |
|||
SaveWorkspace: Default |
|||
AlwaysSaveHistory: Default |
|||
|
|||
EnableCodeIndexing: Yes |
|||
UseSpacesForTab: Yes |
|||
NumSpacesForTab: 2 |
|||
Encoding: UTF-8 |
|||
|
|||
RnwWeave: Sweave |
|||
LaTeX: pdfLaTeX |
|||
|
|||
StripTrailingWhitespace: Yes |
|||
|
|||
BuildType: Package |
|||
PackageUseDevtools: Yes |
|||
PackageInstallArgs: --no-multiarch --with-keep.source |
|||
PackageBuildArgs: --resave-data |
|||
PackageRoxygenize: rd,collate,namespace |
@ -0,0 +1,4 @@ |
|||
|
|||
# Placeholder with simple test |
|||
expect_equal(1 + 1, 2) |
|||
|
@ -0,0 +1,22 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/clearbit-package.R |
|||
\docType{package} |
|||
\name{clearbit} |
|||
\alias{clearbit} |
|||
\alias{clearbit-package} |
|||
\title{...} |
|||
\description{ |
|||
Clearbit provides an interface to perform queries on organizations and people. |
|||
} |
|||
\seealso{ |
|||
Useful links: |
|||
\itemize{ |
|||
\item \url{https://git.rud.is/hrbrmstr/clearbit} |
|||
\item Report bugs at \url{https://git.rud.is/hrbrmstr/clearbit/issues} |
|||
} |
|||
|
|||
} |
|||
\author{ |
|||
Bob Rudis (bob@rud.is) |
|||
} |
|||
\keyword{internal} |
@ -0,0 +1,17 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/core.R |
|||
\name{clearbit_api_key} |
|||
\alias{clearbit_api_key} |
|||
\title{Get or set CLEARBIT_API_KEY value} |
|||
\usage{ |
|||
clearbit_api_key(force = FALSE) |
|||
} |
|||
\arguments{ |
|||
\item{force}{Force setting a new Rapid7 Open Data API key for the current environment?} |
|||
} |
|||
\value{ |
|||
atomic character vector containing the Clearbit API key |
|||
} |
|||
\description{ |
|||
Get or set CLEARBIT_API_KEY value |
|||
} |
@ -0,0 +1,23 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/core.R |
|||
\name{domain_to_org} |
|||
\alias{domain_to_org} |
|||
\title{The Company Name to Domain API lets you convert the exact name of a company |
|||
to a website domain, and a logo.} |
|||
\usage{ |
|||
domain_to_org(domain, api_key = clearbit_api_key()) |
|||
} |
|||
\arguments{ |
|||
\item{domain}{name of the company to look for} |
|||
|
|||
\item{api_key}{Clearbit API key. See \code{\link[=clearbit_api_key]{clearbit_api_key()}}} |
|||
} |
|||
\value{ |
|||
data frame if found. \code{NULL} if not |
|||
} |
|||
\description{ |
|||
The Company API allows you to look up a company by their domain. Alongside |
|||
the domain you may also provide any additional attributes you have about the |
|||
company, such as their company name or twitter handle. Including more detail |
|||
will help us be more accurate when searching. |
|||
} |
@ -0,0 +1,22 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/core.R |
|||
\name{name_to_domain} |
|||
\alias{name_to_domain} |
|||
\title{The Company Name to Domain API lets you convert the exact name of a company |
|||
to a website domain, and a logo.} |
|||
\usage{ |
|||
name_to_domain(name, api_key = clearbit_api_key()) |
|||
} |
|||
\arguments{ |
|||
\item{name}{name of the company to look for} |
|||
|
|||
\item{api_key}{Clearbit API key. See \code{\link[=clearbit_api_key]{clearbit_api_key()}}} |
|||
} |
|||
\value{ |
|||
data frame containing \code{domain}, \code{logo}, and \code{name} if found. \code{NULL} if not |
|||
} |
|||
\description{ |
|||
Clearbit matches based on exact company name, and returns the company with the most |
|||
website traffic. It’s worth noting, that since a company name is not a unique |
|||
identifier, you should be prepared for some inherent inaccuracy in the results. |
|||
} |
@ -0,0 +1,5 @@ |
|||
|
|||
if ( requireNamespace("tinytest", quietly=TRUE) ){ |
|||
tinytest::test_package("clearbit") |
|||
} |
|||
|
Loading…
Reference in new issue