Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
*.class
.idea
*.iml

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Maven
.gradle/
.idea/
.syntastic_javac_config
build/
gradle.properties
gradle/
gradlew
gradlew.bat
out/
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oracle64-10.0.2
26 changes: 0 additions & 26 deletions .travis/publish.sh

This file was deleted.

9 changes: 0 additions & 9 deletions .travis/settings.xml

This file was deleted.

25 changes: 2 additions & 23 deletions LICENSE → LICENCE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2016-2017 Stream.io Inc, and individual contributors.
Copyright (c) 2016-2018 Stream.io Inc, and individual contributors.

All rights reserved.

Expand All @@ -24,25 +24,4 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

This software incorporates additional Open Source components. You can find the source code of these
open source projects along with license information below.

Base64.java:

https://github.com/android/platform_frameworks_base/blob/master/core/java/android/util/Base64.java

Copyright (C) 2010 The Android 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.
POSSIBILITY OF SUCH DAMAGE.
149 changes: 15 additions & 134 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,25 @@
stream-java
===========
[![Build Status](https://travis-ci.org/GetStream/stream-java.svg?branch=master)](https://travis-ci.org/GetStream/stream-java)

[stream-java](https://github.com/GetStream/stream-java) is a Java client for [Stream](https://getstream.io/).

You can sign up for a Stream account at https://getstream.io/get_started.

The Stream's Java client come in two different flavours, you should decide which one to drag into your project.
Those two implementations differ according to the underlying library used to handle HTTP connections:

- *stream-repo-apache* uses Apache HttpClient and we recommend it for backend applications. Apache HttpClient is a mature, reliable and rock-solid HTTP library.
- *stream-repo-okhttp* uses Square's OkHttp which is lightweight, powerful and mobile-oriented HTTP library. We recommend it for mobile application.

### Installation

If you decide to go for the *Apache HttpClient* implementation, add the following dependency to your pom.xml:

```xml
<dependency>
<groupId>io.getstream.client</groupId>
<artifactId>stream-repo-apache</artifactId>
<version>2.1.3</version>
</dependency>
```

or in your build.gradle:

```gradle
compile 'io.getstream.client:stream-repo-apache:2.1.3'
```

Instead, if you opted for the *OkHttp* implementation please add it to your pom.xml
Add the following dependency to your pom.xml:

```xml
<dependency>
<groupId>io.getstream.client</groupId>
<artifactId>stream-repo-okhttp</artifactId>
<version>2.1.3</version>
<artifactId>stream-java</artifactId>
<version>3.0.0</version>
</dependency>
```

or in your build.gradle:

```gradle
compile 'io.getstream.client:stream-repo-okhttp:2.1.3'
compile 'io.getstream.client:stream-java:3.0.0'
```

In case you want to download the artifact and put it manually into your project,
Expand All @@ -55,127 +31,32 @@ Snapshots of the development version are available in [Sonatype](https://oss.son

This API Client project requires Java SE 8.

See the [Travis configuration](.travis.yml) for details of how it is built, tested and packaged.

### Full documentation

Documentation for this Java client are available at the [Stream website](https://getstream.io/docs/?language=java).

### Usage

```java
/**
* Instantiate a new client to connect to us east API endpoint
* Find your API keys here https://getstream.io/dashboard/
**/

StreamClient streamClient = new StreamClientImpl(new ClientConfiguration(), "<API_KEY>", "<API_SECRET>");
```

#### Create a new Feed

```java
/* Instantiate a feed object */
Feed feed = streamClient.newFeed("user", "1");
```

#### Working with Activities

```java
/* Create an activity service */
FlatActivityServiceImpl<SimpleActivity> flatActivityService = feed.newFlatActivityService(SimpleActivity.class);

/* Get activities from 5 to 10 (using offset pagination) */
FeedFilter filter = new FeedFilter.Builder().withLimit(5).withOffset(5).build();
List<SimpleActivity> activities = flatActivityService.getActivities(filter).getResults();

/* Filter on an id less than the given UUID */
aid = "e561de8f-00f1-11e4-b400-0cc47a024be0";
FeedFilter filter = new FeedFilter.Builder().withIdLowerThan(aid).withLimit(5).build();
List<SimpleActivity> activities = flatActivityService.getActivities(filter).getResults();
For examples have a look [here](https://github.com/GetStream/stream-java/tree/master/example/Example.java).

/* Create a new activity */
SimpleActivity activity = new SimpleActivity();
activity.setActor("user:1");
activity.setObject("tweet:1");
activity.setVerb("tweet");
activity.setForeignId("tweet:1");
SimpleActivity response = flatActivityService.addActivity(activity);

/* Remove an activity by its id */
feed.deleteActivity("e561de8f-00f1-11e4-b400-0cc47a024be0");

/* Remove activities by their foreign_id */
feed.deleteActivityByForeignId("tweet:1");
```

In case you want to add a single activity to multiple feeds, you can use the batch feature _addToMany_:

```java
/* Batch adding activities to many feeds */
flatActivityService.addActivityToMany(ImmutableList.<String>of("user:1", "user:2").asList(), myActivity);
```

The API client allows you to send activities with custom field as well, you can find a
complete example [here](https://github.com/GetStream/stream-java/blob/master/stream-repo-apache/src/test/java/io/getstream/client/example/mixtype/MixedType.java)

#### Follow and Unfollow

```java
/* Follow another feed */
feed.follow(flat", "42");

/* Stop following another feed */
feed.unfollow(flat", "42");

/* Retrieve first 10 followers of a feed */
FeedFilter filter = new FeedFilter.Builder().withLimit(10).build();
List<FeedFollow> followingPaged = feed.getFollowing(filter);

/* Retrieve the first 10 followed feeds */
FeedFilter filter = new FeedFilter.Builder().withLimit(10).build();
List<FeedFollow> followingPaged = feed.getFollowing(filter);
```

In case you want to send to Stream a long list of following relationships you can use the batch feature _followMany_:

```java
/* Batch following many feeds */
FollowMany followMany = new FollowMany.Builder()
.add("user:1", "user:2")
.add("user:1", "user:3")
.add("user:1", "user:4")
.add("user:2", "user:3")
.build();
feed.followMany(followMany);

```

#### Client token

In order to generate a token for client side usage (e.g. JS client), you can use the following code:

```java
/* Generating tokens for client side usage */
String token = feed.getToken();
```
Docs are available on [GetStream.io](http://getstream.io/docs/).

#### Further references
Javadocs are available [here](https://getstream.github.io/stream-java/).

For more examples have a look [here](https://github.com/GetStream/stream-java/tree/master/stream-repo-apache/src/test/java/io/getstream/client/apache/example).
### Building & Testing

Docs are available on [GetStream.io](http://getstream.io/docs/).
Run `gradle wrapper --gradle-version 5.0` to generate gradle wrapper files

Javadocs are available [here](https://getstream.github.io/stream-java/).
Run `gradle test` to execute integration tests

### Credits & Contributors

This project was originally contributed by [Alessandro Pieri](sirio7g), prior to him joining Stream as an employee.
Project is maintained by [Max Klyga](nekuromento).

This project was originally contributed by [Alessandro Pieri](sirio7g).

We continue to welcome pull requests from community members.

### Copyright and License Information

Copyright (c) 2016-2017 Stream.io Inc, and individual contributors. All rights reserved.
Copyright (c) 2016-2018 Stream.io Inc, and individual contributors. All rights reserved.

See the file "LICENSE" for information on the history of this software, terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.
See the file "LICENSE" for information on the history of this software, terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.
Loading