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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies {
testImplementation 'org.apache.commons:commons-lang3:3.12.0'
compileOnly 'org.projectlombok:lombok:1.18.32'
annotationProcessor 'org.projectlombok:lombok:1.18.32'
compileOnly 'org.jetbrains:annotations:24.1.0'

testCompileOnly 'org.projectlombok:lombok:1.18.32'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.32'
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/io/getstream/chat/java/models/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,10 @@ public static class ConfigOverridesRequestObject {
@Nullable
@JsonProperty("user_message_reminders")
private Boolean userMessageReminders;

@Nullable
@JsonProperty("shared_locations")
private Boolean sharedLocations;
}

@Builder
Expand Down Expand Up @@ -1234,6 +1238,10 @@ public static class ChannelGetResponse extends StreamResponseObject {
@Nullable
@JsonProperty("hide_messages_before")
private Date hideMessagesBefore;

@Nullable
@JsonProperty("active_live_locations")
private List<SharedLocation> activeLiveLocations;
}

@Data
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/io/getstream/chat/java/models/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ public class Message {
@JsonProperty("pinned_at")
private Date pinnedAt;

@Nullable
@JsonProperty("shared_location")
private SharedLocation sharedLocation;

@NotNull @JsonIgnore private Map<String, Object> additionalFields = new HashMap<>();

@JsonAnyGetter
Expand Down Expand Up @@ -491,6 +495,16 @@ public static class MessageRequestObject {
@JsonProperty("pinned_at")
private Date pinnedAt;

@Nullable
@JsonProperty("shared_location")
private SharedLocation sharedLocation;

@NotNull
public MessageRequestObject setSharedLocation(@Nullable SharedLocation sharedLocation) {
this.sharedLocation = sharedLocation;
return this;
}

@Singular @Nullable @JsonIgnore private Map<String, Object> additionalFields;

@JsonAnyGetter
Expand Down
168 changes: 168 additions & 0 deletions src/main/java/io/getstream/chat/java/models/SharedLocation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
package io.getstream.chat.java.models;

import com.fasterxml.jackson.annotation.*;
import io.getstream.chat.java.models.framework.StreamRequest;
import io.getstream.chat.java.models.framework.StreamResponseObject;
import io.getstream.chat.java.services.SharedLocationService;
import io.getstream.chat.java.services.framework.Client;
import java.util.Date;
import java.util.List;
import lombok.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import retrofit2.Call;

@Data
@NoArgsConstructor
public class SharedLocation {
@JsonProperty("channel_cid")
private String channelCid;

@JsonProperty("created_at")
private Date createdAt;

@JsonProperty("created_by_device_id")
private String createdByDeviceId;

@JsonProperty("end_at")
private Date endAt;

private Double latitude;
private Double longitude;

@JsonProperty("message_id")
private String messageId;

@JsonProperty("updated_at")
private Date updatedAt;

@JsonProperty("user_id")
private String userId;

@Data
@NoArgsConstructor
public static class SharedLocationRequest {
@JsonProperty("message_id")
private String messageId;

@JsonProperty("created_by_device_id")
private String createdByDeviceId;

@Nullable
@JsonProperty("end_at")
private String endAt;

@Nullable private Double latitude;

@Nullable private Double longitude;

@JsonProperty("user_id")
private String userId;
}

@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public static class SharedLocationResponse extends StreamResponseObject {
@JsonProperty("created_by_device_id")
private String createdByDeviceId;

@JsonProperty("end_at")
private String endAt;

private Double latitude;
private Double longitude;
}

@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public static class ActiveLiveLocationsResponse extends StreamResponseObject {
@JsonProperty("active_live_locations")
private List<SharedLocation> activeLiveLocations;
}

public static class UpdateLocationRequestData {
@NotNull
@JsonProperty("request")
private SharedLocationRequest request;

public UpdateLocationRequestData() {}

public UpdateLocationRequestData(SharedLocationRequest request) {
this.request = request;
}

public SharedLocationRequest getRequest() {
return request;
}

public void setRequest(SharedLocationRequest request) {
this.request = request;
}

public static class UpdateLocationRequest extends StreamRequest<SharedLocationResponse> {
private SharedLocationRequest request;
private String userId;

public UpdateLocationRequest() {}

public UpdateLocationRequest(SharedLocationRequest request) {
this.request = request;
}

public UpdateLocationRequest request(SharedLocationRequest request) {
this.request = request;
return this;
}

public UpdateLocationRequest userId(String userId) {
this.userId = userId;
return this;
}

@Override
protected Call<SharedLocationResponse> generateCall(Client client) {
return client.create(SharedLocationService.class).updateLiveLocation(userId, request);
}
}
}

public static class GetLocationsRequestData {
public static class GetLocationsRequest extends StreamRequest<ActiveLiveLocationsResponse> {
private String userId;

public GetLocationsRequest() {}

public GetLocationsRequest userId(String userId) {
this.userId = userId;
return this;
}

@Override
protected Call<ActiveLiveLocationsResponse> generateCall(Client client) {
return client.create(SharedLocationService.class).getLiveLocations(userId);
}
}
}

/**
* Creates an update location request
*
* @return the created request
*/
@NotNull
public static UpdateLocationRequestData.UpdateLocationRequest updateLocation() {
return new UpdateLocationRequestData.UpdateLocationRequest();
}

/**
* Creates a get locations request
*
* @return the created request
*/
@NotNull
public static GetLocationsRequestData.GetLocationsRequest getLocations() {
return new GetLocationsRequestData.GetLocationsRequest();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.getstream.chat.java.services;

import io.getstream.chat.java.models.SharedLocation;
import org.jetbrains.annotations.NotNull;
import retrofit2.Call;
import retrofit2.http.*;

public interface SharedLocationService {
@GET("users/live_locations")
Call<SharedLocation.ActiveLiveLocationsResponse> getLiveLocations(
@NotNull @Query("user_id") String userId);

@PUT("users/live_locations")
Call<SharedLocation.SharedLocationResponse> updateLiveLocation(
@NotNull @Query("user_id") String userId,
@NotNull @Body SharedLocation.SharedLocationRequest sharedLocationRequest);
}
Loading