mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
Add methods for working with contacts. (#896)
Added methods for working with contacts: * Import contact list * Delete contact list * Delete one contact
This commit is contained in:
parent
3c6f53be68
commit
c9ac0bab87
|
|
@ -234,6 +234,36 @@ namespace TLSharp.Core
|
||||||
return (T)result;
|
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()
|
public async Task<TLContacts> GetContactsAsync()
|
||||||
{
|
{
|
||||||
if (!IsUserAuthorized())
|
if (!IsUserAuthorized())
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,17 @@ namespace TeleSharp.TL
|
||||||
public class TLVector<T> : TLObject, IList<T>
|
public class TLVector<T> : TLObject, IList<T>
|
||||||
{
|
{
|
||||||
[TLObject(481674261)]
|
[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]
|
public T this[int index]
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue