示例#1
0
        /// <summary>
        /// Update a time entry for the logged in user. Makes a POST request to the Daily/Update resource.
        /// </summary>
        /// <param name="dayEntryId">The ID of the time entry to update</param>
        /// <param name="spentAt">The new date of the entry</param>
        /// <param name="projectId">The new project ID of the entry</param>
        /// <param name="taskId">The new task ID of the entry</param>
        /// <param name="hours">The new hours for the entry</param>
        /// <param name="startedAt">The new start timestamp for the entry</param>
        /// <param name="endedAt">The new end timestamp for the entry</param>
        /// <param name="notes">The new notes for the entry</param>
        /// <param name="ofUser">The user the entry belongs to</param>
        public Timer UpdateDaily(long dayEntryId, DateTime?spentAt = null, long?projectId = null, long?taskId = null, decimal?hours = null, TimeSpan?startedAt = null, TimeSpan?endedAt = null, string notes = null, long?ofUser = null)
        {
            var options = new DailyOptions()
            {
                SpentAt   = spentAt,
                ProjectId = projectId,
                TaskId    = taskId,
                Notes     = notes
            };

            if (hours != null)
            {
                options.Hours = hours.Value.ToString("f2");
            }

            if (startedAt != null)
            {
                options.StartedAt = new DateTime(2000, 1, 1).Add(startedAt.Value).ToString("h:mmtt").ToLower();
            }

            if (endedAt != null)
            {
                options.EndedAt = new DateTime(2000, 1, 1).Add(endedAt.Value).ToString("h:mmtt").ToLower();
            }

            return(UpdateDaily(dayEntryId, options, ofUser));
        }
示例#2
0
        private IRestRequest CreateDailyRequest(DailyOptions options, long? ofUser)
        {
            var request = Request(ofUser != null ? $"daily/add?of_user={ofUser}" : "daily/add", Method.POST);

            request.AddBody(options);

            return request;
        }
示例#3
0
        /// <summary>
        /// Create a new time entry for the logged in user. Makes a POST request to the Daily/Add resource.
        /// </summary>
        /// <param name="options">The options for the time entry</param>
        /// <param name="ofUser">The user the day entry belongs to</param>
        internal Timer CreateDaily(DailyOptions options, long?ofUser)
        {
            var request = Request(ofUser != null ? string.Format("daily/add?of_user={0}", ofUser) : "daily/add", RestSharp.Method.POST);

            request.AddBody(options);

            return(Execute <Timer>(request));
        }
示例#4
0
        private IRestRequest CreateDailyRequest(DailyOptions options, long?ofUser)
        {
            var request = Request(ofUser != null ? $"{DailyResource}/add?{OfUserParameter}={ofUser}" : "daily/add",
                                  RestSharp.Method.POST);

            request.AddBody(options);

            return(request);
        }
示例#5
0
        /// <summary>
        /// Update a time entry for the logged in user. Makes a POST request to the Daily/Update resource.
        /// </summary>
        /// <param name="dayEntryId">The ID of the entry to update</param>
        /// <param name="options">The options to update</param>
        /// <param name="ofUser">The user the entry belongs to</param>
        internal Task<Timer> UpdateDailyAsync(long dayEntryId, DailyOptions options, long? ofUser)
        {
            var request = Request("daily/update/" + dayEntryId, Method.POST);

            if (ofUser != null)
                request.AddParameter("of_user", ofUser.Value);

            request.AddBody(options);

            return ExecuteAsync<Timer>(request);
        }
示例#6
0
        /// <summary>
        /// Starts a new timer for the logged in user. Makes a POST request to the Daily/Add resource.
        /// </summary>
        /// <param name="spentAt">The date of the entry</param>
        /// <param name="projectId">The project ID for the entry</param>
        /// <param name="taskId">The task ID for the entry</param>
        /// <param name="notes">The notes on the entry</param>
        /// <param name="ofUser">The user the day entry belongs to</param>
        public Timer StartTimer(DateTime spentAt, long projectId, long taskId, string notes = null, long?ofUser = null)
        {
            var options = new DailyOptions()
            {
                Notes     = notes,
                SpentAt   = spentAt,
                ProjectId = projectId,
                TaskId    = taskId,
                Hours     = " "
            };

            return(CreateDaily(options, ofUser));
        }
示例#7
0
        /// <summary>
        /// Update a time entry for the logged in user. Makes a POST request to the Daily/Update resource.
        /// </summary>
        /// <param name="dayEntryId">The ID of the entry to update</param>
        /// <param name="options">The options to update</param>
        /// <param name="ofUser">The user the entry belongs to</param>
        internal Timer UpdateDaily(long dayEntryId, DailyOptions options, long?ofUser)
        {
            var request = Request("daily/update/" + dayEntryId, RestSharp.Method.POST);

            if (ofUser != null)
            {
                request.AddParameter("of_user", ofUser.Value);
            }

            request.AddBody(options);

            return(Execute <Timer>(request));
        }
示例#8
0
        /// <summary>
        /// Create a new time entry for the logged in user. Makes a POST request to the Daily/Add resource.
        /// </summary>
        /// <param name="spentAt">The date of the entry</param>
        /// <param name="projectId">The project ID for the entry</param>
        /// <param name="taskId">The task ID for the entry</param>
        /// <param name="hours">The hours on the entry</param>
        /// <param name="notes">The notes on the entry</param>
        /// <param name="ofUser">The user the day entry belongs to</param>
        public Timer CreateDaily(DateTime spentAt, long projectId, long taskId, decimal hours, string notes = null, long?ofUser = null)
        {
            var options = new DailyOptions()
            {
                Notes     = notes,
                SpentAt   = spentAt,
                ProjectId = projectId,
                TaskId    = taskId,
                Hours     = hours.ToString("f2")
            };

            return(CreateDaily(options, ofUser));
        }
示例#9
0
        private IRestRequest UpdateDailyRequest(long dayEntryId, DailyOptions options, long?ofUser)
        {
            var request = Request($"{DailyResource}/{UpdateAction}/{dayEntryId}", RestSharp.Method.POST);

            if (ofUser != null)
            {
                request.AddParameter("of_user", ofUser.Value);
            }

            request.AddBody(options);

            return(request);
        }
示例#10
0
        /// <summary>
        /// Create a new time entry for the logged in user. Makes a POST request to the Daily/Add resource.
        /// </summary>
        /// <param name="spentAt">The date of the entry</param>
        /// <param name="projectId">The project ID for the entry</param>
        /// <param name="taskId">The task ID for the entry</param>
        /// <param name="startedAt">The start timestamp of the entry</param>
        /// <param name="endedAt">The end timestamp of the entry</param>
        /// <param name="notes">The notes on the entry</param>
        /// <param name="ofUser">The user the day entry belongs to</param>
        public Timer CreateDaily(DateTime spentAt, long projectId, long taskId, TimeSpan startedAt, TimeSpan endedAt, string notes = null, long?ofUser = null)
        {
            var options = new DailyOptions()
            {
                Notes     = notes,
                SpentAt   = spentAt,
                ProjectId = projectId,
                TaskId    = taskId,
                StartedAt = new DateTime(2000, 1, 1).Add(startedAt).ToString("h:mmtt").ToLower(),
                EndedAt   = new DateTime(2000, 1, 1).Add(endedAt).ToString("h:mmtt").ToLower()
            };

            return(CreateDaily(options, ofUser));
        }
示例#11
0
        /// <summary>
        /// Update a time entry for the logged in user. Makes a POST request to the Daily/Update resource.
        /// </summary>
        /// <param name="dayEntryId">The ID of the entry to update</param>
        /// <param name="options">The options to update</param>
        /// <param name="ofUser">The user the entry belongs to</param>
        internal Timer UpdateDaily(long dayEntryId, DailyOptions options, long?ofUser)
        {
            string path = "daily/update/" + dayEntryId;

            if (ofUser != null)
            {
                path = path + $"?of_user={ofUser.Value}";
            }

            var request = Request(path, RestSharp.Method.POST);

            request.AddBody(options);

            return(Execute <Timer>(request));
        }
示例#12
0
        private static DailyOptions GetUpdateDailyOptions(DateTime? spentAt, long? projectId, long? taskId, decimal? hours, TimeSpan? startedAt, TimeSpan? endedAt, string notes)
        {
            var options = new DailyOptions
            {
                SpentAt = spentAt,
                ProjectId = projectId,
                TaskId = taskId,
                Notes = notes
            };

            if (hours != null)
                options.Hours = hours.Value.ToString("f2");

            if (startedAt != null)
                options.StartedAt = new DateTime(2000, 1, 1).Add(startedAt.Value).ToString("h:mmtt").ToLower();

            if (endedAt != null)
                options.EndedAt = new DateTime(2000, 1, 1).Add(endedAt.Value).ToString("h:mmtt").ToLower();

            return options;
        }
示例#13
0
 /// <summary>
 /// Create a new time entry for the logged in user. Makes a POST request to the Daily/Add resource.
 /// </summary>
 /// <param name="options">The options for the time entry</param>
 /// <param name="ofUser">The user the day entry belongs to</param>
 internal Timer CreateDaily(DailyOptions options, long?ofUser)
 {
     return(Execute <Timer>(CreateDailyRequest(options, ofUser)));
 }
示例#14
0
 /// <summary>
 /// Create a new time entry for the logged in user. Makes a POST request to the Daily/Add resource.
 /// </summary>
 /// <param name="options">The options for the time entry</param>
 /// <param name="ofUser">The user the day entry belongs to</param>
 internal async Task <Timer> CreateDailyAsync(DailyOptions options, long?ofUser, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await ExecuteAsync <Timer>(CreateDailyRequest(options, ofUser), cancellationToken));
 }
示例#15
0
        /// <summary>
        /// Create a new time entry for the logged in user. Makes a POST request to the Daily/Add resource.
        /// </summary>
        /// <param name="options">The options for the time entry</param>
        /// <param name="ofUser">The user the day entry belongs to</param>
        internal Task<Timer> CreateDailyAsync(DailyOptions options, long? ofUser)
        {
            var request = CreateDailyRequest(options, ofUser);

            return ExecuteAsync<Timer>(request);
        }
示例#16
0
        /// <summary>
        /// Create a new time entry for the logged in user. Makes a POST request to the Daily/Add resource.
        /// </summary>
        /// <param name="options">The options for the time entry</param>
        /// <param name="ofUser">The user the day entry belongs to</param>
        internal Timer CreateDaily(DailyOptions options, long? ofUser)
        {
            var request = CreateDailyRequest(options, ofUser);

            return Execute<Timer>(request);
        }
示例#17
0
 /// <summary>
 /// Update a time entry for the logged in user. Makes a POST request to the Daily/Update resource.
 /// </summary>
 /// <param name="dayEntryId">The ID of the entry to update</param>
 /// <param name="options">The options to update</param>
 /// <param name="ofUser">The user the entry belongs to</param>
 internal Timer UpdateDaily(long dayEntryId, DailyOptions options, long?ofUser)
 {
     return(Execute <Timer>(UpdateDailyRequest(dayEntryId, options, ofUser)));
 }
示例#18
0
 /// <summary>
 /// Update a time entry for the logged in user. Makes a POST request to the Daily/Update resource.
 /// </summary>
 /// <param name="dayEntryId">The ID of the entry to update</param>
 /// <param name="options">The options to update</param>
 /// <param name="ofUser">The user the entry belongs to</param>
 internal async Task <Timer> UpdateDailyAsync(long dayEntryId, DailyOptions options, long?ofUser, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await ExecuteAsync <Timer>(UpdateDailyRequest(dayEntryId, options, ofUser), cancellationToken));
 }