NcApi.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /*
  2. *
  3. * Nextcloud Talk application
  4. *
  5. * @author Mario Danic
  6. * Copyright (C) 2017 Mario Danic (mario@lovelyhq.com)
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. package com.nextcloud.talk.api;
  22. import android.support.annotation.Nullable;
  23. import com.nextcloud.talk.models.json.call.CallOverall;
  24. import com.nextcloud.talk.models.json.capabilities.CapabilitiesOverall;
  25. import com.nextcloud.talk.models.json.chat.ChatOverall;
  26. import com.nextcloud.talk.models.json.generic.GenericOverall;
  27. import com.nextcloud.talk.models.json.generic.Status;
  28. import com.nextcloud.talk.models.json.mention.MentionOverall;
  29. import com.nextcloud.talk.models.json.participants.AddParticipantOverall;
  30. import com.nextcloud.talk.models.json.participants.ParticipantsOverall;
  31. import com.nextcloud.talk.models.json.push.PushRegistrationOverall;
  32. import com.nextcloud.talk.models.json.rooms.RoomOverall;
  33. import com.nextcloud.talk.models.json.rooms.RoomsOverall;
  34. import com.nextcloud.talk.models.json.sharees.ShareesOverall;
  35. import com.nextcloud.talk.models.json.signaling.SignalingOverall;
  36. import com.nextcloud.talk.models.json.signaling.settings.SignalingSettingsOverall;
  37. import com.nextcloud.talk.models.json.userprofile.UserProfileOverall;
  38. import java.util.Map;
  39. import io.reactivex.Observable;
  40. import retrofit2.Response;
  41. import retrofit2.http.DELETE;
  42. import retrofit2.http.Field;
  43. import retrofit2.http.FieldMap;
  44. import retrofit2.http.FormUrlEncoded;
  45. import retrofit2.http.GET;
  46. import retrofit2.http.Header;
  47. import retrofit2.http.POST;
  48. import retrofit2.http.PUT;
  49. import retrofit2.http.Query;
  50. import retrofit2.http.QueryMap;
  51. import retrofit2.http.Url;
  52. public interface NcApi {
  53. /*
  54. QueryMap items are as follows:
  55. - "format" : "json"
  56. - "search" : ""
  57. - "perPage" : "200"
  58. - "itemType" : "call"
  59. Server URL is: baseUrl + ocsApiVersion + /apps/files_sharing/api/v1/sharees
  60. */
  61. @GET
  62. Observable<Response<ShareesOverall>> getContactsWithSearchParam(@Header("Authorization") String authorization, @Url String url,
  63. @QueryMap Map<String, Object> options);
  64. /*
  65. Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room
  66. */
  67. @GET
  68. Observable<RoomsOverall> getRooms(@Header("Authorization") String authorization, @Url String url);
  69. /*
  70. Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room/roomToken
  71. */
  72. @GET
  73. Observable<RoomOverall> getRoom(@Header("Authorization") String authorization, @Url String url);
  74. /*
  75. QueryMap items are as follows:
  76. - "roomType" : ""
  77. - "invite" : ""
  78. Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room
  79. */
  80. @POST
  81. Observable<RoomOverall> createRoom(@Header("Authorization") String authorization, @Url String url,
  82. @QueryMap Map<String, String> options);
  83. /*
  84. QueryMap items are as follows:
  85. - "roomName" : "newName"
  86. Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room/roomToken
  87. */
  88. @FormUrlEncoded
  89. @PUT
  90. Observable<GenericOverall> renameRoom(@Header("Authorization") String authorization, @Url String url,
  91. @Field("roomName") String roomName);
  92. /*
  93. QueryMap items are as follows:
  94. - "newParticipant" : "user"
  95. Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room/roomToken/participants
  96. */
  97. @POST
  98. Observable<AddParticipantOverall> addParticipant(@Header("Authorization") String authorization, @Url String url,
  99. @QueryMap Map<String, String> options);
  100. /*
  101. Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room/roomToken/participants/self
  102. */
  103. @DELETE
  104. Observable<GenericOverall> removeSelfFromRoom(@Header("Authorization") String authorization, @Url String url);
  105. /*
  106. Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room/roomToken/public
  107. */
  108. @POST
  109. Observable<GenericOverall> makeRoomPublic(@Header("Authorization") String authorization, @Url String url);
  110. /*
  111. Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room/roomToken/public
  112. */
  113. @DELETE
  114. Observable<GenericOverall> makeRoomPrivate(@Header("Authorization") String authorization, @Url String url);
  115. @DELETE
  116. Observable<GenericOverall> deleteRoom(@Header("Authorization") String authorization, @Url String url);
  117. /*
  118. Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /call/callToken
  119. */
  120. @GET
  121. Observable<ParticipantsOverall> getPeersForCall(@Header("Authorization") String authorization, @Url String url);
  122. @FormUrlEncoded
  123. @POST
  124. Observable<CallOverall> joinRoom(@Nullable @Header("Authorization") String authorization, @Url String url,
  125. @Nullable @Field("password") String password);
  126. @DELETE
  127. Observable<GenericOverall> leaveRoom(@Nullable @Header("Authorization") String authorization, @Url String url);
  128. /*
  129. Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /call/callToken
  130. */
  131. @POST
  132. Observable<GenericOverall> joinCall(@Nullable @Header("Authorization") String authorization, @Url String url);
  133. /*
  134. Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /call/callToken
  135. */
  136. @DELETE
  137. Observable<GenericOverall> leaveCall(@Nullable @Header("Authorization") String authorization, @Url String url);
  138. /*
  139. Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /call/callToken/ping
  140. */
  141. @POST
  142. Observable<GenericOverall> pingCall(@Nullable @Header("Authorization") String authorization, @Url String url);
  143. @GET
  144. Observable<SignalingSettingsOverall> getSignalingSettings(@Nullable @Header("Authorization") String authorization,
  145. @Url String url);
  146. /*
  147. QueryMap items are as follows:
  148. - "messages" : "message"
  149. Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /signaling
  150. */
  151. @FormUrlEncoded
  152. @POST
  153. Observable<SignalingOverall> sendSignalingMessages(@Nullable @Header("Authorization") String authorization, @Url String url,
  154. @Field("messages") String messages);
  155. /*
  156. Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /signaling
  157. */
  158. @GET
  159. Observable<SignalingOverall> pullSignalingMessages(@Nullable @Header("Authorization") String authorization, @Url
  160. String
  161. url);
  162. /*
  163. QueryMap items are as follows:
  164. - "format" : "json"
  165. Server URL is: baseUrl + ocsApiVersion + "/cloud/user"
  166. */
  167. @GET
  168. Observable<UserProfileOverall> getUserProfile(@Header("Authorization") String authorization, @Url String url);
  169. /*
  170. Server URL is: baseUrl + /status.php
  171. */
  172. @GET
  173. Observable<Status> getServerStatus(@Url String url);
  174. /*
  175. QueryMap items are as follows:
  176. - "format" : "json"
  177. - "pushTokenHash" : ""
  178. - "devicePublicKey" : ""
  179. - "proxyServer" : ""
  180. Server URL is: baseUrl + ocsApiVersion + "/apps/notifications/api/v2/push
  181. */
  182. @POST
  183. Observable<PushRegistrationOverall> registerDeviceForNotificationsWithNextcloud(@Header("Authorization")
  184. String authorization,
  185. @Url String url,
  186. @QueryMap Map<String,
  187. String> options);
  188. @DELETE
  189. Observable<GenericOverall> unregisterDeviceForNotificationsWithNextcloud(@Header("Authorization")
  190. String authorization,
  191. @Url String url);
  192. @FormUrlEncoded
  193. @POST
  194. Observable<Void> registerDeviceForNotificationsWithProxy(@Header("Authorization") String authorization,
  195. @Url String url,
  196. @FieldMap Map<String, String> fields);
  197. /*
  198. QueryMap items are as follows:
  199. - "deviceIdentifier": "{{deviceIdentifier}}",
  200. - "deviceIdentifierSignature": "{{signature}}",
  201. - "userPublicKey": "{{userPublicKey}}"
  202. */
  203. @DELETE
  204. Observable<Void> unregisterDeviceForNotificationsWithProxy(@Header("Authorization") String authorization,
  205. @Url String url,
  206. @QueryMap Map<String, String> fields);
  207. @FormUrlEncoded
  208. @PUT
  209. Observable<GenericOverall> setPassword(@Header("Authorization") String authorization, @Url String url,
  210. @Field("password") String password);
  211. @GET
  212. Observable<CapabilitiesOverall> getCapabilities(@Header("Authorization") String authorization, @Url String url);
  213. /*
  214. QueryMap items are as follows:
  215. - "lookIntoFuture": int (0 or 1),
  216. - "limit" : int, range 100-200,
  217. - "timeout": used with look into future, 30 default, 60 at most
  218. - "lastKnownMessageId", int, use one from X-Chat-Last-Given
  219. */
  220. @GET
  221. Observable<Response<ChatOverall>> pullChatMessages(@Header("Authorization") String authorization, @Url String url,
  222. @QueryMap Map<String, Integer> fields);
  223. /*
  224. Fieldmap items are as follows:
  225. - "message": ,
  226. - "actorDisplayName"
  227. */
  228. @FormUrlEncoded
  229. @POST
  230. Observable<GenericOverall> sendChatMessage(@Header("Authorization") String authorization, @Url String url,
  231. @Field("message") CharSequence message,
  232. @Field("actorDisplayName") String actorDisplayName);
  233. @GET
  234. Observable<MentionOverall> getMentionAutocompleteSuggestions(@Header("Authorization") String authorization,
  235. @Url String url, @Query("search") String query,
  236. @Nullable @Query("limit") Integer limit);
  237. }