-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathprofile.R
125 lines (97 loc) · 2.11 KB
/
profile.R
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#'
#' init
#'
#' Initialize the library context
#'
#'
#' @examples
#'--------
#' library(eikon_r)
#' init()
init <- function()
{
if (exists("requestInfo") == FALSE)
{
requestInfo <<- new("RequestInfo")
}
}
#'
#' set_app_id
#'
#' Use this function to set your application id.
#' The application id should be set before calling functions to retrieve data
#' @param appId: string
#'
#'
#' @examples
#'--------
#' library(eikon_r)
#' set_app_id('YOUR_APP_ID')
set_app_id <- function(appId) {
init()
requestInfo@application_id <<- appId
}
#'
#' get_app_id
#'
#' Use this function to get back the application id you have set earlier with set_app_id.
#'
#'
#' @examples
#'--------
#' library(eikon_r)
#' my_app_id = get_app_id()
get_app_id <- function(appId) {
init()
return (requestInfo@application_id)
}
#'
#' set_proxy_port
#'
#' By default the library will try to connect to the proxy default port 9000.
#' Use this function if the proxy is listening on another port than 9000
#' @param port: integer
#'
#'
#' @examples
#'--------
#' library(eikon_r)
#' set_proxy_port(37009L)
set_proxy_port <- function(port) {
init()
requestInfo@proxy_port <<- port
}
#'
#' get_proxy_port
#'
#' Use this function to get back the proxy port the library will connect to
#'
#'
#' @examples
#'--------
#' library(eikon_r)
#' prox_port = get_proxy_port()
get_proxy_port <- function(port) {
init()
return (requestInfo@proxy_port)
}
RequestInfo <- setClass(
# Set the name for the class
"RequestInfo",
# Define the slots
slots = c(
application_id = "character",
proxy_port = "integer",
url = "character"
),
prototype=list(application_id="",proxy_port=9000L,url=""),
# Make a function that can test to see if the data is consistent.
# This is not called if you have an initialize function defined!
validity=function(object)
{
#if(sum(object@velocity^2)>100.0) {
#return("The velocity level is out of bounds.")
#}
return(TRUE)
}
)