forked from bitphy/customer-datathon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.R
More file actions
29 lines (23 loc) · 723 Bytes
/
Copy pathclient.R
File metadata and controls
29 lines (23 loc) · 723 Bytes
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
pacman::p_load(
"ConfigParser",
"httr"
)
submit_predictions <- function(config_file, df){
config <- ConfigParser$new()
config <- config$read(config_file)
protocol <- 'http://'
host <- config$get(option='host', section='DEFAULT')
token <- config$get(option='token', section='DEFAULT')
# post predictions
endpoint <- '/predictions'
url <- paste(protocol, host, endpoint, sep='')
headers <- add_headers(
"Content-Type" = "application/json",
"Authorization" = paste("Bearer", token),
"Prefer" = "return=representation"
)
payload <- df[,c('customer', 'date', 'billing')]
r <- POST(url, body = payload, encode = "json", headers)
status <- http_status(r)$message
return(status)
}