Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #64 from sygic-travel/STA-445-prepare-release-0.3.…
Browse files Browse the repository at this point in the history
…0-beta

STA 445 prepare release 0.3.0-beta
  • Loading branch information
Michal Murín authored Jun 21, 2017
2 parents 316e904 + 2ba35b2 commit 034bcc9
Showing 1 changed file with 46 additions and 6 deletions.
52 changes: 46 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Sygic Travel Android SDK is a framework for embedding a rich set of Sygic Travel data within your
application. It gives you an access to millions of places covering the whole world.

For further details see [Full SDK documentation](http://docs.sygictravelapi.com/android-sdk/master).
For further details see [Full SDK documentation](http://docs.sygictravelapi.com/android-sdk/0.3.0-beta).

## Requirements

Expand Down Expand Up @@ -36,7 +36,7 @@ repositories {
Add dependency to your application module `build.gradle` file:
```gradle
dependencies {
compile ('com.sygic.travel:sdk:0.2.0-beta@aar'){
compile ('com.sygic.travel:sdk:0.3.0-beta@aar'){
transitive=true;
}
}
Expand All @@ -57,6 +57,7 @@ dependencies {

*API key* must be provided, otherwise every `StSDK` get method call will result in an error.

**Java/Kotlin:**
```java
// initialize SDK - in onCreate() method of your Application class or a launcher Activity
// Insert real API key instead of YOUR_API_KEY in the line below. The API key can be
Expand All @@ -69,7 +70,7 @@ To obtain your *API key* contact us at https://travel.sygic.com/b2b/api-key.
## Usage Introduction

This example shows how to use the SDK to fetch a representative set of data. To define a set of places
you need to create a [placeQuery](http://docs.sygictravelapi.com/android-sdk/0.2.0-beta/com/sygic/travel/sdk/model/placeQuery/Query.html)
you need to create a [placeQuery](http://docs.sygictravelapi.com/android-sdk/0.3.0-beta/com/sygic/travel/sdk/model/placeQuery/Query.html)
which describes the places which will be fetched - see
[API documentation](http://docs.sygictravelapi.com/0.2/#section-places).

Expand All @@ -80,6 +81,7 @@ Let's define a set of places we want:
- marked with category _Sightseeing_
- only the _Top 10_ of them

**Java:**
```java
// Create placeQuery to get top 10 sightseeings in London
PlaceQuery placeQuery = new PlaceQuery();
Expand All @@ -105,8 +107,34 @@ Callback<List<Place>> placesCallback = new Callback<List<Place>>() {
StSDK.getInstance().getPlaces(placeQuery, placesCallback);
```

**Kotlin:**
```kotlin
// Create placeQuery to get top 10 sightseeings in London
val placeQuery = PlacesQuery()
placeQuery.levels = listOf("poi")
placeQuery.categories = listOf("sightseeing")
placeQuery.parents = listOf("city:1")
placeQuery.limit = 10

// Create Callback
private val placesCallback = object: Callback<List<Place>?>() {
override fun onSuccess(data: List<Place>?) {
// success
}

override fun onFailure(t: Throwable) {
// something went wrong
}
}

// Perform placeQuery
StSDK.getInstance().getPlaces(query, placesCallback)
```

Since the SDK uses RxAndroid it is important to unsubscribe an observable, when an activity comes
to background:
to background.

**Java:**
```java
@Override
protected void onPause() {
Expand All @@ -117,18 +145,30 @@ protected void onPause() {
}
```

**Kotlin:**
```kotlin
override fun onPause() {
super.onPause()

// Observables need to be unsubscribed, when the activity comes to background
StSDK.getInstance().unsubscribeObservable()
}
```

## Basic Classes
For more details check our [documentation](http://docs.sygictravelapi.com/android-sdk/0.2.0-beta).
For more details check our [documentation](http://docs.sygictravelapi.com/android-sdk/0.3.0-beta).

Class | Description
:-------------------|:---------------------
**`StSDK`** | Singleton instance for fetching data
**`Callback<T>`** | Callback class with `onSuccess(T data)` and `onFailure(Throwable t)` methods. `T` is a generic type.
**`Query`** | Entity used when querying for `Places`
**`PlaceQuery`** | Entity used when querying for `Places`
**`Place`** | Basic `Place` entity
**`Detail`** | Detailed object including additional `Place` properties, extends `Place`
**`Medium`** | Basic `Medium` entity
**`Reference`** | External `Reference` link
**`TourQuery`** | Entity used when querying for `Tours`
**`Tour`** | Basic `Tour` entity

## License
This SDK is available under the [MIT License](http://www.opensource.org/licenses/mit-license.php).

0 comments on commit 034bcc9

Please sign in to comment.