Skip to content
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

Allow limit and cursor on calls with pagination. General cleanup of u… #231

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions SlackAPI/Channel.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SlackAPI
namespace SlackAPI
{
public class Channel : Conversation
{
Expand All @@ -17,12 +11,12 @@ public class Channel : Conversation
public bool is_channel;
public bool is_group;
//Is this deprecated by is_open?
public bool IsPrivateGroup { get { return id != null && id[0] == 'G'; } }
public bool IsPrivateGroup => id != null && id[0] == 'G';

public int num_members;
public OwnedStampedMessage topic;
public OwnedStampedMessage purpose;

public string[] members;
}
}
}
10 changes: 2 additions & 8 deletions SlackAPI/ContextMessage.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SlackAPI
namespace SlackAPI
{
public class ContextMessage : Message
{
Expand All @@ -23,4 +17,4 @@ public class ContextMessage : Message
public Message next;
public Message next_2;
}
}
}
6 changes: 1 addition & 5 deletions SlackAPI/Conversation.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SlackAPI
{
Expand All @@ -16,4 +12,4 @@ public class Conversation
public int unread_count;
public Message latest;
}
}
}
10 changes: 2 additions & 8 deletions SlackAPI/DirectMessageConversation.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SlackAPI
namespace SlackAPI
{
public class DirectMessageConversation : Conversation
{
public string user;
public bool is_user_deleted;
}
}
}
7 changes: 3 additions & 4 deletions SlackAPI/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ public static object Deserialize(this string data, Type type)

private static JsonSerializerSettings CreateSettings()
{
JsonSerializerSettings settings = new JsonSerializerSettings();
settings.Converters = Converters;
JsonSerializerSettings settings = new JsonSerializerSettings {Converters = Converters};

return settings;
return settings;
}
}
}
}
6 changes: 1 addition & 5 deletions SlackAPI/JavascriptDateTimeConverter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SlackAPI
{
Expand Down Expand Up @@ -32,4 +28,4 @@ public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value,
writer.WriteValue(((DateTime)value).Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
}
}
}
}
6 changes: 1 addition & 5 deletions SlackAPI/Message.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SlackAPI
{
Expand All @@ -23,4 +19,4 @@ public class Message : SlackSocketMessage

public DateTime? thread_ts;
}
}
}
7 changes: 2 additions & 5 deletions SlackAPI/MimeTypes.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SlackAPI
{
public static class MimeType
public static class MimeType
{

private static Dictionary<String, String> MimeTypeDict = new Dictionary<String, String>()
Expand Down Expand Up @@ -533,4 +530,4 @@ public static String Get(String extension, String defaultMimeType)
}

}
}
}
10 changes: 2 additions & 8 deletions SlackAPI/OwnedStampedMessage.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SlackAPI
namespace SlackAPI
{
public class OwnedStampedMessage
{
public string value;
public string creator;
public string last_set;
}
}
}
4 changes: 1 addition & 3 deletions SlackAPI/Preferences.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace SlackAPI
namespace SlackAPI
{
public class Preferences
{
Expand Down
2 changes: 1 addition & 1 deletion SlackAPI/ProfileIcons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ public class ProfileIcons
public string image_192;
public string image_512;
}
}
}
2 changes: 1 addition & 1 deletion SlackAPI/Reaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ public class Reaction
public int count;
public List<string> users;
}
}
}
10 changes: 2 additions & 8 deletions SlackAPI/ReactionAddedResponse.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SlackAPI
namespace SlackAPI
{
[RequestPath("reactions.add")]
public class ReactionAddedResponse : Response
{

}
}
}
19 changes: 7 additions & 12 deletions SlackAPI/Request.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
using Newtonsoft.Json;
using System;
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Reflection;
using System.Text;
using System.Threading;

namespace SlackAPI
{


class RequestState<K>
class RequestState<K>
where K : Response
{
public HttpWebRequest request;
Expand All @@ -24,8 +19,7 @@ class RequestState<K>

public RequestState(HttpWebRequest requestData, Tuple<string, string>[] postParameters, Action<K> toCallback)
{
if (requestData == null) throw new ArgumentNullException("requestData can not be null");
request = requestData;
request = requestData ?? throw new ArgumentNullException("requestData can not be null");
Post = postParameters;
callback = toCallback;
}
Expand Down Expand Up @@ -59,7 +53,8 @@ public void GotRequest(IAsyncResult result)
if (!first)
writer.Write(',');

writer.Write(string.Format("{0}={1}", Uri.EscapeDataString(postEntry.Item1), Uri.EscapeDataString(postEntry.Item2)));
writer.Write(
$"{Uri.EscapeDataString(postEntry.Item1)}={Uri.EscapeDataString(postEntry.Item2)}");

first = false;
}
Expand Down Expand Up @@ -153,7 +148,7 @@ public static RequestPath GetRequestPath<K>()
TypeInfo info = t.GetTypeInfo();

path = info.GetCustomAttribute<RequestPath>();
if (path == null) throw new InvalidOperationException(string.Format("No valid request path for {0}", t.Name));
if (path == null) throw new InvalidOperationException($"No valid request path for {t.Name}");

try
{
Expand All @@ -175,4 +170,4 @@ public static RequestPath GetRequestPath<K>()
return path;
}
}
}
}
11 changes: 4 additions & 7 deletions SlackAPI/RequestStateForTask.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace SlackAPI
Expand Down Expand Up @@ -80,7 +76,8 @@ private async Task<K> ExecutePost()
if (!first)
writer.Write('&');

await writer.WriteAsync(string.Format("{0}={1}", Uri.EscapeDataString(postEntry.Item1), Uri.EscapeDataString(postEntry.Item2)));
await writer.WriteAsync(
$"{Uri.EscapeDataString(postEntry.Item1)}={Uri.EscapeDataString(postEntry.Item2)}");

first = false;
}
Expand All @@ -91,4 +88,4 @@ private async Task<K> ExecutePost()
return await this.ExecuteResult();
}
}
}
}
15 changes: 9 additions & 6 deletions SlackAPI/Response.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SlackAPI
{
Expand All @@ -21,7 +17,14 @@ public abstract class Response
public void AssertOk()
{
if (!(ok))
throw new InvalidOperationException(string.Format("An error occurred: {0}", this.error));
throw new InvalidOperationException($"An error occurred: {this.error}");
}

public ResponseMetadata response_metadata;
}

public class ResponseMetadata
{
public string next_cursor;
}
}
}
Loading