Skip to content

Commit

Permalink
update gradle to version 5.2
Browse files Browse the repository at this point in the history
update gradle from groovy to kotlin
add upload File Into Post Method
add File Into RestClient
  • Loading branch information
alishatergholi committed Feb 18, 2019
1 parent b6ecb68 commit 936447c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ android {
dependencies {
implementation(fileTree(mapOf("include" to listOf("*.jar"), "dir" to "libs")))
implementation("androidx.appcompat:appcompat:1.0.2")
// implementation("com.github.alishatergholi:rest-client:v1.0.8")
implementation("com.github.alishatergholi:rest-client:v1.0.9")
testImplementation("junit:junit:4.12")
implementation(project(":library"))
// implementation(project(":library"))
androidTestImplementation("androidx.test:runner:1.1.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.1.1")
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/github/restclient/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ protected void onCreate(Bundle savedInstanceState) {
RequestParams params = new RequestParams(RequestBodyType.FormData);
params.put("page", "1");


restClient.POST("https://google.com",
"",
new RequestParams(),
Expand Down
33 changes: 33 additions & 0 deletions library/src/main/java/com/github/library/RestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,39 @@ public void POST(
}
}

public void POST_FILE(
@NonNull final String url,
@Nullable final String tag,
@NonNull final RequestParams params,
@NonNull final ResultHandler responder){

if (checkNetworkConnection(this.appContext)) {
responder.onFailure(url,0,ErrorCode.InternetConnectionError);
return;
}
//region Authorization Model
AuthModel auth = new AuthModel();
auth.setClientId(this.clientId);
auth.setClientSecret(this.clientSecret);
auth.setSite(this.site);
auth.setScope(this.scope);
auth.setGrantType(this.grantType);
auth.setUsername(this.username);
auth.setPassword(this.password);
auth.setAuthType(this.authType);
auth.setEncodingType(this.encodingType);
auth.setHeaders(this.headers);
//endregion
switch (this.authType){
case NO_AUTH:
POST.file_no_Auth(getClient(), url, tag, auth, params, responder);
break;
case BASIC_AUTH:
POST.file_basic_Auth(getClient(),url,tag,auth,params,responder);
break;
}
}

public void GET(
@NonNull final String url,
@Nullable final String tag,
Expand Down

0 comments on commit 936447c

Please sign in to comment.