public static AuthResponse GetAuthResponseFromJson(string json) { if (json == null) { throw new ArgumentNullException(nameof(json)); } if (string.IsNullOrWhiteSpace(json)) { throw new ArgumentException(nameof(json)); } var auth = JsonUtility.ConvertJsonIntoObject <AuthResponse>(json); if (auth == null) { throw new ArgumentNullException(nameof(auth)); } if (!auth.IsStatusOk) { var responseError = AuthErrorsAndWarnings.Get.SingleOrDefault(x => x.ErrorCode.Equals(auth.Error)); string message = responseError != null ? responseError.Description : auth.Error; throw new SlackApiException(message); } return(auth); }
public static ICollection <Im> GetImsFromJson(string json) { if (json == null) { throw new ArgumentNullException(nameof(json)); } if (string.IsNullOrWhiteSpace(json)) { throw new ArgumentException(nameof(json)); } var ims = JsonUtility.ConvertJsonIntoObject <ImParent>(json); if (ims == null) { throw new ArgumentNullException(nameof(ims)); } if (!ims.IsStatusOk) { throw new SlackApiException(ims.Error); } return(ims.Ims); }
public static ICollection <Message> GetMessagesInternal(string json) { var content = JsonUtility.ConvertJsonIntoObject <MessageParent>(json); if (content == null) { throw new ArgumentNullException(nameof(content)); } bool isStatusOk = content.IsStatusOk; if (!isStatusOk) { throw new SlackApiException(content.Error); } return(content.Messages); }
public static ICollection <User> GetUsersFromJson(string json) { var content = JsonUtility.ConvertJsonIntoObject <UserParent>(json); if (content == null) { throw new ArgumentNullException(nameof(content)); } bool isStatusOk = content.IsStatusOk; if (!isStatusOk) { throw new SlackApiException(content.Error); } return(content.Members); }
public static bool IsMessagesSendedFromJson(string json) { var content = JsonUtility.ConvertJsonIntoObject <MessageSendResponse>(json); if (content == null) { return(false); } bool isStatusOk = content.IsStatusOk; if (!isStatusOk) { return(false); } return(true); }