-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconsumeAPI.R
37 lines (34 loc) · 1.44 KB
/
consumeAPI.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
library(httr)
library(jsonlite)
library(lubridate)
## Credential Issuer Data
CredIssuer <- data.frame(
Issuer = c("Gitcoin Passport"),
IssuerDID = c("did:key:z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC")
)
## Function to get the passport
gtc_passport <- function(add,CredIssuer,host="127.0.0.1")
{
req <- GET(paste0("http://",host,":3000/verify?address=",add))
result <- content(req)
if(identical(result,FALSE)) return(data.frame())
res <- data.frame(
Address = add,
PassportOrigin = as_datetime(result$issuanceDate),
CredentialOrigin = as_datetime(sapply(result$stamps,function(x) x$credential$proof$created)),
CredentialProvider = sapply(result$stamps,function(x) x$provider),
CredentialIssuer = sapply(result$stamps,function(x) x$credential$issuer),
CredentialIssuerResolved = CredIssuer$Issuer[match(sapply(result$stamps,function(x) x$credential$issuer),CredIssuer$IssuerDID)],
CredentialVerified = sapply(result$stamps,function(x) x$verified)
)
res$CredentialIssuerResolved <- ifelse(is.na(res$CredentialIssuerResolved),"Not Recognized",res$CredentialIssuerResolved)
return(res)
}
gtc_passport_raw <- function(add,CredIssuer,host="127.0.0.1")
{
req <- GET(paste0("http://",host,":3000/verify?address=",add))
result <- content(req)
return(result)
}
gtc_passport("0x4cff229ef59e9615d12196a4ceff3f0f663e652d",CredIssuer)
gtc_passport_raw("0xdaEbb0DeD5205606Fd61F6D30FDa718839060B8b",CredIssuer)