-
Notifications
You must be signed in to change notification settings - Fork 0
/
infusionsoft.R
35 lines (30 loc) · 1.12 KB
/
infusionsoft.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
library(XMLRPC)
library(XML)
library(RCurl)
library(plyr)
#untar(download.packages(pkgs = "XMLRPC",destdir = ".",type="source",repos="http://r-forge.r-project.org")[,2])
source('./XMLRPC/R/serialize.R')
source('./tableschema.R')
#privateKey <- "1979978dc08730f121747d50003c8513"
getTable <- function(appName,privateKey,table,limit = 1000,page = 0,queryData = list(Id = "%"),selectedFields = c()) {
lookupFields <- if(length(selectedFields)==0) tableSchema[[table]] else selectedFields
data <- c()
while(TRUE) {
dataPage <- xml.rpc(paste("https://",appName,".infusionsoft.com/api/xmlrpc",sep=""),
"DataService.query",
privateKey,
table,
as.integer(limit),
as.integer(page),
queryData,
lookupFields
)
data <- c(data,dataPage)
if(length(dataPage)<limit) break
page <- page + 1
}
#df <- bind_rows(sapply(data,as.data.frame))
df <- rbind.fill(lapply(data,as.data.frame))
df <- df[,order(names(df))]
df
}