-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
103 lines (68 loc) · 2.9 KB
/
README.Rmd
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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# rfieldclimate
<!-- badges: start -->
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#maturing)
[![CRAN status](https://www.r-pkg.org/badges/version/rfieldclimate)](https://CRAN.R-project.org/package=rfieldclimate)
[![R build status](https://github.com/basf/rfieldclimate/workflows/R-CMD-check/badge.svg)](https://github.com/basf/rfieldclimate/actions)
[![Codecov test coverage](https://codecov.io/gh/basf/rfieldclimate/branch/master/graph/badge.svg?token=3OZ8Y9VVWN)](https://app.codecov.io/gh/basf/rfieldclimate?branch=master)
<!-- badges: end -->
An R client for [Fieldclimate API](https://api.fieldclimate.com/v2/docs/)
## Installation
```r
remotes::install_github("basf/rfieldclimate")
```
## Examples
```{r load, eval=FALSE}
library("rfieldclimate")
```
```{r load2, include=FALSE}
library("rfieldclimate", lib.loc = "~/R/packages")
```
### Authentication
`rfieldclimate` uses [HMAC](https://api.fieldclimate.com/v2/docs/#authentication-hmac) for authentication.
The public and private keys are read by default from environmental variables
`FC_PUBLIC_KEY` and `FC_PRIVATE_KEY`, but you can provide them also in every function call
using the `public_key=` and `private_key=` arguments.
### Basic use
`fc_request()` is the workhorse of this package.
With it you can query every API endpoint, e.g.
```{r request, eval=FALSE}
fc_request(method = "GET", path = "/system/types") %>%
head(2)
```
See the `Routes` tables [API documentation](https://api.fieldclimate.com/v2/docs/#system) for details.
URL parameters must be included in the `path=` arguments, the request body in `body=`.
## Wrappers
With `fc_request()` all the api functionality can be easily covered.
Additionally, we provide some wrappers around endpoints.
E.g. the wrapper for station information (see below) is defined as
```{r}
fc_get_station
```
For a few other endpoints wrapper functions are provided:
* `fc_get_user()` to list user information
* `fc_get_user_stations()` to list available stations
* `fc_get_station()` to get station information
* `fc_get_data()` to get data range of a station
* `fc_get_data_range()` to get data in range
Feel free to add more wrappers (as described above).
## Parsers
We provide also convenience wrappers for objects, like
* `fc_parse_data()` to parse the object returned by `fc_get_data_range()` into a
long format data.frame
* `fc_parse_stations()` to parse the object returned by `fc_get_user_stations()`
into a data.frame
## Unit tests
To run the full test suite with 100% coverage set valid environmental variables
`FC_PUBLIC_KEY` and `FC_PRIVATE_KEY` and run `devtools::test()`.