Skip to content

Commit e5d3bb1

Browse files
author
Max Klyga
committed
Final touches before release
1 parent 667ae59 commit e5d3bb1

44 files changed

Lines changed: 392 additions & 104 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group 'io.getstream.client'
12-
version = '3.0.0-BETA2'
12+
version = '3.0.0-RC1'
1313

1414
dependencies {
1515
testCompile 'org.junit.jupiter:junit-jupiter-api:5.3.1'
Lines changed: 100 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
import io.getstream.core.LookupKind;
1010
import io.getstream.core.Region;
1111
import io.getstream.core.models.*;
12-
import io.getstream.core.options.ActivityMarker;
13-
import io.getstream.core.options.EnrichmentFlags;
14-
import io.getstream.core.options.Filter;
15-
import io.getstream.core.options.Pagination;
12+
import io.getstream.core.options.*;
1613

14+
import java.io.File;
15+
import java.net.URL;
1716
import java.time.LocalDateTime;
1817
import java.util.Date;
1918
import java.util.List;
@@ -22,7 +21,6 @@
2221
import static io.getstream.core.utils.Enrichment.createCollectionReference;
2322
import static io.getstream.core.utils.Enrichment.createUserReference;
2423

25-
//TODO: move this to an appropriate place
2624
class Example {
2725
private static final String apiKey = "gp6e8sxxzud6";
2826
private static final String secret = "7j7exnksc4nxy399fdxvjqyqsqdahax3nfgtp27pumpc7sfm9um688pzpxjpjbf2";
@@ -528,9 +526,103 @@ public static void main(String[] args) throws Exception {
528526

529527
/* -------------------------------------------------------- */
530528

531-
client.user("123").update(new Data("")
532-
.set("name", "John Doe")
529+
client.user("123").update(new Data()
530+
.set("name", "Jane Doe")
533531
.set("occupation", "Software Engineer")
534-
.set("gender", "male"));
532+
.set("gender", "female"));
533+
534+
/* -------------------------------------------------------- */
535+
536+
// Read the personalization feed for a given user
537+
client.personalization().get("personalized_feed", new ImmutableMap.Builder<String, Object>()
538+
.put("user_id", 123)
539+
.put("feed_slug", "timeline")
540+
.build());
541+
542+
// Our data science team will typically tell you which endpoint to use
543+
client.personalization().get("discovery_feed", new ImmutableMap.Builder<String, Object>()
544+
.put("user_id", 123)
545+
.put("source_feed_slug", "timeline")
546+
.put("target_feed_slug", "user")
547+
.build());
548+
549+
/* -------------------------------------------------------- */
550+
551+
client.analytics().trackEngagement(Engagement.builder()
552+
.feedID("user:thierry")
553+
.content(new Content("message:34349698")
554+
.set("verb", "share")
555+
.set("actor", ImmutableMap.of("1", "user1")))
556+
.boost(2)
557+
.location("profile_page")
558+
.position(3)
559+
.build());
560+
561+
/* -------------------------------------------------------- */
562+
563+
client.analytics().trackImpression(Impression.builder()
564+
.contentList(new Content("tweet:34349698")
565+
.set("verb", "share")
566+
.set("actor", ImmutableMap.of("1", "user1")),
567+
new Content("tweet:34349699"),
568+
new Content("tweet:34349700"))
569+
.feedID("flat:tommaso")
570+
.location("android-app")
571+
.build());
572+
573+
/* -------------------------------------------------------- */
574+
575+
// the URL to direct to
576+
URL targetURL = new URL("http://mysite.com/detail");
577+
578+
// track the impressions and a click
579+
List<Impression> impressions = Lists.newArrayList(Impression.builder()
580+
.contentList(new Content("tweet:1"),
581+
new Content("tweet:2"),
582+
new Content("tweet:3"))
583+
.userData(new UserData("tommaso", null))
584+
.location("email")
585+
.feedID("user:global")
586+
.build());
587+
List<Engagement> engagements = Lists.newArrayList(Engagement.builder()
588+
.content(new Content("tweet:2"))
589+
.label("click")
590+
.position(1)
591+
.userData(new UserData("tommaso", null))
592+
.location("email")
593+
.feedID("user:global")
594+
.build());
595+
596+
// when the user opens the tracking URL in their browser gets redirected to the target URL
597+
// the events are added to our analytics platform
598+
URL trackingURL = client.analytics().createRedirectURL(targetURL, impressions, engagements);
599+
600+
/* -------------------------------------------------------- */
601+
602+
File image = new File("...");
603+
URL imageURL = client.images().upload(image).join();
604+
605+
File file = new File("...");
606+
URL fileURL = client.files().upload(file).join();
607+
608+
/* -------------------------------------------------------- */
609+
610+
// deleting an image using the url returned by the APIs
611+
client.images().delete(imageURL);
612+
613+
// deleting a file using the url returned by the APIs
614+
client.files().delete(fileURL);
615+
616+
/* -------------------------------------------------------- */
617+
618+
// create a 50x50 thumbnail and crop from center
619+
client.images().process(imageURL, new Resize(50, 50, Resize.Type.CROP));
620+
621+
// create a 50x50 thumbnail using clipping (keeps aspect ratio)
622+
client.images().process(imageURL, new Resize(50, 50, Resize.Type.CLIP));
623+
624+
/* -------------------------------------------------------- */
625+
626+
OGData urlPreview = client.openGraph(new URL("http://www.imdb.com/title/tt0117500/")).join();
535627
}
536628
}

‎src/main/java/io/getstream/client/FileStorageClient.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import static io.getstream.core.utils.Auth.buildFilesToken;
1313

14-
public class FileStorageClient {
14+
public final class FileStorageClient {
1515
private final String secret;
1616
private final StreamFiles files;
1717

‎src/main/java/io/getstream/client/ImageStorageClient.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import static io.getstream.core.utils.Auth.buildFilesToken;
1515

16-
public class ImageStorageClient {
16+
public final class ImageStorageClient {
1717
private final String secret;
1818
private final StreamImages images;
1919

‎src/main/java/io/getstream/client/ReactionsClient.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,22 @@ public CompletableFuture<Reaction> add(String userID, Reaction reaction, FeedID.
7272
}
7373

7474
public CompletableFuture<Reaction> addChild(String userID, String kind, String parentID, Iterable<FeedID> targetFeeds) throws StreamException {
75-
Reaction child = Reaction.builder().kind(kind).parentID(parentID).build();
75+
Reaction child = Reaction.builder().kind(kind).parent(parentID).build();
7676
return add(userID, child, targetFeeds);
7777
}
7878

79-
public CompletableFuture<Reaction> addChild(String userID, String kind, String parentID, Iterable<FeedID> targetFeed, FeedID... targetFeeds) throws StreamException {
80-
Reaction child = Reaction.builder().kind(kind).parentID(parentID).build();
79+
public CompletableFuture<Reaction> addChild(String userID, String kind, String parentID, FeedID... targetFeeds) throws StreamException {
80+
Reaction child = Reaction.builder().kind(kind).parent(parentID).build();
8181
return add(userID, child, targetFeeds);
8282
}
8383

8484
public CompletableFuture<Reaction> addChild(String userID, String parentID, Reaction reaction, Iterable<FeedID> targetFeeds) throws StreamException {
85-
Reaction child = Reaction.builder().fromReaction(reaction).parentID(parentID).build();
85+
Reaction child = Reaction.builder().fromReaction(reaction).parent(parentID).build();
8686
return add(userID, child, targetFeeds);
8787
}
8888

8989
public CompletableFuture<Reaction> addChild(String userID, String parentID, Reaction reaction, FeedID... targetFeeds) throws StreamException {
90-
Reaction child = Reaction.builder().fromReaction(reaction).parentID(parentID).build();
90+
Reaction child = Reaction.builder().fromReaction(reaction).parent(parentID).build();
9191
return add(userID, child, targetFeeds);
9292
}
9393

‎src/main/java/io/getstream/client/User.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import static io.getstream.core.utils.Serialization.deserialize;
1414
import static io.getstream.core.utils.Serialization.deserializeError;
1515

16-
public class User {
16+
public final class User {
1717
private final Client client;
1818
private final String id;
1919

‎src/main/java/io/getstream/cloud/CloudAnalyticsClient.java‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,9 @@
66
import io.getstream.core.http.Token;
77
import io.getstream.core.models.Engagement;
88
import io.getstream.core.models.Impression;
9-
import io.getstream.core.utils.Auth.TokenAction;
109

11-
import java.net.URL;
1210
import java.util.concurrent.CompletableFuture;
1311

14-
import static io.getstream.core.utils.Auth.buildAnalyticsRedirectToken;
15-
import static io.getstream.core.utils.Auth.buildAnalyticsToken;
16-
1712
public final class CloudAnalyticsClient {
1813
private final Token token;
1914
private final StreamAnalytics analytics;

‎src/main/java/io/getstream/cloud/CloudClient.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import static com.google.common.base.Preconditions.checkArgument;
2121
import static com.google.common.base.Preconditions.checkNotNull;
2222

23-
public class CloudClient {
23+
public final class CloudClient {
2424
private final Token token;
2525
private final String userID;
2626
private final Stream stream;

‎src/main/java/io/getstream/cloud/CloudCollectionsClient.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import static io.getstream.core.utils.Serialization.convert;
1313

14-
public class CloudCollectionsClient {
14+
public final class CloudCollectionsClient {
1515
private final Token token;
1616
private final String userID;
1717
private final StreamCollections collections;

‎src/main/java/io/getstream/cloud/CloudFileStorageClient.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.net.URL;
99
import java.util.concurrent.CompletableFuture;
1010

11-
public class CloudFileStorageClient {
11+
public final class CloudFileStorageClient {
1212
private final Token token;
1313
private final StreamFiles files;
1414

0 commit comments

Comments
 (0)