/// <summary> /// request to log in as owner of the uservoice site /// </summary> /// <param name="subdomain">the site's subdomain</param> /// <param name="consumerKey">your consumer key</param> /// <param name="consumerSecret">your consumer secret</param> /// <param name="callbackUrl">your callback url</param> /// <returns>the owner result. owner tokens will be written to the OwnerTokens class</returns> public static async Task <OwnerResult> LoginAsOwner(string subdomain, string consumerKey, string consumerSecret, string callbackUrl) { OwnerResult ownerData = new OwnerResult(); IRestResponse response = await LoginAsOwnerResponse(subdomain, consumerKey, consumerSecret, callbackUrl); if (response.StatusCode != System.Net.HttpStatusCode.OK) { switch (response.StatusCode) { case System.Net.HttpStatusCode.Unauthorized: break; case System.Net.HttpStatusCode.NotFound: break; default: break; } } else if (response.StatusCode == System.Net.HttpStatusCode.OK) { string responseContent = Encoding.UTF8.GetString(response.RawBytes, 0, response.RawBytes.Length); ownerData = JsonConvert.DeserializeObject <OwnerResult>(responseContent); OwnerTokens.AccessToken = ownerData.token.oauth_token; OwnerTokens.AccessTokenSecret = ownerData.token.oauth_token_secret; } return(ownerData); }
public void Deve_retornar_verdadeiro_quando_owner_result_nao_preenchido() { var result = new OwnerResult(); result.Validar(); Assert.IsTrue(result.Notifications.Any()); }
private static OwnerResult GetOrAddResult(this OwnerService service, string environment, StatusType status) { OwnerResult result = service.Results.FirstOrDefault(r => r.Environment == environment); if (result == null) { result = new OwnerResult { Environment = environment, Status = status }; service.Results.Add(result); } return(result); }
public void Deve_retornar_falso_quando_owner_result_preenchido() { var result = new OwnerResult() { Id = 1, Node_Id = "MDQ6VXNlcjU4MzIzMQ==", Avatar_Url = "https://avatars.githubusercontent.com/u/583231?v=3", Login = "******", Type = "User", Url = "https://api.github.com/users/octocat" }; result.Validar(); Assert.IsFalse(result.Notifications.Any()); }