Skip to content

Commit

Permalink
Merge pull request #10 from DataINCITE/flynnc3-temp
Browse files Browse the repository at this point in the history
Update R files and clean directory
  • Loading branch information
flynnc3 authored Apr 6, 2023
2 parents a0b3c9c + 558caca commit 6398915
Show file tree
Hide file tree
Showing 24 changed files with 514 additions and 604 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public final static void unlock(String name) {
// loop through all headers and format
for(String header : headers.get(name)) {
if(buffer.get(i).containsKey(header)) {
line.append(buffer.get(i).get(header));
line.append(buffer.get(i).get(header).replaceAll(",", "|"));
}

line.append(",");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ protected final Request getRequest(String url, HashMap<String, String> propertie
}

// remove final & and update builder
url_builder.deleteCharAt(url_builder.length() - 1);
if(!properties.isEmpty())
url_builder.deleteCharAt(url_builder.length() - 1);
builder = builder.url(url_builder.toString());

// add all headers
Expand Down Expand Up @@ -263,6 +264,7 @@ public final synchronized String request(String[] url_path, HashMap<String, Stri
}

// submit request with updated properties
System.out.println(String.format("Requesting: name=[%s] date=[%s]", getName(), date.toString()));
String request = request(url_path, properties, headers);
if(request != null)
return request;
Expand All @@ -271,6 +273,18 @@ public final synchronized String request(String[] url_path, HashMap<String, Stri
return null;
}

protected String processUrl(String url, HashMap<String, String> headers) {
HashMap<String, String> all_headers = new HashMap<String, String>();

for(String header : this.headers.keySet())
all_headers.put(header, this.headers.get(header));

for(String header : headers.keySet())
all_headers.put(header, headers.get(header));

return processRequest(url, new HashMap<String, String>(), all_headers);
}

protected String process(String url, HashMap<String, String> properties, HashMap<String, String> headers) {
HashMap<String, String> all_properties = new HashMap<String, String>();
HashMap<String, String> all_headers = new HashMap<String, String>();
Expand All @@ -279,17 +293,21 @@ protected String process(String url, HashMap<String, String> properties, HashMap
for(String property : this.properties.keySet())
all_properties.put(property, this.properties.get(property));

for(String header : this.headers.keySet())
all_headers.put(header, this.headers.get(header));

for(String property : properties.keySet())
all_properties.put(property, properties.get(property));

for(String header : this.headers.keySet())
all_headers.put(header, this.headers.get(header));

for(String header : headers.keySet())
all_headers.put(header, headers.get(header));

return processRequest(url, all_properties, all_headers);
}

private String processRequest(String url, HashMap<String, String> properties, HashMap<String, String> headers) {
OkHttpClient client = new OkHttpClient();
Request request = getRequest(url, all_properties, all_headers);
Request request = getRequest(url, properties, headers);
if(request == null) {
System.err.println("Malformed request, killing process.");
return "Malformed request, killing process.";
Expand All @@ -301,8 +319,7 @@ protected String process(String url, HashMap<String, String> properties, HashMap
response = client.newCall(request).execute();
body = response.body().string().toString();
if(response.code() != 200) {
System.err.println(String.format("Request Failure code <%d> url <%s>\nbody:\n%s", response.code(), request.url().toString(), body));
return String.format("Request Failure code <%d> url <%s>\nbody:\n%s", response.code(), request.url().toString(), body);
return String.format("Request Failure code=<%d> url=<%s> body=<%s>", response.code(), request.url().toString(), body);
}
} catch (IOException e) {
e.printStackTrace();
Expand All @@ -315,7 +332,7 @@ protected String process(String url, HashMap<String, String> properties, HashMap

// send to specific request handler
try {
handle(body, all_properties, all_headers);
handle(body, properties, headers);
} catch(Exception e) {
e.printStackTrace();
return e.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ else if(obj.has(path[i])) {
case "url":
properties.clear();
url = recursive_parameter;
break;
return processUrl(url, headers);

// type incremental:
// - assert that parameter is an integer
Expand Down Expand Up @@ -174,6 +174,7 @@ else if(obj.has(path[i])) {
} else {
properties.put(getRecursiveLocation()[0], recursive_parameter);
}
break;
}

// increment param, replace, and execute
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
request.name= amberdata-uniswap-pool

url.base= https://web3api.io/api/v2/defi/dex/uniswapv2/pools

url.base.path= poolAddress,.

url.properties= size,900

url.headers= accept,application/json,\
x-api-key,.

data.path= payload,\
data

recursion.type= parameterized

recursion.tags= -l,900,\
-t,url

recursion.location= payload,metadata,next

date.valid= true

date.location= properties

date.start= startDate

date.end= endDate

date.format= yyyy-MM-dd
Binary file not shown.
49 changes: 0 additions & 49 deletions DeFi-Data-Engine/Rest Application/.classpath

This file was deleted.

2 changes: 0 additions & 2 deletions DeFi-Data-Engine/Rest Application/.gitignore

This file was deleted.

23 changes: 0 additions & 23 deletions DeFi-Data-Engine/Rest Application/.project

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions DeFi-Data-Engine/Rest Application/Dockerfile

This file was deleted.

76 changes: 0 additions & 76 deletions DeFi-Data-Engine/Rest Application/pom.xml

This file was deleted.

Loading

0 comments on commit 6398915

Please sign in to comment.