Skip to content

Commit

Permalink
[Problem/Solution] Minot Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Sztangierski committed Nov 6, 2016
1 parent f02c61b commit f6b6965
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 29 deletions.
26 changes: 9 additions & 17 deletions Assets/Syncano/Client/SyncanoHttpClient.cs
Expand Up @@ -478,25 +478,12 @@ private UnityWebRequest PrepareWebRequest(string url, string serializedObject, D

string ID = string.IsNullOrEmpty(id) == false ? id.ToString() : string.Empty;

if(classType.ToString().ToLower().Equals("channel"))
if(classType.IsGenericTypeDefinition)
{
sb.Append(string.Format(Constants.CHANNELS_LIST_URL, SyncanoClient.Instance.InstanceName));
}

else
{
if(classType.IsGenericTypeDefinition)
Type t = classType.GetGenericTypeDefinition();
if(t == typeof(User<>))
{
Type t = classType.GetGenericTypeDefinition();
if(t == typeof(User<>))
{
sb.Append(string.Format("/v1.1/instances/{0}/users/", SyncanoClient.Instance.InstanceName));
}

else
{
sb.Append(string.Format(Constants.OBJECTS_DETAIL_URL, SyncanoClient.Instance.InstanceName, classType.ToString(), ID));
}
sb.Append(string.Format("/v1.1/instances/{0}/users/", SyncanoClient.Instance.InstanceName));
}

else
Expand All @@ -505,6 +492,11 @@ private UnityWebRequest PrepareWebRequest(string url, string serializedObject, D
}
}

else
{
sb.Append(string.Format(Constants.OBJECTS_DETAIL_URL, SyncanoClient.Instance.InstanceName, classType.ToString(), ID));
}

url = sb.ToString();
}

Expand Down
1 change: 0 additions & 1 deletion Assets/Syncano/Data/AbstractUser.cs
Expand Up @@ -8,7 +8,6 @@
namespace Syncano.Data {
public abstract class AbstractUser<P> : SyncanoObject where P : Profile {

public const string FIELD_ID = "id";
public const string FIELD_USER_NAME = "username";
public const string FIELD_PASSWORD = "password";
public const string FIELD_USER_KEY = "user_key";
Expand Down
3 changes: 0 additions & 3 deletions Assets/Syncano/Data/Channel.cs
Expand Up @@ -10,9 +10,6 @@ public class Channel : SyncanoObject {
public const string FIELD_NAME = "name";
public const string FIELD_DESCRIPTION = "description";
public const string FIELD_TYPE = "type";
public const string FIELD_GROUP = "group";
public const string FIELD_GROUP_PERMISSIONS = "group_permissions";
public const string FIELD_OTHER_PERMISSIONS = "other_permissions";
public const string FIELD_CREATED_AT = "created_at";
public const string FIELD_UPDATED_AT = "updated_at";
public const string FIELD_CUSTOM_PUBLISH = "custom_publish";
Expand Down
3 changes: 2 additions & 1 deletion Assets/Syncano/Request/RequestBuilder.cs
Expand Up @@ -81,7 +81,8 @@ public class RequestBuilder {
/// <param name="onFailure">On failure.</param>
public Coroutine CreateChannel(Channel channel, Action<Response<Channel>> onSuccess, Action<Response<Channel>> onFailure) {
CheckCallbacks<Channel>(onSuccess, onFailure);
return SyncanoHttpClient.Instance.PostAsync<Channel>(channel, onSuccess, onFailure, UnityEngine.Networking.UnityWebRequest.kHttpVerbPOST);
string url = Constants.PRODUCTION_SERVER_URL + string.Format(Constants.CHANNELS_LIST_URL, SyncanoClient.Instance.InstanceName);
return SyncanoHttpClient.Instance.PostAsync<Channel>(channel, onSuccess, onFailure, UnityEngine.Networking.UnityWebRequest.kHttpVerbPOST, url:url);
}

public Coroutine CreateChannel(Channel channel, Action<Response<Channel>> onResponseReturned) {
Expand Down
23 changes: 16 additions & 7 deletions Assets/Syncano/SyncanoObject.cs
Expand Up @@ -12,50 +12,59 @@ namespace Syncano {
/// Class representing basic data structure for all DataObjects returned from Syncano. Every class must override it, otherwise it won't deserialize properly.
/// </summary>
public class SyncanoObject {

public const string FIELD_ID = "id";
public const string FIELD_CHANNEL = "channel";
public const string FIELD_CHANNEL_ROOM = "channel_room";
public const string FIELD_OWNER_PERMISSIONS = "owner_permissions";
public const string FIELD_GROUP_PERMISSIONS = "group_permissions";
public const string FIELD_OTHER_PERMISSIONS = "other_permissions";
public const string FIELD_GROUP = "group";

/// <summary>
/// The identifier of this object from Syncano.
/// </summary>
[JsonProperty("id")]
[JsonProperty(FIELD_ID)]
public long Id;

/// <summary>
/// The channel.
/// </summary>
[JsonProperty("channel", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(FIELD_CHANNEL, NullValueHandling = NullValueHandling.Ignore)]
public string Channel;

/// <summary>
/// Channel room.
/// </summary>
[JsonProperty("channelroom", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(FIELD_CHANNEL_ROOM, NullValueHandling = NullValueHandling.Ignore)]
public string ChannelRoom { get; set; }

/// <summary>
/// Gets or sets the owner permissions.
/// </summary>
/// <value>The owner permissions.</value>
[JsonProperty("ownerPermissions", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(FIELD_OWNER_PERMISSIONS, NullValueHandling = NullValueHandling.Ignore)]
public DataObjectPermissions? OwnerPermissions { get; set; }

/// <summary>
/// Gets or sets the group permissions.
/// </summary>
/// <value>The group permissions.</value>
[JsonProperty("groupPermissions", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(FIELD_GROUP_PERMISSIONS, NullValueHandling = NullValueHandling.Ignore)]
public DataObjectPermissions? GroupPermissions { get; set; }

/// <summary>
/// Gets or sets the other permissions.
/// </summary>
/// <value>The other permissions.</value>
[JsonProperty("otherPermissions", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(FIELD_OTHER_PERMISSIONS, NullValueHandling = NullValueHandling.Ignore)]
public DataObjectPermissions? OtherPermissions { get; set; }

/// <summary>
/// Gets or sets the group.
/// </summary>
/// <value>The group.</value>
[JsonProperty("group", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(FIELD_GROUP, NullValueHandling = NullValueHandling.Ignore)]
public int? Group { get; set; }

/// <summary>
Expand Down

0 comments on commit f6b6965

Please sign in to comment.