-
Notifications
You must be signed in to change notification settings - Fork 14
[CHA-649]: feature(CHA-769): add shared locations support #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f6de824
feature(CHA-769): add shared locations support
d97af3d
format
157f106
fix model
4923ae3
fix import
1453bb7
fix model
4dc3741
fix model and test
a5f4f24
fix tests
48aa8e6
format
fc18fd5
add test get active live locations from query channels
3f977d4
feat(cha-769): change url name
c041919
Merge branch 'main' into live_location
rafaelmf3 d1937ce
fix unit tests
777a0cb
clean up
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
src/main/java/io/getstream/chat/java/models/SharedLocation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/main/java/io/getstream/chat/java/services/SharedLocationService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.