mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-27 17:08:00 +01:00
handle non-root URLs
This commit is contained in:
parent
0eb68ec461
commit
12e3214f70
@ -18,7 +18,7 @@ namespace Bit.App.Repositories
|
||||
: base(connectivity, httpService, tokenService)
|
||||
{ }
|
||||
|
||||
protected override string ApiRoute => "accounts";
|
||||
protected override string ApiRoute => "/accounts";
|
||||
|
||||
public virtual async Task<ApiResult> PostRegisterAsync(RegisterRequest requestObj)
|
||||
{
|
||||
@ -32,7 +32,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/register")),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/register")),
|
||||
};
|
||||
|
||||
try
|
||||
@ -64,7 +64,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/password-hint")),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/password-hint")),
|
||||
};
|
||||
|
||||
try
|
||||
@ -102,7 +102,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage()
|
||||
{
|
||||
Method = HttpMethod.Get,
|
||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/revision-date")),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/revision-date")),
|
||||
};
|
||||
|
||||
try
|
||||
@ -151,7 +151,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage()
|
||||
{
|
||||
Method = HttpMethod.Get,
|
||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/profile")),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/profile")),
|
||||
};
|
||||
|
||||
try
|
||||
@ -191,7 +191,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage()
|
||||
{
|
||||
Method = HttpMethod.Get,
|
||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/keys")),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/keys")),
|
||||
};
|
||||
|
||||
try
|
||||
|
@ -6,7 +6,6 @@ using Bit.App.Abstractions;
|
||||
using Bit.App.Models.Api;
|
||||
using Newtonsoft.Json;
|
||||
using Plugin.Connectivity.Abstractions;
|
||||
using System.Net;
|
||||
|
||||
namespace Bit.App.Repositories
|
||||
{
|
||||
@ -40,7 +39,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage()
|
||||
{
|
||||
Method = HttpMethod.Get,
|
||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/", id)),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/", id)),
|
||||
};
|
||||
|
||||
try
|
||||
@ -80,7 +79,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage()
|
||||
{
|
||||
Method = HttpMethod.Get,
|
||||
RequestUri = new Uri(client.BaseAddress, ApiRoute),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute)),
|
||||
};
|
||||
|
||||
try
|
||||
@ -120,7 +119,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri(client.BaseAddress, ApiRoute),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute)),
|
||||
};
|
||||
|
||||
try
|
||||
@ -160,7 +159,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
||||
{
|
||||
Method = HttpMethod.Put,
|
||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/", id)),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/", id)),
|
||||
};
|
||||
|
||||
try
|
||||
@ -200,7 +199,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage()
|
||||
{
|
||||
Method = HttpMethod.Delete,
|
||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/", id)),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/", id)),
|
||||
};
|
||||
|
||||
try
|
||||
|
@ -54,7 +54,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new HttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri(client.BaseAddress, "connect/token"),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, "/connect/token")),
|
||||
Content = new FormUrlEncodedContent(new Dictionary<string, string>
|
||||
{
|
||||
{ "grant_type", "refresh_token" },
|
||||
@ -126,7 +126,7 @@ namespace Bit.App.Repositories
|
||||
{ }
|
||||
|
||||
return ApiResult<T>.Failed(response.StatusCode,
|
||||
new ApiError { Message = "An unknown error has occured." });
|
||||
new ApiError { Message = "An unknown error has occurred." });
|
||||
}
|
||||
|
||||
protected async Task<ApiResult> HandleErrorAsync(HttpResponseMessage response)
|
||||
@ -140,7 +140,7 @@ namespace Bit.App.Repositories
|
||||
{ }
|
||||
|
||||
return ApiResult.Failed(response.StatusCode,
|
||||
new ApiError { Message = "An unknown error has occured." });
|
||||
new ApiError { Message = "An unknown error has occurred." });
|
||||
}
|
||||
|
||||
private async Task<List<ApiError>> ParseErrorsAsync(HttpResponseMessage response)
|
||||
@ -186,7 +186,7 @@ namespace Bit.App.Repositories
|
||||
|
||||
if(errors.Count == 0)
|
||||
{
|
||||
errors.Add(new ApiError { Message = "An unknown error has occured." });
|
||||
errors.Add(new ApiError { Message = "An unknown error has occurred." });
|
||||
}
|
||||
|
||||
return errors;
|
||||
|
@ -19,7 +19,7 @@ namespace Bit.App.Repositories
|
||||
: base(connectivity, httpService, tokenService)
|
||||
{ }
|
||||
|
||||
protected override string ApiRoute => "ciphers";
|
||||
protected override string ApiRoute => "/ciphers";
|
||||
|
||||
public virtual async Task<ApiResult<CipherResponse>> GetByIdAsync(string id)
|
||||
{
|
||||
@ -39,7 +39,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage()
|
||||
{
|
||||
Method = HttpMethod.Get,
|
||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/", id)),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/", id)),
|
||||
};
|
||||
|
||||
try
|
||||
@ -79,8 +79,8 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage()
|
||||
{
|
||||
Method = HttpMethod.Get,
|
||||
RequestUri = new Uri(client.BaseAddress,
|
||||
string.Format("{0}?includeFolders=false&includeShared=true", ApiRoute)),
|
||||
RequestUri = new Uri(string.Format("{0}{1}?includeFolders=false&includeShared=true",
|
||||
client.BaseAddress, ApiRoute)),
|
||||
};
|
||||
|
||||
try
|
||||
@ -124,7 +124,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/", cipherId, "/attachment")),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/", cipherId, "/attachment")),
|
||||
Content = content
|
||||
};
|
||||
|
||||
@ -165,8 +165,8 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage()
|
||||
{
|
||||
Method = HttpMethod.Delete,
|
||||
RequestUri = new Uri(client.BaseAddress,
|
||||
string.Concat(ApiRoute, "/", cipherId, "/attachment/", attachmentId)),
|
||||
RequestUri = new Uri(
|
||||
string.Concat(client.BaseAddress, ApiRoute, "/", cipherId, "/attachment/", attachmentId)),
|
||||
};
|
||||
|
||||
try
|
||||
|
@ -20,7 +20,7 @@ namespace Bit.App.Repositories
|
||||
: base(connectivity, httpService, tokenService)
|
||||
{ }
|
||||
|
||||
protected override string ApiRoute => "connect";
|
||||
protected override string ApiRoute => "/connect";
|
||||
|
||||
public virtual async Task<ApiResult<TokenResponse>> PostTokenAsync(TokenRequest requestObj)
|
||||
{
|
||||
@ -34,7 +34,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new HttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/token")),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/token")),
|
||||
Content = new FormUrlEncodedContent(requestObj.ToIdentityTokenRequest())
|
||||
};
|
||||
|
||||
|
@ -18,7 +18,7 @@ namespace Bit.App.Repositories
|
||||
: base(connectivity, httpService, tokenService)
|
||||
{ }
|
||||
|
||||
protected override string ApiRoute => "devices";
|
||||
protected override string ApiRoute => "/devices";
|
||||
|
||||
public virtual async Task<ApiResult> PutTokenAsync(string identifier, DeviceTokenRequest request)
|
||||
{
|
||||
@ -38,7 +38,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage(request)
|
||||
{
|
||||
Method = HttpMethod.Put,
|
||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/identifier/", identifier, "/token")),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/identifier/", identifier, "/token")),
|
||||
};
|
||||
|
||||
try
|
||||
@ -70,8 +70,8 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Put,
|
||||
RequestUri = new Uri(client.BaseAddress,
|
||||
string.Concat(ApiRoute, "/identifier/", identifier, "/clear-token"))
|
||||
RequestUri = new Uri(
|
||||
string.Concat(client.BaseAddress, ApiRoute, "/identifier/", identifier, "/clear-token"))
|
||||
};
|
||||
|
||||
try
|
||||
|
@ -14,6 +14,6 @@ namespace Bit.App.Repositories
|
||||
: base(connectivity, httpService, tokenService)
|
||||
{ }
|
||||
|
||||
protected override string ApiRoute => "folders";
|
||||
protected override string ApiRoute => "/folders";
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,6 @@ namespace Bit.App.Repositories
|
||||
: base(connectivity, httpService, tokenService)
|
||||
{ }
|
||||
|
||||
protected override string ApiRoute => "sites";
|
||||
protected override string ApiRoute => "/logins";
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace Bit.App.Repositories
|
||||
: base(connectivity, httpService, tokenService)
|
||||
{ }
|
||||
|
||||
protected override string ApiRoute => "settings";
|
||||
protected override string ApiRoute => "/settings";
|
||||
|
||||
public virtual async Task<ApiResult<DomainsResponse>> GetDomains(bool excluded = false)
|
||||
{
|
||||
@ -37,8 +37,8 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage()
|
||||
{
|
||||
Method = HttpMethod.Get,
|
||||
RequestUri = new Uri(client.BaseAddress,
|
||||
string.Concat(ApiRoute, "/domains?excluded=", excluded.ToString().ToLowerInvariant())),
|
||||
RequestUri = new Uri(
|
||||
string.Concat(client.BaseAddress, ApiRoute, "/domains?excluded=", excluded.ToString().ToLowerInvariant())),
|
||||
};
|
||||
|
||||
try
|
||||
|
@ -16,7 +16,7 @@ namespace Bit.App.Repositories
|
||||
: base(connectivity, httpService, tokenService)
|
||||
{ }
|
||||
|
||||
protected override string ApiRoute => "two-factor";
|
||||
protected override string ApiRoute => "/two-factor";
|
||||
|
||||
public virtual async Task<ApiResult> PostSendEmailLoginAsync(TwoFactorEmailRequest requestObj)
|
||||
{
|
||||
@ -30,7 +30,7 @@ namespace Bit.App.Repositories
|
||||
var requestMessage = new TokenHttpRequestMessage(requestObj)
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/send-email-login")),
|
||||
RequestUri = new Uri(string.Concat(client.BaseAddress, ApiRoute, "/send-email-login")),
|
||||
};
|
||||
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user