mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
Added methods for working with contacts.
Added custom constructor for TLVector.
This commit is contained in:
parent
3c6f53be68
commit
f1bcd62df3
|
|
@ -234,12 +234,42 @@ namespace TLSharp.Core
|
|||
return (T)result;
|
||||
}
|
||||
|
||||
public async Task<TLImportedContacts> ImportContactsAsync(IReadOnlyList<TLInputPhoneContact> contacts)
|
||||
{
|
||||
if (!IsUserAuthorized())
|
||||
throw new InvalidOperationException("Authorize user first!");
|
||||
|
||||
var req = new TLRequestImportContacts { Contacts = new TLVector<TLInputPhoneContact>(contacts)};
|
||||
|
||||
return await SendRequestAsync<TLImportedContacts>(req);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteContactsAsync(IReadOnlyList<TLAbsInputUser> users)
|
||||
{
|
||||
if (!IsUserAuthorized())
|
||||
throw new InvalidOperationException("Authorize user first!");
|
||||
|
||||
var req = new TLRequestDeleteContacts {Id = new TLVector<TLAbsInputUser>(users)};
|
||||
|
||||
return await SendRequestAsync<bool>(req);
|
||||
}
|
||||
|
||||
public async Task<TLLink> DeleteContactAsync(TLAbsInputUser user)
|
||||
{
|
||||
if (!IsUserAuthorized())
|
||||
throw new InvalidOperationException("Authorize user first!");
|
||||
|
||||
var req = new TLRequestDeleteContact {Id = user};
|
||||
|
||||
return await SendRequestAsync<TLLink>(req);
|
||||
}
|
||||
|
||||
public async Task<TLContacts> GetContactsAsync()
|
||||
{
|
||||
if (!IsUserAuthorized())
|
||||
throw new InvalidOperationException("Authorize user first!");
|
||||
|
||||
var req = new TLRequestGetContacts() { Hash = "" };
|
||||
var req = new TLRequestGetContacts {Hash = ""};
|
||||
|
||||
return await SendRequestAsync<TLContacts>(req);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,17 @@ namespace TeleSharp.TL
|
|||
public class TLVector<T> : TLObject, IList<T>
|
||||
{
|
||||
[TLObject(481674261)]
|
||||
private List<T> lists = new List<T>();
|
||||
private List<T> lists;
|
||||
|
||||
public TLVector(IEnumerable<T> collection)
|
||||
{
|
||||
lists = new List<T>(collection);
|
||||
}
|
||||
|
||||
public TLVector()
|
||||
{
|
||||
lists = new List<T>();
|
||||
}
|
||||
|
||||
public T this[int index]
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue