-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc6f1db
commit a2f957f
Showing
17 changed files
with
400 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src" /> | ||
<classpathentry kind="con" | ||
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8" /> | ||
<classpathentry exported="true" kind="con" | ||
path="org.springsource.ide.eclipse.gradle.classpathcontainer" /> | ||
<classpathentry kind="output" path="bin" /> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>RingCentral-Java</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.springsource.ide.eclipse.gradle.core.nature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
5 changes: 5 additions & 0 deletions
5
.settings/gradle/org.springsource.ide.eclipse.gradle.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#org.springsource.ide.eclipse.gradle.core.preferences.GradleProjectPreferences | ||
#Wed Jul 29 13:15:58 PDT 2015 | ||
build.family.org.gradle.tooling.model.eclipse.HierarchicalEclipseProject=; | ||
org.springsource.ide.eclipse.gradle.linkedresources= | ||
org.springsource.ide.eclipse.gradle.rootprojectloc= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.8 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package core; | ||
|
||
import platform.Platform; | ||
|
||
public class SDK { | ||
|
||
Platform platform; | ||
|
||
public SDK(String appKey, String appSecret, String server) { | ||
platform = new Platform(appKey, appSecret, server); | ||
} | ||
|
||
public Platform getPlatform() { | ||
return this.platform; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package http; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class RCHeaders { | ||
|
||
public static String CONTENT_TYPE = "Content-Type"; | ||
|
||
public static final String JSON_CONTENT_TYPE = "application/json"; | ||
public static final String MULTIPART_CONTENT_TYPE = "multipart/mixed"; | ||
public static final String URL_ENCODED_CONTENT_TYPE = "application/x-www-form-urlencoded"; | ||
HashMap<String, String> hmHeader; | ||
|
||
public RCHeaders() { | ||
this.hmHeader = new HashMap<>(); | ||
} | ||
|
||
public RCHeaders(HashMap<String, String> headers) { | ||
this.hmHeader = headers; | ||
} | ||
|
||
public String getContentType() { | ||
return hasHeader(CONTENT_TYPE) ? getHeader(CONTENT_TYPE) : ""; | ||
} | ||
|
||
public String getHeader(String key) { | ||
return this.hmHeader.get(key); | ||
} | ||
|
||
public HashMap<String, String> getHeaders() { | ||
return hmHeader; | ||
} | ||
|
||
public String[] getHeadersArray() { | ||
String[] array = new String[this.hmHeader.size()]; | ||
int count = 0; | ||
for (Map.Entry<String, String> entry : this.hmHeader.entrySet()) { | ||
array[count] = entry.getKey() + ":" + entry.getValue(); | ||
count++; | ||
} | ||
return array; | ||
} | ||
|
||
public boolean hasHeader(String key) { | ||
return this.hmHeader.containsKey(key); | ||
} | ||
|
||
public boolean isContentType(String contentType) { | ||
return (this.hmHeader.get(CONTENT_TYPE).contains(contentType)); | ||
} | ||
|
||
public boolean isJson() { | ||
return isContentType(JSON_CONTENT_TYPE); | ||
} | ||
|
||
public boolean isMultipart() { | ||
return isContentType(MULTIPART_CONTENT_TYPE); | ||
} | ||
|
||
public boolean isURLEncoded() { | ||
return isContentType(URL_ENCODED_CONTENT_TYPE); | ||
} | ||
|
||
public void setContentType(String contentType) { | ||
this.hmHeader.put(CONTENT_TYPE, contentType); | ||
} | ||
|
||
public void setHeader(String key, String val) { | ||
this.hmHeader.put(key, val); | ||
} | ||
|
||
public void setHeaders(HashMap<String, String> headers) { | ||
for (Map.Entry<String, String> entry : headers.entrySet()) { | ||
setHeader(entry.getKey(), entry.getValue()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package http; | ||
|
||
import java.util.HashMap; | ||
|
||
public class RCRequest { | ||
HashMap<String, String> body; | ||
String method; | ||
String query; | ||
public RCHeaders RCHeaders; | ||
String url; | ||
|
||
public RCRequest(HashMap<String, String> body, | ||
HashMap<String, String> headerMap) { | ||
RCHeaders = new RCHeaders(); | ||
this.method = headerMap.get("method"); | ||
this.url = headerMap.get("url"); | ||
if (headerMap.containsKey("query")) { | ||
this.query = headerMap.get("query"); | ||
} else { | ||
this.query = ""; | ||
} | ||
if (headerMap.containsKey("Content-Type")) { | ||
this.RCHeaders.setContentType(headerMap.get("Content-Type")); | ||
} | ||
if (body != null) { | ||
this.body = body; | ||
} else { | ||
this.body = null; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package http; | ||
|
||
public class RCResponse { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package platform; | ||
|
||
import java.util.Calendar; | ||
import java.util.Date; | ||
import java.util.GregorianCalendar; | ||
import java.util.Map; | ||
|
||
public class Auth { | ||
|
||
String access_token; | ||
Date expire_time; | ||
String expires_in; | ||
String owner_id; | ||
String refresh_token; | ||
Date refresh_token_expire_time; | ||
String refresh_token_expires_in; | ||
String scope; | ||
String token_type; | ||
|
||
// public Auth() { | ||
// token_type = ""; | ||
// access_token = ""; | ||
// expires_in = ""; | ||
// expire_time = null; | ||
// refresh_token = ""; | ||
// refresh_token_expires_in = ""; | ||
// refresh_token_expire_time = null; | ||
// scope = ""; | ||
// owner_id = ""; | ||
// } | ||
|
||
public String getAccessToken() { | ||
return this.access_token; | ||
} | ||
|
||
public Auth getData() { | ||
return this; | ||
} | ||
|
||
public String getRefreshToken() { | ||
return this.refresh_token; | ||
} | ||
|
||
public String getTokenType() { | ||
return this.token_type; | ||
} | ||
|
||
public boolean isAccessTokenValid() { | ||
GregorianCalendar cal = new GregorianCalendar(); | ||
cal.setTime(this.expire_time); | ||
return isTokenDateValid(cal); | ||
} | ||
|
||
public boolean isRefreshTokenValid() { | ||
GregorianCalendar cal = new GregorianCalendar(); | ||
cal.setTime(this.refresh_token_expire_time); | ||
return isTokenDateValid(cal); | ||
} | ||
|
||
public boolean isTokenDateValid(GregorianCalendar token_date) { | ||
return (token_date.compareTo(new GregorianCalendar()) > 0); | ||
} | ||
|
||
public void setData(Map<String, String> authData) { | ||
|
||
if (authData.containsKey("token_type")) { | ||
this.token_type = authData.get("token_type"); | ||
} | ||
if (authData.containsKey("scope")) { | ||
this.scope = authData.get("scope"); | ||
} | ||
if (authData.containsKey("owner_id")) { | ||
this.owner_id = authData.get("owner_id"); | ||
} | ||
if (authData.containsKey("access_token")) { | ||
this.access_token = authData.get("access_token"); | ||
} | ||
if (authData.containsKey("expires_in")) { | ||
this.expires_in = authData.get("expires_in"); | ||
} | ||
if (!authData.containsKey("expire_time") | ||
&& authData.containsKey("expires_in")) { | ||
int expiresIn = Integer.parseInt(authData.get("expires_in")); | ||
Calendar calendar = new GregorianCalendar(); | ||
calendar.add(Calendar.SECOND, expiresIn); | ||
this.expire_time = calendar.getTime(); | ||
|
||
} | ||
if (authData.containsKey("refresh_token")) { | ||
this.refresh_token = authData.get("refresh_token"); | ||
} | ||
if (authData.containsKey("refresh_token_expires_in")) { | ||
this.refresh_token_expires_in = authData | ||
.get("refresh_token_expires_in"); | ||
} | ||
if (!authData.containsKey("refresh_token_expire_time") | ||
&& authData.containsKey("refresh_token_expires_in")) { | ||
int expiresIn = Integer.parseInt(authData | ||
.get("refresh_token_expires_in")); | ||
Calendar calendar = new GregorianCalendar(); | ||
calendar.add(Calendar.SECOND, expiresIn); | ||
this.refresh_token_expire_time = calendar.getTime(); | ||
} | ||
|
||
System.out.println(this.expire_time); | ||
System.out.println(this.expires_in); | ||
System.out.println(this.refresh_token_expires_in); | ||
System.out.println(this.refresh_token_expire_time); | ||
} | ||
} |
Oops, something went wrong.