mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 18:08:26 +03:00
new apis
This commit is contained in:
parent
f76051d362
commit
25c82ffd58
2 changed files with 58 additions and 42 deletions
|
@ -39,5 +39,8 @@ namespace Bit.Core.Abstractions
|
|||
Task<TResponse> SendAsync<TRequest, TResponse>(HttpMethod method, string path,
|
||||
TRequest body, bool authed, bool hasResponse);
|
||||
void SetUrls(EnvironmentUrls urls);
|
||||
Task<CipherResponse> PostCipherAttachmentAsync(string id, MultipartFormDataContent data);
|
||||
Task PostShareCipherAttachmentAsync(string id, string attachmentId, MultipartFormDataContent data,
|
||||
string organizationId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,12 +230,26 @@ namespace Bit.Core.Services
|
|||
|
||||
#region Attachments APIs
|
||||
|
||||
public Task<CipherResponse> PostCipherAttachmentAsync(string id, MultipartFormDataContent data)
|
||||
{
|
||||
return SendAsync<MultipartFormDataContent, CipherResponse>(HttpMethod.Post,
|
||||
string.Concat("/ciphers/", id, "/attachment"), data, true, true);
|
||||
}
|
||||
|
||||
public Task DeleteCipherAttachmentAsync(string id, string attachmentId)
|
||||
{
|
||||
return SendAsync<object, object>(HttpMethod.Delete,
|
||||
string.Concat("/ciphers/", id, "/attachments/", attachmentId), null, true, false);
|
||||
}
|
||||
|
||||
public Task PostShareCipherAttachmentAsync(string id, string attachmentId, MultipartFormDataContent data,
|
||||
string organizationId)
|
||||
{
|
||||
return SendAsync<MultipartFormDataContent, object>(HttpMethod.Post,
|
||||
string.Concat("/ciphers/", id, "/attachment/", attachmentId, "/share?organizationId=", organizationId),
|
||||
data, true, false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Sync APIs
|
||||
|
@ -263,12 +277,10 @@ namespace Bit.Core.Services
|
|||
public async Task<TResponse> SendAsync<TRequest, TResponse>(HttpMethod method, string path, TRequest body,
|
||||
bool authed, bool hasResponse)
|
||||
{
|
||||
var requestMessage = new HttpRequestMessage
|
||||
using(var requestMessage = new HttpRequestMessage())
|
||||
{
|
||||
Method = method,
|
||||
RequestUri = new Uri(string.Concat(ApiBaseUrl, path)),
|
||||
};
|
||||
|
||||
requestMessage.Method = method;
|
||||
requestMessage.RequestUri = new Uri(string.Concat(ApiBaseUrl, path));
|
||||
if(body != null)
|
||||
{
|
||||
var bodyType = body.GetType();
|
||||
|
@ -277,9 +289,9 @@ namespace Bit.Core.Services
|
|||
requestMessage.Content = new StringContent((object)bodyType as string, Encoding.UTF8,
|
||||
"application/x-www-form-urlencoded; charset=utf-8");
|
||||
}
|
||||
else if(false)
|
||||
else if(bodyType == typeof(MultipartFormDataContent))
|
||||
{
|
||||
// TODO: form data content
|
||||
requestMessage.Content = body as MultipartFormDataContent;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -312,6 +324,7 @@ namespace Bit.Core.Services
|
|||
}
|
||||
return (TResponse)(object)null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IdentityTokenResponse> DoRefreshTokenAsync()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue