コード例 #1
0
ファイル: RequestBuilder.cs プロジェクト: chaelli/Harvest.Api
        public RequestBuilder Body(string name, ExternalReference value)
        {
            if (value == null)
            {
                return(this);
            }

            if (_json == null)
            {
                _form.Add($"{name}.id", value.Id);
                _form.Add($"{name}.group_id", value.GroupId);
                _form.Add($"{name}.permalink", value.Permalink);
            }
            else
            {
                _json.Add(name, new JObject
                {
                    ["id"]        = value.Id,
                    ["group_id"]  = value.GroupId,
                    ["permalink"] = value.Permalink
                });
            }

            return(this);
        }
コード例 #2
0
        public RequestBuilder Form(string name, ExternalReference value)
        {
            if (value != null)
            {
                this.Form($"{name}.id", value.Id);
                this.Form($"{name}.group_id", value.GroupId);
                this.Form($"{name}.permalink", value.Permalink);
            }

            return(this);
        }
コード例 #3
0
        public RequestBuilder Json(string name, ExternalReference value)
        {
            if (value != null)
            {
                var jref = new JObject
                {
                    ["id"]        = value.Id,
                    ["group_id"]  = value.GroupId,
                    ["permalink"] = value.Permalink
                };

                _json[name] = jref;
            }
            ;

            return(this);
        }
コード例 #4
0
ファイル: HarvestClient.cs プロジェクト: sunnywiz/Harvest.Api
        public async Task <TimeEntry> UpdateTimeEntryAsync(long entryId,
                                                           long?projectId = null, long?taskId  = null, DateTime?spentDate = null, TimeSpan?startedTime = null, TimeSpan?endedTime = null,
                                                           decimal?hours  = null, string notes = null, ExternalReference externalReference = null,
                                                           long?accountId = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            await RefreshTokenIsNeeded();

            return(await SimpleRequestBuilder($"{harvestApiUrl}/time_entries/{entryId}", accountId, RequestBuilder.PatchMethod)
                   .Form("project_id", projectId)
                   .Form("task_id", taskId)
                   .Form("spent_date", spentDate, true)
                   .Form("started_time", startedTime)
                   .Form("ended_time", endedTime)
                   .Form("hours", hours)
                   .Form("notes", notes)
                   .Form("external_reference", externalReference)
                   .SendAsync <TimeEntry>(_httpClient, cancellationToken));
        }