voto-sdk-rxjava

Uses RxJava for accessing the VOTO API

License

License

Categories

Categories

RxJava Container Microservices Reactive libraries
GroupId

GroupId

com.addhen
ArtifactId

ArtifactId

voto-rxjava
Last Version

Last Version

0.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

voto-sdk-rxjava
Uses RxJava for accessing the VOTO API
Project URL

Project URL

https://github.com/eyedol/voto-java-sdk
Source Code Management

Source Code Management

https://github.com/eyedol/voto-java-sdk

Download voto-rxjava

How to add to project

<!-- https://jarcasting.com/artifacts/com.addhen/voto-rxjava/ -->
<dependency>
    <groupId>com.addhen</groupId>
    <artifactId>voto-rxjava</artifactId>
    <version>0.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.addhen/voto-rxjava/
implementation 'com.addhen:voto-rxjava:0.3.0'
// https://jarcasting.com/artifacts/com.addhen/voto-rxjava/
implementation ("com.addhen:voto-rxjava:0.3.0")
'com.addhen:voto-rxjava:jar:0.3.0'
<dependency org="com.addhen" name="voto-rxjava" rev="0.3.0">
  <artifact name="voto-rxjava" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.addhen', module='voto-rxjava', version='0.3.0')
)
libraryDependencies += "com.addhen" % "voto-rxjava" % "0.3.0"
[com.addhen/voto-rxjava "0.3.0"]

Dependencies

compile (2)

Group / Artifact Type Version
voto-java-sdk » voto jar 0.3.0
com.squareup.retrofit2 : adapter-rxjava jar 2.0.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Build Status Stories in Ready codecov.io Android Arsenal

VOTO JAVA SDK

VOTO Java SDK is a wrapper around the VOTO API to make it very easy to use. The goal of this SDK is to ease VOTO API integration into both Android and Java applications.

It comes with three independent modules:

  • Synchronous module; Access the API synchronously
  • Asynchronous module; Access the API asynchronously
  • RxJava module; Access the API using RxJava

Note: These are not official libraries from the VOTO team.

###Setup Add gradle dependency:

Add jcenter repostory:

repositories {
    jcenter()
}

Synchronous module:

dependencies {
    compile 'com.addhen:voto-sdk-sync:0.3.0'
}

Asynchronous module:

dependencies {
    compile 'com.addhen:voto-sdk-async:0.3.0'
}

RxJava module:

dependencies {
    compile 'com.addhen:voto-sdk-rxjava:0.3.0'
}

Usage

GET Data From VOTO API

Build API Client
  • Synchronous:
SyncVotoApiClient syncVotoApilient = new SyncVotoApiClient.Builder(<api_key>)
	.withLogLevel(HttpLoggingInterceptor.Level.BODY)
	.build();
  • Asynchronous:
AsyncVotoApiClient asyncVotoClient = new AsyncVotoApiClient.Builder(<api_key>)
	.withLogLevel(HttpLoggingInterceptor.Level.BODY)
	.build();
  • RxJava:
RxJavaVotoApiClient rxVotoClient = new RxJavaVotoApiClient.Builder(<api_key>)
	.withLogLevel(HttpLoggingInterceptor.Level.BODY)
	.build();
Execute API Request
  • Synchronous:
SyncVotoApiClient syncVotoApiClient = new SyncVotoApiClient.Builder("api_key")
	.withLogLevel(HttpLoggingInterceptor.Level.BODY)
	.build();
	
ListSubscribersResponse listSubscribersResponse = null;
try {
    listSubscribersResponse = syncVotoApiClient.listSubscribers(10);
} catch (IOException e) {
    e.printStackTrace();
}

System.out.println(listSubscribersResponse);
  • Asynchronous:
AsyncVotoApiClient asyncVotoApiClient = new AsyncVotoApiClient.Builder("api_key")
	.withLogLevel(HttpLoggingInterceptor.Level.BODY)
	.build();
	
asyncVotoApiClient.listSubscribers(10, new Callback<ListSubscribersResponse>() {
	@Override
    public void onResponse(Call<ListSubscribersResponse> call, Response<ListSubscribersResponse> response) {
    ListSubscribersResponse listSubscribersResponse = response.body();
    	System.out.println(listSubscribersResponse);
    }

    @Override
    public void onFailure(Call<ListSubscribersResponse> call, Throwable t) {
    	t.printStackTrace();
    }
});
  • RxJava:
RxJavaVotoApiClient rxJavaVotoApiClient = new RxJavaVotoApiClient.Builder("api_key")
	.withLogLevel(HttpLoggingInterceptor.Level.BODY)
	.build();
	
rxJavaVotoApiClient.listSubscribers(10).subscribe(new Action1<ListSubscribersResponse>() {
	@Override
	public void call(ListSubscribersResponse listSubscribersResponse) {
    	System.out.println(listSubscribersResponse);
  	}
});

Run sample

Make sure you've your VOTO API key set in the local.properties file located in the root directory of the project. The property name should be votoApiKey. If you don't set this, a dummy API key will be used.

After setting the voto api key, issue ./gradlew run. This should run the sample app and output the results in the console.

License

Copyright 2016 Henry Addo Open Source 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.

Versions

Version
0.3.0
0.2.0
0.1.0