public TogglApi(ApiConfiguration configuration, HttpClientHandler handler = null) { Ensure.Argument.IsNotNull(configuration, nameof(configuration)); var httpHandler = handler ?? new HttpClientHandler { AutomaticDecompression = GZip | Deflate }; var httpClient = new HttpClient(httpHandler); var userAgent = configuration.UserAgent; var credentials = configuration.Credentials; var serializer = new JsonSerializer(); var apiClient = new ApiClient(httpClient, userAgent); var endpoints = new Endpoints(configuration.Environment); Status = new StatusApi(endpoints, apiClient); Tags = new TagsApi(endpoints, apiClient, serializer, credentials); User = new UserApi(endpoints, apiClient, serializer, credentials); Tasks = new TasksApi(endpoints, apiClient, serializer, credentials); Clients = new ClientsApi(endpoints, apiClient, serializer, credentials); Projects = new ProjectsApi(endpoints, apiClient, serializer, credentials); Location = new LocationApi(endpoints, apiClient, serializer, credentials); Countries = new CountriesApi(endpoints, apiClient, serializer, credentials); Workspaces = new WorkspacesApi(endpoints, apiClient, serializer, credentials); Preferences = new PreferencesApi(endpoints, apiClient, serializer, credentials); ProjectsSummary = new ProjectsSummaryApi(endpoints, apiClient, serializer, credentials); TimeEntries = new TimeEntriesApi(endpoints, apiClient, serializer, credentials, userAgent); WorkspaceFeatures = new WorkspaceFeaturesApi(endpoints, apiClient, serializer, credentials); }
public TheDeleteMethod() { api = new TimeEntriesApi( new Endpoints(ApiEnvironment.Staging), apiClient, jsonSerializer, credentials, new UserAgent("unit tests", "0.0")); }
public TimeEntry CreateNewTimeEntry(TimeEntry timeEntry) { var api = new TimeEntriesApi(apiClient); var response = api.CreateEntry(timeEntry); if (!response.IsSuccessResponse()) { throw new ApplicationException(response.GetError().Message); } return(response.GetResult <TimeEntry>()); }
public List <TimeEntry> GetTimeEntryList(DateTime startDate, DateTime endDate, string memberID) { var api = new TimeEntriesApi(apiClient); var conditions = "Member/Identifier = '" + memberID + "' AND TimeStart >= [" + startDate.ToString("yyyy-MM-dd HH:mm:ss") + "] AND TimeStart <= [" + endDate.ToString("yyyy-MM-dd HH:mm:ss") + "]"; var response = api.GetEntries(conditions, "TimeStart, TimeEnd desc", null, null, null, 200); if (!response.IsSuccessResponse()) { throw new ApplicationException(response.GetError().Message); } return(response.GetResult <List <TimeEntry> >()); }
public TogglApi(ApiConfiguration configuration, HttpClientHandler handler = null) { Ensure.Argument.IsNotNull(configuration, nameof(configuration)); var httpHandler = handler ?? new NativeMessageHandler { AutomaticDecompression = GZip | Deflate }; var httpClient = new HttpClient(httpHandler); var credentials = configuration.Credentials; var serializer = new JsonSerializer(); var apiClient = new ApiClient(httpClient, configuration.UserAgent); var endpoints = new Endpoints(configuration.Environment); Tags = new TagsApi(endpoints.Tags, apiClient, serializer, credentials); User = new UserApi(endpoints.User, apiClient, serializer, credentials); Tasks = new TasksApi(); Status = new StatusApi(endpoints.Status, apiClient); Clients = new ClientsApi(endpoints.Clients, apiClient, serializer, credentials); Projects = new ProjectsApi(endpoints.Projects, apiClient, serializer, credentials); Workspaces = new WorkspacesApi(endpoints.Workspaces, apiClient, serializer, credentials); TimeEntries = new TimeEntriesApi(endpoints.TimeEntries, apiClient, serializer, credentials); }