eipar.R 1.58 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

#' eipar
#'
#' eipar
#' @keywords eipar
#' @export
#' @examples
#' \dontrun{
#' eipar()
#' }
eipar <- function(){
  eipar_object()
}

eipar_object <- function(){

  client_api <- ecapi::ecapi()

  client_api$url_auth("ask for the id key")
  client_api$auth_type("basic")
  client_api$ua("eipar-r-package")
Jean-Marie Lepioufle's avatar
typo    
Jean-Marie Lepioufle committed
22
  client_api$base_url(host="https://air-tst.epa.ie",basepath="/api/v1/")
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

  client_api$add_endpoint(name     = "measurements",
                          epoint   = "aq_measurements",
                          question = "?where",
                          debut    = "{",
                          end      = "}",
                          syntaxe  = "'measurementtype':<<'measurementtype'>>,'samplingpoint':<<'samplingpoint'>>,'measurementunit':<<'measurementunit'>>,'pollutantname':<<'pollutantname'>>,'raw_reading_measurement_time':<<'raw_reading_measurement_time'>>,'rawreadingid':<<rawreadingid>>"
                        )

  object <- local({

    measurements <- function(measurementtype="",measurementunit="",pollutantname="",raw_reading_measurement_time="",rawreadingid="",samplingpoint="",username,password,type){
      client_api$verb_get(name="measurements",measurementtype=measurementtype,measurementunit=measurementunit,pollutantname=pollutantname,raw_reading_measurement_time=raw_reading_measurement_time,rawreadingid=rawreadingid,samplingpoint=samplingpoint,out='_items',username=username,password=password)
    }

    summary <- function(){
      client_api$summary()
    }

    environment()
    })
    lockEnvironment(object, TRUE)
    structure(object, class=c("eipar", class(object)))
}