Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.apptik:jus:v0.6.9'
}
dependencies {
implementation("com.github.apptik:jus:v0.6.9")
}
<dependency>
<groupId>com.github.apptik</groupId>
<artifactId>jus</artifactId>
<version>v0.6.9</version>
</dependency>
libraryDependencies += "com.github.apptik" % "jus" % "v0.6.9"
:dependencies [[com.github.apptik/jus "v0.6.9"]]
Jus is a flexible and easy HTTP/REST client library for Java and Android.
Jus is inspired by the flexibility, modularity and transparency of Google's Volley Library and the extreme simplicity of declarative API mapping of Retrofit.
Like Volley the main thing where Requests are executed is the RequestQueue.
RequestQueue queue = Jus.newRequestQueue();
and then Requests can be added to the Queue:
queue.add(new Request<String>(
Request.Method.GET,
HttpUrl.parse(BeerService.fullUrl),
new Converters.StringResponseConverter())
.addResponseListener((r) -> out.println("RESPONSE: " + r))
.addErrorListener((e) -> out.println("ERROR: " + e))
);
Anther option similarly to Retrofit is to map Java Interface to an API.
public interface BeerService {
@GET("locquery/{user}/{q}")
Request<String> getBeer(
@Path("user") String user,
@Path("q") String q);
}
Then create the Service Instance:
RetroProxy retroJus = new RetroProxy.Builder()
.baseUrl(BeerService.baseUrl)
.requestQueue(queue)
.addConverterFactory(new BasicConverterFactory())
.build();
BeerService beerService = retroJus.create(BeerService.class);
And execute a request:
beerService.getBeer(BeerService.userString, "777")
.addResponseListener((r) -> out.println("RESPONSE: " + r))
.addErrorListener((e) -> out.println("ERROR: " + e.networkResponse));
Find the latest JARs or grab via Maven:
<dependency>
<groupId>io.apptik.comm</groupId>
<artifactId>jus-XXX</artifactId>
<version>0.6.9</version>
</dependency>
or Gradle:
compile 'io.apptik.comm:jus-XXX:0.6.9'
Downloads of the released versions are available in Sonatype's releases
repository.
Snapshots of the development versions are available in Sonatype's snapshots
repository.
Jus requires at minimum Java 7 or Android SDK 15.
StackOverflow with tag 'jus' or 'apptik'
HTTP Stacks
Jus for Android
Copyright (C) 2016 AppTik Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.