Example #1
0
        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);
        }
Example #2
0
        public TogglApi(ApiConfiguration configuration, IApiClient apiClient)
        {
            Ensure.Argument.IsNotNull(configuration, nameof(configuration));

            var userAgent   = configuration.UserAgent;
            var credentials = configuration.Credentials;
            var serializer  = new JsonSerializer();
            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);
            TimeEntriesReports = new TimeEntriesReportsApi(endpoints, apiClient, serializer, credentials);
            WorkspaceFeatures  = new WorkspaceFeaturesApi(endpoints, apiClient, serializer, credentials);
            Feedback           = new FeedbackApiClient(endpoints, apiClient, serializer, credentials);
            Timezones          = new TimezonesApi(endpoints, apiClient, serializer, credentials);
        }
 public void Init()
 {
     instance = new CountriesApi();
 }