1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 package tasks
57
58 import (
59 "bytes"
60 "context"
61 "encoding/json"
62 "errors"
63 "fmt"
64 "io"
65 "net/http"
66 "net/url"
67 "strconv"
68 "strings"
69
70 googleapi "google.golang.org/api/googleapi"
71 internal "google.golang.org/api/internal"
72 gensupport "google.golang.org/api/internal/gensupport"
73 option "google.golang.org/api/option"
74 internaloption "google.golang.org/api/option/internaloption"
75 htransport "google.golang.org/api/transport/http"
76 )
77
78
79
80 var _ = bytes.NewBuffer
81 var _ = strconv.Itoa
82 var _ = fmt.Sprintf
83 var _ = json.NewDecoder
84 var _ = io.Copy
85 var _ = url.Parse
86 var _ = gensupport.MarshalJSON
87 var _ = googleapi.Version
88 var _ = errors.New
89 var _ = strings.Replace
90 var _ = context.Canceled
91 var _ = internaloption.WithDefaultEndpoint
92 var _ = internal.Version
93
94 const apiId = "tasks:v1"
95 const apiName = "tasks"
96 const apiVersion = "v1"
97 const basePath = "https://tasks.googleapis.com/"
98 const basePathTemplate = "https://tasks.UNIVERSE_DOMAIN/"
99 const mtlsBasePath = "https://tasks.mtls.googleapis.com/"
100
101
102 const (
103
104 TasksScope = "https://www.googleapis.com/auth/tasks"
105
106
107 TasksReadonlyScope = "https://www.googleapis.com/auth/tasks.readonly"
108 )
109
110
111 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
112 scopesOption := internaloption.WithDefaultScopes(
113 "https://www.googleapis.com/auth/tasks",
114 "https://www.googleapis.com/auth/tasks.readonly",
115 )
116
117 opts = append([]option.ClientOption{scopesOption}, opts...)
118 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
119 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
120 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
121 opts = append(opts, internaloption.EnableNewAuthLibrary())
122 client, endpoint, err := htransport.NewClient(ctx, opts...)
123 if err != nil {
124 return nil, err
125 }
126 s, err := New(client)
127 if err != nil {
128 return nil, err
129 }
130 if endpoint != "" {
131 s.BasePath = endpoint
132 }
133 return s, nil
134 }
135
136
137
138
139
140
141 func New(client *http.Client) (*Service, error) {
142 if client == nil {
143 return nil, errors.New("client is nil")
144 }
145 s := &Service{client: client, BasePath: basePath}
146 s.Tasklists = NewTasklistsService(s)
147 s.Tasks = NewTasksService(s)
148 return s, nil
149 }
150
151 type Service struct {
152 client *http.Client
153 BasePath string
154 UserAgent string
155
156 Tasklists *TasklistsService
157
158 Tasks *TasksService
159 }
160
161 func (s *Service) userAgent() string {
162 if s.UserAgent == "" {
163 return googleapi.UserAgent
164 }
165 return googleapi.UserAgent + " " + s.UserAgent
166 }
167
168 func NewTasklistsService(s *Service) *TasklistsService {
169 rs := &TasklistsService{s: s}
170 return rs
171 }
172
173 type TasklistsService struct {
174 s *Service
175 }
176
177 func NewTasksService(s *Service) *TasksService {
178 rs := &TasksService{s: s}
179 return rs
180 }
181
182 type TasksService struct {
183 s *Service
184 }
185
186 type Task struct {
187
188
189 Completed *string `json:"completed,omitempty"`
190
191
192 Deleted bool `json:"deleted,omitempty"`
193
194
195
196
197 Due string `json:"due,omitempty"`
198
199 Etag string `json:"etag,omitempty"`
200
201
202
203 Hidden bool `json:"hidden,omitempty"`
204
205 Id string `json:"id,omitempty"`
206
207 Kind string `json:"kind,omitempty"`
208
209 Links []*TaskLinks `json:"links,omitempty"`
210
211
212 Notes string `json:"notes,omitempty"`
213
214
215
216 Parent string `json:"parent,omitempty"`
217
218
219
220
221
222
223 Position string `json:"position,omitempty"`
224
225
226 SelfLink string `json:"selfLink,omitempty"`
227
228 Status string `json:"status,omitempty"`
229
230 Title string `json:"title,omitempty"`
231
232 Updated string `json:"updated,omitempty"`
233
234
235 WebViewLink string `json:"webViewLink,omitempty"`
236
237
238 googleapi.ServerResponse `json:"-"`
239
240
241
242
243
244 ForceSendFields []string `json:"-"`
245
246
247
248
249 NullFields []string `json:"-"`
250 }
251
252 func (s *Task) MarshalJSON() ([]byte, error) {
253 type NoMethod Task
254 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
255 }
256
257 type TaskLinks struct {
258
259
260 Description string `json:"description,omitempty"`
261
262 Link string `json:"link,omitempty"`
263
264 Type string `json:"type,omitempty"`
265
266
267
268
269
270 ForceSendFields []string `json:"-"`
271
272
273
274
275 NullFields []string `json:"-"`
276 }
277
278 func (s *TaskLinks) MarshalJSON() ([]byte, error) {
279 type NoMethod TaskLinks
280 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
281 }
282
283 type TaskList struct {
284
285 Etag string `json:"etag,omitempty"`
286
287 Id string `json:"id,omitempty"`
288
289 Kind string `json:"kind,omitempty"`
290
291
292 SelfLink string `json:"selfLink,omitempty"`
293
294 Title string `json:"title,omitempty"`
295
296 Updated string `json:"updated,omitempty"`
297
298
299 googleapi.ServerResponse `json:"-"`
300
301
302
303
304
305 ForceSendFields []string `json:"-"`
306
307
308
309
310 NullFields []string `json:"-"`
311 }
312
313 func (s *TaskList) MarshalJSON() ([]byte, error) {
314 type NoMethod TaskList
315 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
316 }
317
318 type TaskLists struct {
319
320 Etag string `json:"etag,omitempty"`
321
322 Items []*TaskList `json:"items,omitempty"`
323
324 Kind string `json:"kind,omitempty"`
325
326
327 NextPageToken string `json:"nextPageToken,omitempty"`
328
329
330 googleapi.ServerResponse `json:"-"`
331
332
333
334
335
336 ForceSendFields []string `json:"-"`
337
338
339
340
341 NullFields []string `json:"-"`
342 }
343
344 func (s *TaskLists) MarshalJSON() ([]byte, error) {
345 type NoMethod TaskLists
346 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
347 }
348
349 type Tasks struct {
350
351 Etag string `json:"etag,omitempty"`
352
353 Items []*Task `json:"items,omitempty"`
354
355 Kind string `json:"kind,omitempty"`
356
357 NextPageToken string `json:"nextPageToken,omitempty"`
358
359
360 googleapi.ServerResponse `json:"-"`
361
362
363
364
365
366 ForceSendFields []string `json:"-"`
367
368
369
370
371 NullFields []string `json:"-"`
372 }
373
374 func (s *Tasks) MarshalJSON() ([]byte, error) {
375 type NoMethod Tasks
376 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
377 }
378
379 type TasklistsDeleteCall struct {
380 s *Service
381 tasklistid string
382 urlParams_ gensupport.URLParams
383 ctx_ context.Context
384 header_ http.Header
385 }
386
387
388
389
390 func (r *TasklistsService) Delete(tasklistid string) *TasklistsDeleteCall {
391 c := &TasklistsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
392 c.tasklistid = tasklistid
393 return c
394 }
395
396
397
398
399 func (c *TasklistsDeleteCall) Fields(s ...googleapi.Field) *TasklistsDeleteCall {
400 c.urlParams_.Set("fields", googleapi.CombineFields(s))
401 return c
402 }
403
404
405 func (c *TasklistsDeleteCall) Context(ctx context.Context) *TasklistsDeleteCall {
406 c.ctx_ = ctx
407 return c
408 }
409
410
411
412 func (c *TasklistsDeleteCall) Header() http.Header {
413 if c.header_ == nil {
414 c.header_ = make(http.Header)
415 }
416 return c.header_
417 }
418
419 func (c *TasklistsDeleteCall) doRequest(alt string) (*http.Response, error) {
420 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
421 var body io.Reader = nil
422 c.urlParams_.Set("alt", alt)
423 c.urlParams_.Set("prettyPrint", "false")
424 urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/users/@me/lists/{tasklist}")
425 urls += "?" + c.urlParams_.Encode()
426 req, err := http.NewRequest("DELETE", urls, body)
427 if err != nil {
428 return nil, err
429 }
430 req.Header = reqHeaders
431 googleapi.Expand(req.URL, map[string]string{
432 "tasklist": c.tasklistid,
433 })
434 return gensupport.SendRequest(c.ctx_, c.s.client, req)
435 }
436
437
438 func (c *TasklistsDeleteCall) Do(opts ...googleapi.CallOption) error {
439 gensupport.SetOptions(c.urlParams_, opts...)
440 res, err := c.doRequest("json")
441 if err != nil {
442 return err
443 }
444 defer googleapi.CloseBody(res)
445 if err := googleapi.CheckResponse(res); err != nil {
446 return gensupport.WrapError(err)
447 }
448 return nil
449 }
450
451 type TasklistsGetCall struct {
452 s *Service
453 tasklistid string
454 urlParams_ gensupport.URLParams
455 ifNoneMatch_ string
456 ctx_ context.Context
457 header_ http.Header
458 }
459
460
461
462
463 func (r *TasklistsService) Get(tasklistid string) *TasklistsGetCall {
464 c := &TasklistsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
465 c.tasklistid = tasklistid
466 return c
467 }
468
469
470
471
472 func (c *TasklistsGetCall) Fields(s ...googleapi.Field) *TasklistsGetCall {
473 c.urlParams_.Set("fields", googleapi.CombineFields(s))
474 return c
475 }
476
477
478
479
480 func (c *TasklistsGetCall) IfNoneMatch(entityTag string) *TasklistsGetCall {
481 c.ifNoneMatch_ = entityTag
482 return c
483 }
484
485
486 func (c *TasklistsGetCall) Context(ctx context.Context) *TasklistsGetCall {
487 c.ctx_ = ctx
488 return c
489 }
490
491
492
493 func (c *TasklistsGetCall) Header() http.Header {
494 if c.header_ == nil {
495 c.header_ = make(http.Header)
496 }
497 return c.header_
498 }
499
500 func (c *TasklistsGetCall) doRequest(alt string) (*http.Response, error) {
501 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
502 if c.ifNoneMatch_ != "" {
503 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
504 }
505 var body io.Reader = nil
506 c.urlParams_.Set("alt", alt)
507 c.urlParams_.Set("prettyPrint", "false")
508 urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/users/@me/lists/{tasklist}")
509 urls += "?" + c.urlParams_.Encode()
510 req, err := http.NewRequest("GET", urls, body)
511 if err != nil {
512 return nil, err
513 }
514 req.Header = reqHeaders
515 googleapi.Expand(req.URL, map[string]string{
516 "tasklist": c.tasklistid,
517 })
518 return gensupport.SendRequest(c.ctx_, c.s.client, req)
519 }
520
521
522
523
524
525
526 func (c *TasklistsGetCall) Do(opts ...googleapi.CallOption) (*TaskList, error) {
527 gensupport.SetOptions(c.urlParams_, opts...)
528 res, err := c.doRequest("json")
529 if res != nil && res.StatusCode == http.StatusNotModified {
530 if res.Body != nil {
531 res.Body.Close()
532 }
533 return nil, gensupport.WrapError(&googleapi.Error{
534 Code: res.StatusCode,
535 Header: res.Header,
536 })
537 }
538 if err != nil {
539 return nil, err
540 }
541 defer googleapi.CloseBody(res)
542 if err := googleapi.CheckResponse(res); err != nil {
543 return nil, gensupport.WrapError(err)
544 }
545 ret := &TaskList{
546 ServerResponse: googleapi.ServerResponse{
547 Header: res.Header,
548 HTTPStatusCode: res.StatusCode,
549 },
550 }
551 target := &ret
552 if err := gensupport.DecodeResponse(target, res); err != nil {
553 return nil, err
554 }
555 return ret, nil
556 }
557
558 type TasklistsInsertCall struct {
559 s *Service
560 tasklist *TaskList
561 urlParams_ gensupport.URLParams
562 ctx_ context.Context
563 header_ http.Header
564 }
565
566
567
568 func (r *TasklistsService) Insert(tasklist *TaskList) *TasklistsInsertCall {
569 c := &TasklistsInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
570 c.tasklist = tasklist
571 return c
572 }
573
574
575
576
577 func (c *TasklistsInsertCall) Fields(s ...googleapi.Field) *TasklistsInsertCall {
578 c.urlParams_.Set("fields", googleapi.CombineFields(s))
579 return c
580 }
581
582
583 func (c *TasklistsInsertCall) Context(ctx context.Context) *TasklistsInsertCall {
584 c.ctx_ = ctx
585 return c
586 }
587
588
589
590 func (c *TasklistsInsertCall) Header() http.Header {
591 if c.header_ == nil {
592 c.header_ = make(http.Header)
593 }
594 return c.header_
595 }
596
597 func (c *TasklistsInsertCall) doRequest(alt string) (*http.Response, error) {
598 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
599 var body io.Reader = nil
600 body, err := googleapi.WithoutDataWrapper.JSONReader(c.tasklist)
601 if err != nil {
602 return nil, err
603 }
604 c.urlParams_.Set("alt", alt)
605 c.urlParams_.Set("prettyPrint", "false")
606 urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/users/@me/lists")
607 urls += "?" + c.urlParams_.Encode()
608 req, err := http.NewRequest("POST", urls, body)
609 if err != nil {
610 return nil, err
611 }
612 req.Header = reqHeaders
613 return gensupport.SendRequest(c.ctx_, c.s.client, req)
614 }
615
616
617
618
619
620
621 func (c *TasklistsInsertCall) Do(opts ...googleapi.CallOption) (*TaskList, error) {
622 gensupport.SetOptions(c.urlParams_, opts...)
623 res, err := c.doRequest("json")
624 if res != nil && res.StatusCode == http.StatusNotModified {
625 if res.Body != nil {
626 res.Body.Close()
627 }
628 return nil, gensupport.WrapError(&googleapi.Error{
629 Code: res.StatusCode,
630 Header: res.Header,
631 })
632 }
633 if err != nil {
634 return nil, err
635 }
636 defer googleapi.CloseBody(res)
637 if err := googleapi.CheckResponse(res); err != nil {
638 return nil, gensupport.WrapError(err)
639 }
640 ret := &TaskList{
641 ServerResponse: googleapi.ServerResponse{
642 Header: res.Header,
643 HTTPStatusCode: res.StatusCode,
644 },
645 }
646 target := &ret
647 if err := gensupport.DecodeResponse(target, res); err != nil {
648 return nil, err
649 }
650 return ret, nil
651 }
652
653 type TasklistsListCall struct {
654 s *Service
655 urlParams_ gensupport.URLParams
656 ifNoneMatch_ string
657 ctx_ context.Context
658 header_ http.Header
659 }
660
661
662
663 func (r *TasklistsService) List() *TasklistsListCall {
664 c := &TasklistsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
665 return c
666 }
667
668
669
670 func (c *TasklistsListCall) MaxResults(maxResults int64) *TasklistsListCall {
671 c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
672 return c
673 }
674
675
676
677 func (c *TasklistsListCall) PageToken(pageToken string) *TasklistsListCall {
678 c.urlParams_.Set("pageToken", pageToken)
679 return c
680 }
681
682
683
684
685 func (c *TasklistsListCall) Fields(s ...googleapi.Field) *TasklistsListCall {
686 c.urlParams_.Set("fields", googleapi.CombineFields(s))
687 return c
688 }
689
690
691
692
693 func (c *TasklistsListCall) IfNoneMatch(entityTag string) *TasklistsListCall {
694 c.ifNoneMatch_ = entityTag
695 return c
696 }
697
698
699 func (c *TasklistsListCall) Context(ctx context.Context) *TasklistsListCall {
700 c.ctx_ = ctx
701 return c
702 }
703
704
705
706 func (c *TasklistsListCall) Header() http.Header {
707 if c.header_ == nil {
708 c.header_ = make(http.Header)
709 }
710 return c.header_
711 }
712
713 func (c *TasklistsListCall) doRequest(alt string) (*http.Response, error) {
714 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
715 if c.ifNoneMatch_ != "" {
716 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
717 }
718 var body io.Reader = nil
719 c.urlParams_.Set("alt", alt)
720 c.urlParams_.Set("prettyPrint", "false")
721 urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/users/@me/lists")
722 urls += "?" + c.urlParams_.Encode()
723 req, err := http.NewRequest("GET", urls, body)
724 if err != nil {
725 return nil, err
726 }
727 req.Header = reqHeaders
728 return gensupport.SendRequest(c.ctx_, c.s.client, req)
729 }
730
731
732
733
734
735
736 func (c *TasklistsListCall) Do(opts ...googleapi.CallOption) (*TaskLists, error) {
737 gensupport.SetOptions(c.urlParams_, opts...)
738 res, err := c.doRequest("json")
739 if res != nil && res.StatusCode == http.StatusNotModified {
740 if res.Body != nil {
741 res.Body.Close()
742 }
743 return nil, gensupport.WrapError(&googleapi.Error{
744 Code: res.StatusCode,
745 Header: res.Header,
746 })
747 }
748 if err != nil {
749 return nil, err
750 }
751 defer googleapi.CloseBody(res)
752 if err := googleapi.CheckResponse(res); err != nil {
753 return nil, gensupport.WrapError(err)
754 }
755 ret := &TaskLists{
756 ServerResponse: googleapi.ServerResponse{
757 Header: res.Header,
758 HTTPStatusCode: res.StatusCode,
759 },
760 }
761 target := &ret
762 if err := gensupport.DecodeResponse(target, res); err != nil {
763 return nil, err
764 }
765 return ret, nil
766 }
767
768
769
770
771 func (c *TasklistsListCall) Pages(ctx context.Context, f func(*TaskLists) error) error {
772 c.ctx_ = ctx
773 defer c.PageToken(c.urlParams_.Get("pageToken"))
774 for {
775 x, err := c.Do()
776 if err != nil {
777 return err
778 }
779 if err := f(x); err != nil {
780 return err
781 }
782 if x.NextPageToken == "" {
783 return nil
784 }
785 c.PageToken(x.NextPageToken)
786 }
787 }
788
789 type TasklistsPatchCall struct {
790 s *Service
791 tasklistid string
792 tasklist *TaskList
793 urlParams_ gensupport.URLParams
794 ctx_ context.Context
795 header_ http.Header
796 }
797
798
799
800
801
802 func (r *TasklistsService) Patch(tasklistid string, tasklist *TaskList) *TasklistsPatchCall {
803 c := &TasklistsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
804 c.tasklistid = tasklistid
805 c.tasklist = tasklist
806 return c
807 }
808
809
810
811
812 func (c *TasklistsPatchCall) Fields(s ...googleapi.Field) *TasklistsPatchCall {
813 c.urlParams_.Set("fields", googleapi.CombineFields(s))
814 return c
815 }
816
817
818 func (c *TasklistsPatchCall) Context(ctx context.Context) *TasklistsPatchCall {
819 c.ctx_ = ctx
820 return c
821 }
822
823
824
825 func (c *TasklistsPatchCall) Header() http.Header {
826 if c.header_ == nil {
827 c.header_ = make(http.Header)
828 }
829 return c.header_
830 }
831
832 func (c *TasklistsPatchCall) doRequest(alt string) (*http.Response, error) {
833 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
834 var body io.Reader = nil
835 body, err := googleapi.WithoutDataWrapper.JSONReader(c.tasklist)
836 if err != nil {
837 return nil, err
838 }
839 c.urlParams_.Set("alt", alt)
840 c.urlParams_.Set("prettyPrint", "false")
841 urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/users/@me/lists/{tasklist}")
842 urls += "?" + c.urlParams_.Encode()
843 req, err := http.NewRequest("PATCH", urls, body)
844 if err != nil {
845 return nil, err
846 }
847 req.Header = reqHeaders
848 googleapi.Expand(req.URL, map[string]string{
849 "tasklist": c.tasklistid,
850 })
851 return gensupport.SendRequest(c.ctx_, c.s.client, req)
852 }
853
854
855
856
857
858
859 func (c *TasklistsPatchCall) Do(opts ...googleapi.CallOption) (*TaskList, error) {
860 gensupport.SetOptions(c.urlParams_, opts...)
861 res, err := c.doRequest("json")
862 if res != nil && res.StatusCode == http.StatusNotModified {
863 if res.Body != nil {
864 res.Body.Close()
865 }
866 return nil, gensupport.WrapError(&googleapi.Error{
867 Code: res.StatusCode,
868 Header: res.Header,
869 })
870 }
871 if err != nil {
872 return nil, err
873 }
874 defer googleapi.CloseBody(res)
875 if err := googleapi.CheckResponse(res); err != nil {
876 return nil, gensupport.WrapError(err)
877 }
878 ret := &TaskList{
879 ServerResponse: googleapi.ServerResponse{
880 Header: res.Header,
881 HTTPStatusCode: res.StatusCode,
882 },
883 }
884 target := &ret
885 if err := gensupport.DecodeResponse(target, res); err != nil {
886 return nil, err
887 }
888 return ret, nil
889 }
890
891 type TasklistsUpdateCall struct {
892 s *Service
893 tasklistid string
894 tasklist *TaskList
895 urlParams_ gensupport.URLParams
896 ctx_ context.Context
897 header_ http.Header
898 }
899
900
901
902
903 func (r *TasklistsService) Update(tasklistid string, tasklist *TaskList) *TasklistsUpdateCall {
904 c := &TasklistsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
905 c.tasklistid = tasklistid
906 c.tasklist = tasklist
907 return c
908 }
909
910
911
912
913 func (c *TasklistsUpdateCall) Fields(s ...googleapi.Field) *TasklistsUpdateCall {
914 c.urlParams_.Set("fields", googleapi.CombineFields(s))
915 return c
916 }
917
918
919 func (c *TasklistsUpdateCall) Context(ctx context.Context) *TasklistsUpdateCall {
920 c.ctx_ = ctx
921 return c
922 }
923
924
925
926 func (c *TasklistsUpdateCall) Header() http.Header {
927 if c.header_ == nil {
928 c.header_ = make(http.Header)
929 }
930 return c.header_
931 }
932
933 func (c *TasklistsUpdateCall) doRequest(alt string) (*http.Response, error) {
934 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
935 var body io.Reader = nil
936 body, err := googleapi.WithoutDataWrapper.JSONReader(c.tasklist)
937 if err != nil {
938 return nil, err
939 }
940 c.urlParams_.Set("alt", alt)
941 c.urlParams_.Set("prettyPrint", "false")
942 urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/users/@me/lists/{tasklist}")
943 urls += "?" + c.urlParams_.Encode()
944 req, err := http.NewRequest("PUT", urls, body)
945 if err != nil {
946 return nil, err
947 }
948 req.Header = reqHeaders
949 googleapi.Expand(req.URL, map[string]string{
950 "tasklist": c.tasklistid,
951 })
952 return gensupport.SendRequest(c.ctx_, c.s.client, req)
953 }
954
955
956
957
958
959
960 func (c *TasklistsUpdateCall) Do(opts ...googleapi.CallOption) (*TaskList, error) {
961 gensupport.SetOptions(c.urlParams_, opts...)
962 res, err := c.doRequest("json")
963 if res != nil && res.StatusCode == http.StatusNotModified {
964 if res.Body != nil {
965 res.Body.Close()
966 }
967 return nil, gensupport.WrapError(&googleapi.Error{
968 Code: res.StatusCode,
969 Header: res.Header,
970 })
971 }
972 if err != nil {
973 return nil, err
974 }
975 defer googleapi.CloseBody(res)
976 if err := googleapi.CheckResponse(res); err != nil {
977 return nil, gensupport.WrapError(err)
978 }
979 ret := &TaskList{
980 ServerResponse: googleapi.ServerResponse{
981 Header: res.Header,
982 HTTPStatusCode: res.StatusCode,
983 },
984 }
985 target := &ret
986 if err := gensupport.DecodeResponse(target, res); err != nil {
987 return nil, err
988 }
989 return ret, nil
990 }
991
992 type TasksClearCall struct {
993 s *Service
994 tasklistid string
995 urlParams_ gensupport.URLParams
996 ctx_ context.Context
997 header_ http.Header
998 }
999
1000
1001
1002
1003
1004
1005 func (r *TasksService) Clear(tasklistid string) *TasksClearCall {
1006 c := &TasksClearCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1007 c.tasklistid = tasklistid
1008 return c
1009 }
1010
1011
1012
1013
1014 func (c *TasksClearCall) Fields(s ...googleapi.Field) *TasksClearCall {
1015 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1016 return c
1017 }
1018
1019
1020 func (c *TasksClearCall) Context(ctx context.Context) *TasksClearCall {
1021 c.ctx_ = ctx
1022 return c
1023 }
1024
1025
1026
1027 func (c *TasksClearCall) Header() http.Header {
1028 if c.header_ == nil {
1029 c.header_ = make(http.Header)
1030 }
1031 return c.header_
1032 }
1033
1034 func (c *TasksClearCall) doRequest(alt string) (*http.Response, error) {
1035 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1036 var body io.Reader = nil
1037 c.urlParams_.Set("alt", alt)
1038 c.urlParams_.Set("prettyPrint", "false")
1039 urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/clear")
1040 urls += "?" + c.urlParams_.Encode()
1041 req, err := http.NewRequest("POST", urls, body)
1042 if err != nil {
1043 return nil, err
1044 }
1045 req.Header = reqHeaders
1046 googleapi.Expand(req.URL, map[string]string{
1047 "tasklist": c.tasklistid,
1048 })
1049 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1050 }
1051
1052
1053 func (c *TasksClearCall) Do(opts ...googleapi.CallOption) error {
1054 gensupport.SetOptions(c.urlParams_, opts...)
1055 res, err := c.doRequest("json")
1056 if err != nil {
1057 return err
1058 }
1059 defer googleapi.CloseBody(res)
1060 if err := googleapi.CheckResponse(res); err != nil {
1061 return gensupport.WrapError(err)
1062 }
1063 return nil
1064 }
1065
1066 type TasksDeleteCall struct {
1067 s *Service
1068 tasklistid string
1069 taskid string
1070 urlParams_ gensupport.URLParams
1071 ctx_ context.Context
1072 header_ http.Header
1073 }
1074
1075
1076
1077
1078
1079 func (r *TasksService) Delete(tasklistid string, taskid string) *TasksDeleteCall {
1080 c := &TasksDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1081 c.tasklistid = tasklistid
1082 c.taskid = taskid
1083 return c
1084 }
1085
1086
1087
1088
1089 func (c *TasksDeleteCall) Fields(s ...googleapi.Field) *TasksDeleteCall {
1090 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1091 return c
1092 }
1093
1094
1095 func (c *TasksDeleteCall) Context(ctx context.Context) *TasksDeleteCall {
1096 c.ctx_ = ctx
1097 return c
1098 }
1099
1100
1101
1102 func (c *TasksDeleteCall) Header() http.Header {
1103 if c.header_ == nil {
1104 c.header_ = make(http.Header)
1105 }
1106 return c.header_
1107 }
1108
1109 func (c *TasksDeleteCall) doRequest(alt string) (*http.Response, error) {
1110 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1111 var body io.Reader = nil
1112 c.urlParams_.Set("alt", alt)
1113 c.urlParams_.Set("prettyPrint", "false")
1114 urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/tasks/{task}")
1115 urls += "?" + c.urlParams_.Encode()
1116 req, err := http.NewRequest("DELETE", urls, body)
1117 if err != nil {
1118 return nil, err
1119 }
1120 req.Header = reqHeaders
1121 googleapi.Expand(req.URL, map[string]string{
1122 "tasklist": c.tasklistid,
1123 "task": c.taskid,
1124 })
1125 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1126 }
1127
1128
1129 func (c *TasksDeleteCall) Do(opts ...googleapi.CallOption) error {
1130 gensupport.SetOptions(c.urlParams_, opts...)
1131 res, err := c.doRequest("json")
1132 if err != nil {
1133 return err
1134 }
1135 defer googleapi.CloseBody(res)
1136 if err := googleapi.CheckResponse(res); err != nil {
1137 return gensupport.WrapError(err)
1138 }
1139 return nil
1140 }
1141
1142 type TasksGetCall struct {
1143 s *Service
1144 tasklistid string
1145 taskid string
1146 urlParams_ gensupport.URLParams
1147 ifNoneMatch_ string
1148 ctx_ context.Context
1149 header_ http.Header
1150 }
1151
1152
1153
1154
1155
1156 func (r *TasksService) Get(tasklistid string, taskid string) *TasksGetCall {
1157 c := &TasksGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1158 c.tasklistid = tasklistid
1159 c.taskid = taskid
1160 return c
1161 }
1162
1163
1164
1165
1166 func (c *TasksGetCall) Fields(s ...googleapi.Field) *TasksGetCall {
1167 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1168 return c
1169 }
1170
1171
1172
1173
1174 func (c *TasksGetCall) IfNoneMatch(entityTag string) *TasksGetCall {
1175 c.ifNoneMatch_ = entityTag
1176 return c
1177 }
1178
1179
1180 func (c *TasksGetCall) Context(ctx context.Context) *TasksGetCall {
1181 c.ctx_ = ctx
1182 return c
1183 }
1184
1185
1186
1187 func (c *TasksGetCall) Header() http.Header {
1188 if c.header_ == nil {
1189 c.header_ = make(http.Header)
1190 }
1191 return c.header_
1192 }
1193
1194 func (c *TasksGetCall) doRequest(alt string) (*http.Response, error) {
1195 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1196 if c.ifNoneMatch_ != "" {
1197 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1198 }
1199 var body io.Reader = nil
1200 c.urlParams_.Set("alt", alt)
1201 c.urlParams_.Set("prettyPrint", "false")
1202 urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/tasks/{task}")
1203 urls += "?" + c.urlParams_.Encode()
1204 req, err := http.NewRequest("GET", urls, body)
1205 if err != nil {
1206 return nil, err
1207 }
1208 req.Header = reqHeaders
1209 googleapi.Expand(req.URL, map[string]string{
1210 "tasklist": c.tasklistid,
1211 "task": c.taskid,
1212 })
1213 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1214 }
1215
1216
1217
1218
1219
1220
1221 func (c *TasksGetCall) Do(opts ...googleapi.CallOption) (*Task, error) {
1222 gensupport.SetOptions(c.urlParams_, opts...)
1223 res, err := c.doRequest("json")
1224 if res != nil && res.StatusCode == http.StatusNotModified {
1225 if res.Body != nil {
1226 res.Body.Close()
1227 }
1228 return nil, gensupport.WrapError(&googleapi.Error{
1229 Code: res.StatusCode,
1230 Header: res.Header,
1231 })
1232 }
1233 if err != nil {
1234 return nil, err
1235 }
1236 defer googleapi.CloseBody(res)
1237 if err := googleapi.CheckResponse(res); err != nil {
1238 return nil, gensupport.WrapError(err)
1239 }
1240 ret := &Task{
1241 ServerResponse: googleapi.ServerResponse{
1242 Header: res.Header,
1243 HTTPStatusCode: res.StatusCode,
1244 },
1245 }
1246 target := &ret
1247 if err := gensupport.DecodeResponse(target, res); err != nil {
1248 return nil, err
1249 }
1250 return ret, nil
1251 }
1252
1253 type TasksInsertCall struct {
1254 s *Service
1255 tasklistid string
1256 task *Task
1257 urlParams_ gensupport.URLParams
1258 ctx_ context.Context
1259 header_ http.Header
1260 }
1261
1262
1263
1264
1265
1266 func (r *TasksService) Insert(tasklistid string, task *Task) *TasksInsertCall {
1267 c := &TasksInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1268 c.tasklistid = tasklistid
1269 c.task = task
1270 return c
1271 }
1272
1273
1274
1275 func (c *TasksInsertCall) Parent(parent string) *TasksInsertCall {
1276 c.urlParams_.Set("parent", parent)
1277 return c
1278 }
1279
1280
1281
1282
1283 func (c *TasksInsertCall) Previous(previous string) *TasksInsertCall {
1284 c.urlParams_.Set("previous", previous)
1285 return c
1286 }
1287
1288
1289
1290
1291 func (c *TasksInsertCall) Fields(s ...googleapi.Field) *TasksInsertCall {
1292 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1293 return c
1294 }
1295
1296
1297 func (c *TasksInsertCall) Context(ctx context.Context) *TasksInsertCall {
1298 c.ctx_ = ctx
1299 return c
1300 }
1301
1302
1303
1304 func (c *TasksInsertCall) Header() http.Header {
1305 if c.header_ == nil {
1306 c.header_ = make(http.Header)
1307 }
1308 return c.header_
1309 }
1310
1311 func (c *TasksInsertCall) doRequest(alt string) (*http.Response, error) {
1312 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1313 var body io.Reader = nil
1314 body, err := googleapi.WithoutDataWrapper.JSONReader(c.task)
1315 if err != nil {
1316 return nil, err
1317 }
1318 c.urlParams_.Set("alt", alt)
1319 c.urlParams_.Set("prettyPrint", "false")
1320 urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/tasks")
1321 urls += "?" + c.urlParams_.Encode()
1322 req, err := http.NewRequest("POST", urls, body)
1323 if err != nil {
1324 return nil, err
1325 }
1326 req.Header = reqHeaders
1327 googleapi.Expand(req.URL, map[string]string{
1328 "tasklist": c.tasklistid,
1329 })
1330 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1331 }
1332
1333
1334
1335
1336
1337
1338 func (c *TasksInsertCall) Do(opts ...googleapi.CallOption) (*Task, error) {
1339 gensupport.SetOptions(c.urlParams_, opts...)
1340 res, err := c.doRequest("json")
1341 if res != nil && res.StatusCode == http.StatusNotModified {
1342 if res.Body != nil {
1343 res.Body.Close()
1344 }
1345 return nil, gensupport.WrapError(&googleapi.Error{
1346 Code: res.StatusCode,
1347 Header: res.Header,
1348 })
1349 }
1350 if err != nil {
1351 return nil, err
1352 }
1353 defer googleapi.CloseBody(res)
1354 if err := googleapi.CheckResponse(res); err != nil {
1355 return nil, gensupport.WrapError(err)
1356 }
1357 ret := &Task{
1358 ServerResponse: googleapi.ServerResponse{
1359 Header: res.Header,
1360 HTTPStatusCode: res.StatusCode,
1361 },
1362 }
1363 target := &ret
1364 if err := gensupport.DecodeResponse(target, res); err != nil {
1365 return nil, err
1366 }
1367 return ret, nil
1368 }
1369
1370 type TasksListCall struct {
1371 s *Service
1372 tasklistid string
1373 urlParams_ gensupport.URLParams
1374 ifNoneMatch_ string
1375 ctx_ context.Context
1376 header_ http.Header
1377 }
1378
1379
1380
1381
1382
1383 func (r *TasksService) List(tasklistid string) *TasksListCall {
1384 c := &TasksListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1385 c.tasklistid = tasklistid
1386 return c
1387 }
1388
1389
1390
1391
1392 func (c *TasksListCall) CompletedMax(completedMax string) *TasksListCall {
1393 c.urlParams_.Set("completedMax", completedMax)
1394 return c
1395 }
1396
1397
1398
1399
1400 func (c *TasksListCall) CompletedMin(completedMin string) *TasksListCall {
1401 c.urlParams_.Set("completedMin", completedMin)
1402 return c
1403 }
1404
1405
1406
1407
1408 func (c *TasksListCall) DueMax(dueMax string) *TasksListCall {
1409 c.urlParams_.Set("dueMax", dueMax)
1410 return c
1411 }
1412
1413
1414
1415
1416 func (c *TasksListCall) DueMin(dueMin string) *TasksListCall {
1417 c.urlParams_.Set("dueMin", dueMin)
1418 return c
1419 }
1420
1421
1422
1423 func (c *TasksListCall) MaxResults(maxResults int64) *TasksListCall {
1424 c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
1425 return c
1426 }
1427
1428
1429
1430 func (c *TasksListCall) PageToken(pageToken string) *TasksListCall {
1431 c.urlParams_.Set("pageToken", pageToken)
1432 return c
1433 }
1434
1435
1436
1437
1438
1439 func (c *TasksListCall) ShowCompleted(showCompleted bool) *TasksListCall {
1440 c.urlParams_.Set("showCompleted", fmt.Sprint(showCompleted))
1441 return c
1442 }
1443
1444
1445
1446 func (c *TasksListCall) ShowDeleted(showDeleted bool) *TasksListCall {
1447 c.urlParams_.Set("showDeleted", fmt.Sprint(showDeleted))
1448 return c
1449 }
1450
1451
1452
1453 func (c *TasksListCall) ShowHidden(showHidden bool) *TasksListCall {
1454 c.urlParams_.Set("showHidden", fmt.Sprint(showHidden))
1455 return c
1456 }
1457
1458
1459
1460
1461 func (c *TasksListCall) UpdatedMin(updatedMin string) *TasksListCall {
1462 c.urlParams_.Set("updatedMin", updatedMin)
1463 return c
1464 }
1465
1466
1467
1468
1469 func (c *TasksListCall) Fields(s ...googleapi.Field) *TasksListCall {
1470 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1471 return c
1472 }
1473
1474
1475
1476
1477 func (c *TasksListCall) IfNoneMatch(entityTag string) *TasksListCall {
1478 c.ifNoneMatch_ = entityTag
1479 return c
1480 }
1481
1482
1483 func (c *TasksListCall) Context(ctx context.Context) *TasksListCall {
1484 c.ctx_ = ctx
1485 return c
1486 }
1487
1488
1489
1490 func (c *TasksListCall) Header() http.Header {
1491 if c.header_ == nil {
1492 c.header_ = make(http.Header)
1493 }
1494 return c.header_
1495 }
1496
1497 func (c *TasksListCall) doRequest(alt string) (*http.Response, error) {
1498 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1499 if c.ifNoneMatch_ != "" {
1500 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1501 }
1502 var body io.Reader = nil
1503 c.urlParams_.Set("alt", alt)
1504 c.urlParams_.Set("prettyPrint", "false")
1505 urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/tasks")
1506 urls += "?" + c.urlParams_.Encode()
1507 req, err := http.NewRequest("GET", urls, body)
1508 if err != nil {
1509 return nil, err
1510 }
1511 req.Header = reqHeaders
1512 googleapi.Expand(req.URL, map[string]string{
1513 "tasklist": c.tasklistid,
1514 })
1515 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1516 }
1517
1518
1519
1520
1521
1522
1523 func (c *TasksListCall) Do(opts ...googleapi.CallOption) (*Tasks, error) {
1524 gensupport.SetOptions(c.urlParams_, opts...)
1525 res, err := c.doRequest("json")
1526 if res != nil && res.StatusCode == http.StatusNotModified {
1527 if res.Body != nil {
1528 res.Body.Close()
1529 }
1530 return nil, gensupport.WrapError(&googleapi.Error{
1531 Code: res.StatusCode,
1532 Header: res.Header,
1533 })
1534 }
1535 if err != nil {
1536 return nil, err
1537 }
1538 defer googleapi.CloseBody(res)
1539 if err := googleapi.CheckResponse(res); err != nil {
1540 return nil, gensupport.WrapError(err)
1541 }
1542 ret := &Tasks{
1543 ServerResponse: googleapi.ServerResponse{
1544 Header: res.Header,
1545 HTTPStatusCode: res.StatusCode,
1546 },
1547 }
1548 target := &ret
1549 if err := gensupport.DecodeResponse(target, res); err != nil {
1550 return nil, err
1551 }
1552 return ret, nil
1553 }
1554
1555
1556
1557
1558 func (c *TasksListCall) Pages(ctx context.Context, f func(*Tasks) error) error {
1559 c.ctx_ = ctx
1560 defer c.PageToken(c.urlParams_.Get("pageToken"))
1561 for {
1562 x, err := c.Do()
1563 if err != nil {
1564 return err
1565 }
1566 if err := f(x); err != nil {
1567 return err
1568 }
1569 if x.NextPageToken == "" {
1570 return nil
1571 }
1572 c.PageToken(x.NextPageToken)
1573 }
1574 }
1575
1576 type TasksMoveCall struct {
1577 s *Service
1578 tasklistid string
1579 taskid string
1580 urlParams_ gensupport.URLParams
1581 ctx_ context.Context
1582 header_ http.Header
1583 }
1584
1585
1586
1587
1588
1589
1590
1591
1592 func (r *TasksService) Move(tasklistid string, taskid string) *TasksMoveCall {
1593 c := &TasksMoveCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1594 c.tasklistid = tasklistid
1595 c.taskid = taskid
1596 return c
1597 }
1598
1599
1600
1601 func (c *TasksMoveCall) Parent(parent string) *TasksMoveCall {
1602 c.urlParams_.Set("parent", parent)
1603 return c
1604 }
1605
1606
1607
1608
1609 func (c *TasksMoveCall) Previous(previous string) *TasksMoveCall {
1610 c.urlParams_.Set("previous", previous)
1611 return c
1612 }
1613
1614
1615
1616
1617 func (c *TasksMoveCall) Fields(s ...googleapi.Field) *TasksMoveCall {
1618 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1619 return c
1620 }
1621
1622
1623 func (c *TasksMoveCall) Context(ctx context.Context) *TasksMoveCall {
1624 c.ctx_ = ctx
1625 return c
1626 }
1627
1628
1629
1630 func (c *TasksMoveCall) Header() http.Header {
1631 if c.header_ == nil {
1632 c.header_ = make(http.Header)
1633 }
1634 return c.header_
1635 }
1636
1637 func (c *TasksMoveCall) doRequest(alt string) (*http.Response, error) {
1638 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1639 var body io.Reader = nil
1640 c.urlParams_.Set("alt", alt)
1641 c.urlParams_.Set("prettyPrint", "false")
1642 urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/tasks/{task}/move")
1643 urls += "?" + c.urlParams_.Encode()
1644 req, err := http.NewRequest("POST", urls, body)
1645 if err != nil {
1646 return nil, err
1647 }
1648 req.Header = reqHeaders
1649 googleapi.Expand(req.URL, map[string]string{
1650 "tasklist": c.tasklistid,
1651 "task": c.taskid,
1652 })
1653 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1654 }
1655
1656
1657
1658
1659
1660
1661 func (c *TasksMoveCall) Do(opts ...googleapi.CallOption) (*Task, error) {
1662 gensupport.SetOptions(c.urlParams_, opts...)
1663 res, err := c.doRequest("json")
1664 if res != nil && res.StatusCode == http.StatusNotModified {
1665 if res.Body != nil {
1666 res.Body.Close()
1667 }
1668 return nil, gensupport.WrapError(&googleapi.Error{
1669 Code: res.StatusCode,
1670 Header: res.Header,
1671 })
1672 }
1673 if err != nil {
1674 return nil, err
1675 }
1676 defer googleapi.CloseBody(res)
1677 if err := googleapi.CheckResponse(res); err != nil {
1678 return nil, gensupport.WrapError(err)
1679 }
1680 ret := &Task{
1681 ServerResponse: googleapi.ServerResponse{
1682 Header: res.Header,
1683 HTTPStatusCode: res.StatusCode,
1684 },
1685 }
1686 target := &ret
1687 if err := gensupport.DecodeResponse(target, res); err != nil {
1688 return nil, err
1689 }
1690 return ret, nil
1691 }
1692
1693 type TasksPatchCall struct {
1694 s *Service
1695 tasklistid string
1696 taskid string
1697 task *Task
1698 urlParams_ gensupport.URLParams
1699 ctx_ context.Context
1700 header_ http.Header
1701 }
1702
1703
1704
1705
1706
1707 func (r *TasksService) Patch(tasklistid string, taskid string, task *Task) *TasksPatchCall {
1708 c := &TasksPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1709 c.tasklistid = tasklistid
1710 c.taskid = taskid
1711 c.task = task
1712 return c
1713 }
1714
1715
1716
1717
1718 func (c *TasksPatchCall) Fields(s ...googleapi.Field) *TasksPatchCall {
1719 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1720 return c
1721 }
1722
1723
1724 func (c *TasksPatchCall) Context(ctx context.Context) *TasksPatchCall {
1725 c.ctx_ = ctx
1726 return c
1727 }
1728
1729
1730
1731 func (c *TasksPatchCall) Header() http.Header {
1732 if c.header_ == nil {
1733 c.header_ = make(http.Header)
1734 }
1735 return c.header_
1736 }
1737
1738 func (c *TasksPatchCall) doRequest(alt string) (*http.Response, error) {
1739 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1740 var body io.Reader = nil
1741 body, err := googleapi.WithoutDataWrapper.JSONReader(c.task)
1742 if err != nil {
1743 return nil, err
1744 }
1745 c.urlParams_.Set("alt", alt)
1746 c.urlParams_.Set("prettyPrint", "false")
1747 urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/tasks/{task}")
1748 urls += "?" + c.urlParams_.Encode()
1749 req, err := http.NewRequest("PATCH", urls, body)
1750 if err != nil {
1751 return nil, err
1752 }
1753 req.Header = reqHeaders
1754 googleapi.Expand(req.URL, map[string]string{
1755 "tasklist": c.tasklistid,
1756 "task": c.taskid,
1757 })
1758 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1759 }
1760
1761
1762
1763
1764
1765
1766 func (c *TasksPatchCall) Do(opts ...googleapi.CallOption) (*Task, error) {
1767 gensupport.SetOptions(c.urlParams_, opts...)
1768 res, err := c.doRequest("json")
1769 if res != nil && res.StatusCode == http.StatusNotModified {
1770 if res.Body != nil {
1771 res.Body.Close()
1772 }
1773 return nil, gensupport.WrapError(&googleapi.Error{
1774 Code: res.StatusCode,
1775 Header: res.Header,
1776 })
1777 }
1778 if err != nil {
1779 return nil, err
1780 }
1781 defer googleapi.CloseBody(res)
1782 if err := googleapi.CheckResponse(res); err != nil {
1783 return nil, gensupport.WrapError(err)
1784 }
1785 ret := &Task{
1786 ServerResponse: googleapi.ServerResponse{
1787 Header: res.Header,
1788 HTTPStatusCode: res.StatusCode,
1789 },
1790 }
1791 target := &ret
1792 if err := gensupport.DecodeResponse(target, res); err != nil {
1793 return nil, err
1794 }
1795 return ret, nil
1796 }
1797
1798 type TasksUpdateCall struct {
1799 s *Service
1800 tasklistid string
1801 taskid string
1802 task *Task
1803 urlParams_ gensupport.URLParams
1804 ctx_ context.Context
1805 header_ http.Header
1806 }
1807
1808
1809
1810
1811
1812 func (r *TasksService) Update(tasklistid string, taskid string, task *Task) *TasksUpdateCall {
1813 c := &TasksUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1814 c.tasklistid = tasklistid
1815 c.taskid = taskid
1816 c.task = task
1817 return c
1818 }
1819
1820
1821
1822
1823 func (c *TasksUpdateCall) Fields(s ...googleapi.Field) *TasksUpdateCall {
1824 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1825 return c
1826 }
1827
1828
1829 func (c *TasksUpdateCall) Context(ctx context.Context) *TasksUpdateCall {
1830 c.ctx_ = ctx
1831 return c
1832 }
1833
1834
1835
1836 func (c *TasksUpdateCall) Header() http.Header {
1837 if c.header_ == nil {
1838 c.header_ = make(http.Header)
1839 }
1840 return c.header_
1841 }
1842
1843 func (c *TasksUpdateCall) doRequest(alt string) (*http.Response, error) {
1844 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1845 var body io.Reader = nil
1846 body, err := googleapi.WithoutDataWrapper.JSONReader(c.task)
1847 if err != nil {
1848 return nil, err
1849 }
1850 c.urlParams_.Set("alt", alt)
1851 c.urlParams_.Set("prettyPrint", "false")
1852 urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/tasks/{task}")
1853 urls += "?" + c.urlParams_.Encode()
1854 req, err := http.NewRequest("PUT", urls, body)
1855 if err != nil {
1856 return nil, err
1857 }
1858 req.Header = reqHeaders
1859 googleapi.Expand(req.URL, map[string]string{
1860 "tasklist": c.tasklistid,
1861 "task": c.taskid,
1862 })
1863 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1864 }
1865
1866
1867
1868
1869
1870
1871 func (c *TasksUpdateCall) Do(opts ...googleapi.CallOption) (*Task, error) {
1872 gensupport.SetOptions(c.urlParams_, opts...)
1873 res, err := c.doRequest("json")
1874 if res != nil && res.StatusCode == http.StatusNotModified {
1875 if res.Body != nil {
1876 res.Body.Close()
1877 }
1878 return nil, gensupport.WrapError(&googleapi.Error{
1879 Code: res.StatusCode,
1880 Header: res.Header,
1881 })
1882 }
1883 if err != nil {
1884 return nil, err
1885 }
1886 defer googleapi.CloseBody(res)
1887 if err := googleapi.CheckResponse(res); err != nil {
1888 return nil, gensupport.WrapError(err)
1889 }
1890 ret := &Task{
1891 ServerResponse: googleapi.ServerResponse{
1892 Header: res.Header,
1893 HTTPStatusCode: res.StatusCode,
1894 },
1895 }
1896 target := &ret
1897 if err := gensupport.DecodeResponse(target, res); err != nil {
1898 return nil, err
1899 }
1900 return ret, nil
1901 }
1902
View as plain text