Skip to content

Commit

Permalink
Update to 1.5 APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
x2bool committed Nov 30, 2019
1 parent 947ac74 commit 45f1281
Show file tree
Hide file tree
Showing 126 changed files with 2,359 additions and 273 deletions.
20 changes: 11 additions & 9 deletions TDLib.Api/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Converter : JsonConverter
{
private static Assembly _assembly;
private static Dictionary<string, Type> _mapper;

static Converter()
{
_assembly = typeof(Converter).Assembly;
Expand All @@ -22,7 +22,7 @@ static Converter()
_mapper.Add(type.Name, type);
}
}

public override bool CanRead => true;

public override bool CanWrite => false;
Expand All @@ -32,18 +32,19 @@ public override bool CanConvert(Type type)
return _mapper.ContainsKey(type.Name);
}

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
JsonSerializer serializer)
{
var jToken = JToken.Load(reader);

if (jToken.Type == JTokenType.Object)
{
var jObject = (JObject) jToken;

var typeProp = jObject["@type"];
if (typeProp != null)
{
var typeName = (string)typeProp;
var typeName = (string) typeProp;
if (typeName != null && _mapper.TryGetValue(typeName, out var type))
{
return jObject.ToObject(type);
Expand All @@ -53,7 +54,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist

return jToken.ToObject(objectType);
}

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
Expand All @@ -65,7 +66,8 @@ public class Int64 : JsonConverter

public override bool CanWrite => true;

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
JsonSerializer serializer)
{
var token = JToken.ReadFrom(reader);
if (token.Type == JTokenType.Array)
Expand All @@ -91,8 +93,8 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist

public override bool CanConvert(Type objectType)
{
return objectType == typeof(long)
|| objectType == typeof(long[]);
return objectType == typeof(long)
|| objectType == typeof(long[]);
}

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
Expand Down
5 changes: 4 additions & 1 deletion TDLib.Api/Function.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
{
public partial class TdApi
{
/// <summary>
/// Base class for all functions
/// </summary>
/// <typeparam name="T">Return type for this function</typeparam>
public abstract class Function<T> : Object
{

}
}
}
13 changes: 3 additions & 10 deletions TDLib.Api/Functions/ChangePhoneNumber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,11 @@ public class ChangePhoneNumber : Function<AuthenticationCodeInfo>
public string PhoneNumber { get; set; }

/// <summary>
/// Pass true if the code can be sent via flash call to the specified phone number
/// Settings for the authentication of the user's phone number
/// </summary>
[JsonConverter(typeof(Converter))]
[JsonProperty("allow_flash_call")]
public bool AllowFlashCall { get; set; }

/// <summary>
/// Pass true if the phone number is used on the current device. Ignored if allow_flash_call is false
/// </summary>
[JsonConverter(typeof(Converter))]
[JsonProperty("is_current_phone_number")]
public bool IsCurrentPhoneNumber { get; set; }
[JsonProperty("settings")]
public PhoneNumberAuthenticationSettings Settings { get; set; }
}
}
}
14 changes: 0 additions & 14 deletions TDLib.Api/Functions/CheckAuthenticationCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@ public class CheckAuthenticationCode : Function<Ok>
[JsonConverter(typeof(Converter))]
[JsonProperty("code")]
public string Code { get; set; }

/// <summary>
/// If the user is not yet registered, the first name of the user; 1-64 characters. You can also pass an empty string for unregistered user there to check verification code validness. In the latter case PHONE_NUMBER_UNOCCUPIED error will be returned for a valid code
/// </summary>
[JsonConverter(typeof(Converter))]
[JsonProperty("first_name")]
public string FirstName { get; set; }

/// <summary>
/// If the user is not yet registered; the last name of the user; optional; 0-64 characters
/// </summary>
[JsonConverter(typeof(Converter))]
[JsonProperty("last_name")]
public string LastName { get; set; }
}
}
}
16 changes: 15 additions & 1 deletion TDLib.Api/Functions/ForwardMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class ForwardMessages : Function<Messages>
public bool DisableNotification { get; set; }

/// <summary>
/// Pass true if the message is sent from the background
/// Pass true if the messages are sent from the background
/// </summary>
[JsonConverter(typeof(Converter))]
[JsonProperty("from_background")]
Expand All @@ -66,6 +66,20 @@ public class ForwardMessages : Function<Messages>
[JsonConverter(typeof(Converter))]
[JsonProperty("as_album")]
public bool AsAlbum { get; set; }

/// <summary>
/// True, if content of the messages needs to be copied without links to the original messages. Always true if the messages are forwarded to a secret chat
/// </summary>
[JsonConverter(typeof(Converter))]
[JsonProperty("send_copy")]
public bool SendCopy { get; set; }

/// <summary>
/// True, if media captions of message copies needs to be removed. Ignored if send_copy is false
/// </summary>
[JsonConverter(typeof(Converter))]
[JsonProperty("remove_caption")]
public bool RemoveCaption { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion TDLib.Api/Functions/GenerateChatInviteLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace TdLib
public partial class TdApi
{
/// <summary>
/// Generates a new invite link for a chat; the previously generated link is revoked. Available for basic groups, supergroups, and channels. In basic groups this can be called only by the group's creator; in supergroups and channels this requires appropriate administrator rights
/// Generates a new invite link for a chat; the previously generated link is revoked. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right
/// </summary>
public class GenerateChatInviteLink : Function<ChatInviteLink>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ namespace TdLib
public partial class TdApi
{
/// <summary>
/// Returns background wallpapers
/// Returns auto-download settings presets for the currently logged in user
/// </summary>
public class GetWallpapers : Function<Wallpapers>
public class GetAutoDownloadSettingsPresets : Function<AutoDownloadSettingsPresets>
{
/// <summary>
/// Data type for serialization
/// </summary>
[JsonProperty("@type")]
public override string DataType { get; set; } = "getWallpapers";
public override string DataType { get; set; } = "getAutoDownloadSettingsPresets";

/// <summary>
/// Extra data attached to the message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ namespace TdLib
public partial class TdApi
{
/// <summary>
/// Toggles whether all members of a supergroup can add new members; requires appropriate administrator rights in the supergroup.
/// Constructs a persistent HTTP URL for a background
/// </summary>
public class ToggleSupergroupInvites : Function<Ok>
public class GetBackgroundUrl : Function<HttpUrl>
{
/// <summary>
/// Data type for serialization
/// </summary>
[JsonProperty("@type")]
public override string DataType { get; set; } = "toggleSupergroupInvites";
public override string DataType { get; set; } = "getBackgroundUrl";

/// <summary>
/// Extra data attached to the message
Expand All @@ -26,18 +26,18 @@ public class ToggleSupergroupInvites : Function<Ok>
public override string Extra { get; set; }

/// <summary>
/// Identifier of the supergroup
/// Background name
/// </summary>
[JsonConverter(typeof(Converter))]
[JsonProperty("supergroup_id")]
public int SupergroupId { get; set; }
[JsonProperty("name")]
public string Name { get; set; }

/// <summary>
/// New value of anyone_can_invite
/// Background type
/// </summary>
[JsonConverter(typeof(Converter))]
[JsonProperty("anyone_can_invite")]
public bool AnyoneCanInvite { get; set; }
[JsonProperty("type")]
public BackgroundType Type { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ namespace TdLib
public partial class TdApi
{
/// <summary>
/// Represents a list of all emoji corresponding to a sticker in a sticker set. The list is only for informational purposes, because a sticker is always sent with a fixed emoji from the corresponding Sticker object
/// Returns backgrounds installed by the user
/// </summary>
public class StickerEmojis : Object
public class GetBackgrounds : Function<Backgrounds>
{
/// <summary>
/// Data type for serialization
/// </summary>
[JsonProperty("@type")]
public override string DataType { get; set; } = "stickerEmojis";
public override string DataType { get; set; } = "getBackgrounds";

/// <summary>
/// Extra data attached to the message
Expand All @@ -26,11 +26,11 @@ public class StickerEmojis : Object
public override string Extra { get; set; }

/// <summary>
/// List of emojis
/// True, if the backgrounds needs to be ordered for dark theme
/// </summary>
[JsonConverter(typeof(Converter))]
[JsonProperty("emojis")]
public string[] Emojis { get; set; }
[JsonProperty("for_dark_theme")]
public bool ForDarkTheme { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion TDLib.Api/Functions/GetChatStatisticsUrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace TdLib
public partial class TdApi
{
/// <summary>
/// Returns URL with the chat statistics. Currently this method can be used only for channels
/// Returns an HTTP URL with the chat statistics. Currently this method can be used only for channels
/// </summary>
public class GetChatStatisticsUrl : Function<HttpUrl>
{
Expand Down
2 changes: 1 addition & 1 deletion TDLib.Api/Functions/GetCountryCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace TdLib
public partial class TdApi
{
/// <summary>
/// Uses current user IP to found his country. Returns two-letter ISO 3166-1 alpha-2 country code. Can be called before authorization
/// Uses current user IP to found their country. Returns two-letter ISO 3166-1 alpha-2 country code. Can be called before authorization
/// </summary>
public class GetCountryCode : Function<Text>
{
Expand Down
2 changes: 1 addition & 1 deletion TDLib.Api/Functions/GetCreatedPublicChats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace TdLib
public partial class TdApi
{
/// <summary>
/// Returns a list of public chats created by the user
/// Returns a list of public chats with username created by the user
/// </summary>
public class GetCreatedPublicChats : Function<Chats>
{
Expand Down
36 changes: 36 additions & 0 deletions TDLib.Api/Functions/GetEmojiSuggestionsUrl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using Newtonsoft.Json;

namespace TdLib
{
/// <summary>
/// Autogenerated TDLib APIs
/// </summary>
public partial class TdApi
{
/// <summary>
/// Returns an HTTP URL which can be used to automatically log in to the translation platform and suggest new emoji replacements. The URL will be valid for 30 seconds after generation
/// </summary>
public class GetEmojiSuggestionsUrl : Function<HttpUrl>
{
/// <summary>
/// Data type for serialization
/// </summary>
[JsonProperty("@type")]
public override string DataType { get; set; } = "getEmojiSuggestionsUrl";

/// <summary>
/// Extra data attached to the message
/// </summary>
[JsonProperty("@extra")]
public override string Extra { get; set; }

/// <summary>
/// Language code for which the emoji replacements will be suggested
/// </summary>
[JsonConverter(typeof(Converter))]
[JsonProperty("language_code")]
public string LanguageCode { get; set; }
}
}
}
36 changes: 36 additions & 0 deletions TDLib.Api/Functions/GetMessageLinkInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using Newtonsoft.Json;

namespace TdLib
{
/// <summary>
/// Autogenerated TDLib APIs
/// </summary>
public partial class TdApi
{
/// <summary>
/// Returns information about a public or private message link
/// </summary>
public class GetMessageLinkInfo : Function<MessageLinkInfo>
{
/// <summary>
/// Data type for serialization
/// </summary>
[JsonProperty("@type")]
public override string DataType { get; set; } = "getMessageLinkInfo";

/// <summary>
/// Extra data attached to the message
/// </summary>
[JsonProperty("@extra")]
public override string Extra { get; set; }

/// <summary>
/// The message link in the format "https://t.me/c/...", or "tg://privatepost?...", or "https://t.me/username/...", or "tg://resolve?..."
/// </summary>
[JsonConverter(typeof(Converter))]
[JsonProperty("url")]
public string Url { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion TDLib.Api/Functions/GetPublicMessageLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace TdLib
public partial class TdApi
{
/// <summary>
/// Returns a public HTTPS link to a message. Available only for messages in public supergroups and channels
/// Returns a public HTTPS link to a message. Available only for messages in supergroups and channels with username
/// </summary>
public class GetPublicMessageLink : Function<PublicMessageLink>
{
Expand Down
2 changes: 1 addition & 1 deletion TDLib.Api/Functions/GetRemoteFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace TdLib
public partial class TdApi
{
/// <summary>
/// Returns information about a file by its remote ID; this is an offline request. Can be used to register a URL as a file for further uploading, or sending as a message
/// Returns information about a file by its remote ID; this is an offline request. Can be used to register a URL as a file for further uploading, or sending as a message. Even the request succeeds, the file can be used only if it is still accessible to the user.
/// </summary>
public class GetRemoteFile : Function<File>
{
Expand Down
Loading

0 comments on commit 45f1281

Please sign in to comment.