raksul / go-clickup

Clickup go client
MIT License
39 stars 24 forks source link

Make it possible to get value of custom field. #29

Closed w-haibara closed 2 years ago

w-haibara commented 2 years ago

This PR make it possible to get value of custom field via Get Task API.

task, _, _ := client.Tasks.GetTask(ctx, id, nil)

for _, field := range task.CustomFields {
  v := field.GetValue() // value of custom field

  // process to use v

}

GetValue() returns interface value. It can be cast in concrete type. What type can be cast depends on the CustomField.Type as shown in the table below.

CustomField.Type Type of GetValue() returns value
url, email, phone, text, short_text string
number, formula float64
checkbox bool
date time.Time
currency clickup.CurrencyValue
emoji clickup.EmojiValue
location clickup.LocationValue
automatic_progress clickup.AutomaticProgressValue
manual_progress clickup.ManualProgressValue
tasks clickup.TasksValue
users clickup.UsersValue
attachment clickup.AttachmentValue
drop_down clickup.DropDownValue
labels clickup.LabelsValue

For more details, please see the example code (example/custom-fields/main.go) .