private T GetCompanyMethod <T>(int companyId, CompanyMethods companyMethod, int page = 0, string language = null) where T : new() { RestRequest req = new RestRequest("company/{companyId}/{method}"); req.AddUrlSegment("companyId", companyId.ToString()); req.AddUrlSegment("method", companyMethod.GetDescription()); if (page >= 1) { req.AddParameter("page", page); } language = language ?? DefaultLanguage; if (!String.IsNullOrWhiteSpace(language)) { req.AddParameter("language", language); } IRestResponse <T> resp = _client.Get <T>(req); return(resp.Data); }
private async Task <T> GetCompanyMethod <T>(int companyId, CompanyMethods companyMethod, int page = 0, string language = null, CancellationToken cancellationToken = default(CancellationToken)) where T : new() { RestRequest req = _client.Create("company/{companyId}/{method}"); req.AddUrlSegment("companyId", companyId.ToString()); req.AddUrlSegment("method", companyMethod.GetDescription()); if (page >= 1) { req.AddParameter("page", page.ToString()); } language = language ?? DefaultLanguage; if (!string.IsNullOrWhiteSpace(language)) { req.AddParameter("language", language); } RestResponse <T> resp = await req.ExecuteGet <T>(cancellationToken).ConfigureAwait(false); return(resp); }