/// <summary> /// Executes Keeper JSON command. /// </summary> /// <param name="command">JSON command.</param> /// <param name="responseType">Type of response.</param> /// <param name="throwOnError">if <c>True</c> throw exception on Keeper error.</param> /// <returns>JSON response.</returns> /// <exception cref="KeeperApiException">Keeper JSON API Exception</exception> public async Task <KeeperApiResponse> ExecuteAuthCommand(AuthenticatedCommand command, Type responseType, bool throwOnError) { command.username = Username; command.sessionToken = authContext.SessionToken.Base64UrlEncode(); var response = await Endpoint.ExecuteV2Command(command, responseType); if (response.IsSuccess) { ResetKeepAliveTimer(); return(response); } if (response.resultCode == "auth_failed") { throw new KeeperAuthFailed(); } if (throwOnError) { throw new KeeperApiException(response.resultCode, response.message); } return(response); }
/// <summary> /// Executes JSON authenticated command that does not return data. /// </summary> /// <param name="auth">The authenticated connection.</param> /// <param name="command">JSON authenticated command.</param> /// <returns>A Task returning basic JSON response.</returns> /// <seealso cref="IKeeperEndpoint.ExecuteV2Command"/> public static async Task <KeeperApiResponse> ExecuteAuthCommand(this IAuthentication auth, AuthenticatedCommand command) { return(await auth.ExecuteAuthCommand(command, typeof(KeeperApiResponse), true)); }
public static PostCallBuilder WhenCommand(AuthenticatedCommand command) { whenPostCallBuilder = new PostCallBuilder(client, GetTokeniser(), command, false); return(whenPostCallBuilder); }
public PostCallBuilder(HttpClient client, Tokeniser tokeniser, AuthenticatedCommand command, bool failIfUnsuccessful) : base(client, tokeniser) { Command = command; this.failIfUnsuccessful = failIfUnsuccessful; }