-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from sbxcloud/annotationlib
with chat, push, and changepassword
- Loading branch information
Showing
12 changed files
with
822 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 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
91 changes: 91 additions & 0 deletions
91
app/src/main/java/com/sbxcloud/android/sbxcloudsdk/message/ChannelHelper.java
This file contains 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,91 @@ | ||
package com.sbxcloud.android.sbxcloudsdk.message; | ||
|
||
import com.sbxcloud.android.sbxcloudsdk.auth.SbxAuth; | ||
import com.sbxcloud.android.sbxcloudsdk.query.SbxQueryBuilder; | ||
import com.sbxcloud.android.sbxcloudsdk.util.SbxJsonModeler; | ||
import com.sbxcloud.android.sbxcloudsdk.util.SbxUrlComposer; | ||
import com.sbxcloud.android.sbxcloudsdk.util.UrlHelper; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
|
||
/** | ||
* Created by lgguzman on 24/03/17. | ||
*/ | ||
|
||
public class ChannelHelper { | ||
|
||
public static SbxUrlComposer getUrlCreateChannel(String channelName) throws Exception{ | ||
String appKey = SbxAuth.getDefaultSbxAuth().getAppKey(); | ||
String token = SbxAuth.getDefaultSbxAuth().getToken(); | ||
SbxUrlComposer sbxUrlComposer = new SbxUrlComposer( | ||
UrlHelper.MESSAGE_CHANNEL | ||
, UrlHelper.POST | ||
); | ||
JSONObject jsonObject = new JSONObject(); | ||
jsonObject.put("name", channelName); | ||
return sbxUrlComposer | ||
.addHeader(UrlHelper.HEADER_KEY_APP_KEY, appKey) | ||
// .addHeader(UrlHelper.HEADER_KEY_ENCODING, UrlHelper.HEADER_GZIP) | ||
// .addHeader(UrlHelper.HEADER_KEY_CONTENT_TYPE, UrlHelper.HEADER_JSON) | ||
.addHeader(UrlHelper.HEADER_KEY_AUTORIZATION, UrlHelper.HEADER_BEARER+token) | ||
.addBody(jsonObject); | ||
} | ||
|
||
public static SbxUrlComposer getUrlAddMember(int channelId, int []idUsers) throws Exception{ | ||
String appKey = SbxAuth.getDefaultSbxAuth().getAppKey(); | ||
String token = SbxAuth.getDefaultSbxAuth().getToken(); | ||
SbxUrlComposer sbxUrlComposer = new SbxUrlComposer( | ||
UrlHelper.MESSAGE_CHANNEL_MEMBER | ||
, UrlHelper.POST | ||
); | ||
JSONObject jsonObject = new JSONObject(); | ||
JSONArray jsonArray = new JSONArray(); | ||
for (int i=0;i<idUsers.length;i++){ | ||
jsonArray.put(idUsers[i]); | ||
} | ||
jsonObject.put("channel_id", channelId); | ||
jsonObject.put("members", jsonArray); | ||
return sbxUrlComposer | ||
.addHeader(UrlHelper.HEADER_KEY_APP_KEY, appKey) | ||
// .addHeader(UrlHelper.HEADER_KEY_ENCODING, UrlHelper.HEADER_GZIP) | ||
// .addHeader(UrlHelper.HEADER_KEY_CONTENT_TYPE, UrlHelper.HEADER_JSON) | ||
.addHeader(UrlHelper.HEADER_KEY_AUTORIZATION, UrlHelper.HEADER_BEARER+token) | ||
.addBody(jsonObject); | ||
} | ||
|
||
public static SbxUrlComposer getUrlListMessage(int channelId) throws Exception{ | ||
String appKey = SbxAuth.getDefaultSbxAuth().getAppKey(); | ||
String token = SbxAuth.getDefaultSbxAuth().getToken(); | ||
SbxUrlComposer sbxUrlComposer = new SbxUrlComposer( | ||
UrlHelper.MESSAGE_LIST | ||
, UrlHelper.GET | ||
); | ||
return sbxUrlComposer | ||
.addHeader(UrlHelper.HEADER_KEY_APP_KEY, appKey) | ||
// .addHeader(UrlHelper.HEADER_KEY_ENCODING, UrlHelper.HEADER_GZIP) | ||
// .addHeader(UrlHelper.HEADER_KEY_CONTENT_TYPE, UrlHelper.HEADER_JSON) | ||
.addHeader(UrlHelper.HEADER_KEY_AUTORIZATION, UrlHelper.HEADER_BEARER+token) | ||
.setUrlParam("channel_id",channelId+""); | ||
|
||
} | ||
|
||
public static SbxUrlComposer getUrlSendMessage(int channelId, SbxJsonModeler body) throws Exception{ | ||
String appKey = SbxAuth.getDefaultSbxAuth().getAppKey(); | ||
String token = SbxAuth.getDefaultSbxAuth().getToken(); | ||
SbxUrlComposer sbxUrlComposer = new SbxUrlComposer( | ||
UrlHelper.MESSAGE_SEND | ||
, UrlHelper.POST | ||
); | ||
|
||
JSONObject jsonObject = new JSONObject(); | ||
jsonObject.put("channel_id", channelId); | ||
jsonObject.put("body", body.toJson()); | ||
return sbxUrlComposer | ||
.addHeader(UrlHelper.HEADER_KEY_APP_KEY, appKey) | ||
// .addHeader(UrlHelper.HEADER_KEY_ENCODING, UrlHelper.HEADER_GZIP) | ||
// .addHeader(UrlHelper.HEADER_KEY_CONTENT_TYPE, UrlHelper.HEADER_JSON) | ||
.addHeader(UrlHelper.HEADER_KEY_AUTORIZATION, UrlHelper.HEADER_BEARER+token) | ||
.setUrlParam("channel_id",channelId+""); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.