-
Notifications
You must be signed in to change notification settings - Fork 71
Initialize
Orhan Obut edited this page Aug 9, 2015
·
2 revisions
####Create a service interface
public interface GitHubService {
@GET("/repos/{user}/{repo}")
void getRepo(
@Path("user") String user,
@Path("repo") String repo,
Callback<Repo> callback
);
@Mock
@Headers
@POST("/repos/{user}")
void addName(
@Path("user") String user,
@Header("auth") String authToken,
@Body Repo repo,
Callback<Repo> callback
);
}
####Initialize the wasp
GitHubService service = new Wasp.Builder(this)
.setEndpoint("https://api.github.com")
.setRequestInterceptor // Optional
.trustCertificates // Optional
.setHttpStack // Optional
.enableCookies // Optional
.setNetworkMode(NetworkMode.MOCK) // Optional(Used for Mock)
.build()
.create(MyService.class);
####And use it everywhere!
service.fetchRepo("github","wasp", new Callback<List<Repo>>{
@Override
public void onSuccess(WaspResponse response, List<Repo> repos) {
// do something
}
@Override
public void onError(WaspError error) {
// handle error
}
});
All contributes are welcome.