Skip to content

Commit

Permalink
update version and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianTerhorst committed Aug 6, 2016
1 parent b5c12ab commit 55d9e79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ A easy to use api client that combines the power of Retrofit, Realm, Gson, Rxjav

#####Add to build.gradle

```
compile 'io.fabianterhorst:apiclient:0.3'
```groovy
compile 'io.fabianterhorst:apiclient:0.4'
compile 'io.fabianterhorst:apiclient-accountmanager:0.1'
compile 'io.fabianterhorst:apiclient-components:0.1'
```
Expand All @@ -13,7 +13,7 @@ compile 'io.fabianterhorst:apiclient-components:0.1'

Create your Api Class

```
```java
public class Twitter extends ApiClient<TwitterApi> implements TwitterApi {

public Twitter(Realm realm, String apiKey) {
Expand Down Expand Up @@ -42,7 +42,7 @@ public class Twitter extends ApiClient<TwitterApi> implements TwitterApi {

Create your Api Interface (The Retrofit way)

```
```java
public interface TwitterApi {

@GET("tweets")
Expand All @@ -57,7 +57,7 @@ public interface TwitterApi {

Initiate the Singleton in the Application onCreate

```
```java
public class MyApplication extends Application {

@Override
Expand All @@ -76,7 +76,7 @@ public class MyApplication extends Application {

Use it and have fun. The library is handling the saving, the loading and the refreshing for you.

```
```java
Twitter twitter = Twitter.getInstance();

twitter.getTweets().subscribe(tweets-> System.out.println(tweets));
Expand All @@ -90,7 +90,7 @@ You can use the ApiClient component module to get access to RxActivity and RxFra

In your Activity you have to get the Singleton with the Activity lifecycle. Your activity has to extend RxActivity.

```
```java
Twitter twitter = Twitter.getInstance(bindToLifecycle());
```

Expand All @@ -100,7 +100,7 @@ And thats everythink you have to do to prevent memory leaks.

You can override the gson builder inside your api class and add custom deserializer adapters to avoid adding null objects.

```
```java
@Override
public GsonBuilder getGsonBuilder(GsonBuilder gsonBuilder) {
GsonUtils.registerRemoveNullListSerializer(gsonBuilder, new TypeToken<RealmList<MyFirstObject>>() {}, MyFirstObject.class);
Expand All @@ -114,15 +114,15 @@ public GsonBuilder getGsonBuilder(GsonBuilder gsonBuilder) {

You can use the ```setApiKey``` method.

```
```java
Twitter.getInstance().setApiKey("9876543210");
```

#####How to add other query parameters?

You can override the ```getHttpUrlBuilder(HttpUrl.Builder builder)``` method from the api client.

```
```java
@Override
public HttpUrl.Builder getHttpUrlBuilder(HttpUrl.Builder builder) {
return addQueryParameter("lang", Locale.getDefault().getLanguage());
Expand All @@ -134,15 +134,15 @@ public HttpUrl.Builder getHttpUrlBuilder(HttpUrl.Builder builder) {
The easiest way is to use the AuthUtils to add a authentication via the request builder for post parameters and headers or the http url builder for query parameter

myurl.com/api
```
```java
@Override
public Request.Builder getRequestBuilder(Request.Builder builder) {
return AuthUtils.addDefaultAuthentication(builder, getApiKey());
}
```

myurl.com/api?apiKey=012345
```
```java
@Override
public HttpUrl.Builder getHttpUrlBuilder(HttpUrl.Builder builder) {
AuthUtils.addDefaultAuthentication(builder, "apiKey", getApiKey());
Expand Down
2 changes: 1 addition & 1 deletion publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'com.jfrog.bintray'
def siteUrl = 'https://github.com/FabianTerhorst/ApiClient'
def gitUrl = 'https://github.com/FabianTerhorst/ApiClient.git'

version = "0.3"
version = "0.4"
group = "io.fabianterhorst"

/*install {
Expand Down

0 comments on commit 55d9e79

Please sign in to comment.