public static async Task <ISimpleResponse <T> > SendMessage <T>(ISimpleRestClient client, ISimpleMessage message) { T messageTypeToReturn = Activator.CreateInstance <T>(); ISimpleResponse <T> toReturn = new SimpleResponse <T>(); HttpClient restClient = new HttpClient(); Windows.Web.Http.HttpMethod method = message.HttpMethod == HttpMethod.Get ? Windows.Web.Http.HttpMethod.Get : Windows.Web.Http.HttpMethod.Post; // Add Global Request Parameters foreach (var globalRequestParameter in client.GlobalRequestParameters) { message.Parameters[globalRequestParameter.Key] = globalRequestParameter.Value; } Uri uriWithQueryString = await MessageHelper.BuildUri(baseUrl : client.BaseUrl, endPointPath : message.EndPointPath, queryStringParameters : message.Parameters); HttpRequestMessage requestMessage = new HttpRequestMessage(method, uriWithQueryString); // Add Headers foreach (var header in client.Headers) { requestMessage.Headers.Add(header.Key, header.Value); } HttpResponseMessage response = await restClient.SendRequestAsync(requestMessage); toReturn.DataRaw = response.Content; toReturn.DataConverted = Deserializer.JsonToObject <T>(response.Content.ToString()); return(toReturn); }
public JiraClient(string baseUrl, string username, string password, bool useTempo, string tempoToken) { var url = baseUrl + (baseUrl.EndsWith("/") ? "" : "/") + "rest/api/2"; jiraClient = SimpleRestClient.WithBasicAuthentication(url, username, password, GetErrorMessages); try { myUser = GetCurrentUser(); } catch (Exception e) { throw new ConnectionError(ConnectionError.Type.Jira, "Error connecting to jira", e); } if (useTempo) { tempoClient = SimpleRestClient.WithBearerAuthentication("https://api.tempo.io/core/3", tempoToken, null); try { var queryDate = DateTime.UtcNow; tempoClient.Get <TempoWorkLogSearch>(HttpStatusCode.OK, $"worklogs/user/{myUser.accountId}?from={queryDate:yyyy-MM-dd}&to={queryDate:yyyy-MM-dd}"); } catch (Exception e) { throw new ConnectionError(ConnectionError.Type.Tempo, "Error connecting to tempo", e); } } else { tempoClient = null; } }
protected MovesClient(ISimpleRestClient restClient) : base(restClient) { AuthenticationBaseUrl = "https://api.moves-app.com/oauth/v1/"; Places = new PlaceEndpoint(RestClient); Profile = new ProfileEndpoint(RestClient); Storyline = new StorylineEndpoint(RestClient); Summary = new SummaryEndpoint(RestClient); Activity = new ActivityEndpoint(RestClient); }
public JiraRestClient(string baseUrl, string username, string password, bool useTempo) { var url = baseUrl + (baseUrl.EndsWith("/") ? "" : "/") + "rest/"; restClient = new SimpleRestClient(url, username, password, GetErrorMessages); myUser = GetCurrentUser(); if (useTempo) { try { //NOTE THIS IS NOT THE RIGHT TYPE, BUT NOT EXPECTING VALID DATA ANYWAY restClient.Get <List <string> >(HttpStatusCode.OK, "tempo-timesheets/3/worklogs?dateFrom=1990-01-01&dateTo=1990-01-02"); HasTempo = true; } catch (Exception) { HasTempo = false; } } else { HasTempo = false; } }
public MunicipalityTaxController(ILogger <MunicipalityTaxController> logger, ISimpleRestClient simpleRestClient) { this._logger = logger; this.simpleRestClient = simpleRestClient; }
public SummaryEndpoint(ISimpleRestClient restClient) : base(restClient, "summary") { }
public JiraRestClient(string baseUrl, string username, string password) { var url = baseUrl + (baseUrl.EndsWith("/") ? "" : "/") + "rest/api/2/"; restClient = new SimpleRestClient(url, username, password, GetErrorMessages); }
public PlaceEndpoint(ISimpleRestClient restClient) : base(restClient, "places") { }
public DailyEndpointBase(ISimpleRestClient restClient, string apiName) : base(restClient) { this.ApiName = apiName; }
public ProfileEndpoint(ISimpleRestClient restClient) : base(restClient) { }
public StorylineEndpoint(ISimpleRestClient restClient) : base(restClient, "storyline") { }
public EndpointBase(ISimpleRestClient restClient) { RestClient = restClient; }
public ActivityEndpoint(ISimpleRestClient restClient) : base(restClient, "activities") { }
private MovesClient CreateMovesClient(ISimpleRestClient restClient) { return(new TestableMovesClient(restClient)); }
public TestableMovesClient(ISimpleRestClient restClient) : base(restClient) { }