Class: Trello::CustomFieldItem
Overview
A custom field item contains the value for a custom field on a particular card.
Instance Attribute Summary collapse
Attributes inherited from BasicData
#client
Instance Method Summary
collapse
Methods inherited from BasicData
#==, #attributes, client, #collection_name, create, #element_name, find, #hash, #initialize, many, one, parse, parse_many, path_name, #refresh!, register_attrs, save, #schema, schema, #update!, #update_fields
Methods included from JsonUtils
included
Instance Attribute Details
#custom_field_id ⇒ String
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/trello/custom_field_item.rb', line 16
class CustomFieldItem < BasicData
schema do
attribute :id, readonly: true, primary_key: true
attribute :model_id, readonly: true, remote_key: 'idModel'
attribute :model_type, readonly: true, remote_key: 'modelType'
attribute :custom_field_id, readonly: true, remote_key: 'idCustomField'
attribute :option_id, readonly: true, remote_key: 'idValue'
attribute :value
end
validates_presence_of :id, :model_id, :custom_field_id
one :card, path: :cards, using: :model_id
one :custom_field, path: 'customFields', using: :custom_field_id
def save
return update! if id
payload = {}
schema.attrs.each do |_, attribute|
payload = attribute.build_payload_for_create(attributes, payload)
end
put(element_path, payload)
end
def collection_path
"/cards/#{model_id}/#{collection_name}"
end
def element_path
"/cards/#{model_id}/customField/#{custom_field_id}/item"
end
def remove
params = { value: {} }
client.put(element_path, params)
end
def type
custom_field.type
end
def option_value
if option_id
option_endpoint = "/customFields/#{custom_field_id}/options/#{option_id}"
option = CustomFieldOption.from_response client.get(option_endpoint)
option.value
end
end
end
|
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/trello/custom_field_item.rb', line 16
class CustomFieldItem < BasicData
schema do
attribute :id, readonly: true, primary_key: true
attribute :model_id, readonly: true, remote_key: 'idModel'
attribute :model_type, readonly: true, remote_key: 'modelType'
attribute :custom_field_id, readonly: true, remote_key: 'idCustomField'
attribute :option_id, readonly: true, remote_key: 'idValue'
attribute :value
end
validates_presence_of :id, :model_id, :custom_field_id
one :card, path: :cards, using: :model_id
one :custom_field, path: 'customFields', using: :custom_field_id
def save
return update! if id
payload = {}
schema.attrs.each do |_, attribute|
payload = attribute.build_payload_for_create(attributes, payload)
end
put(element_path, payload)
end
def collection_path
"/cards/#{model_id}/#{collection_name}"
end
def element_path
"/cards/#{model_id}/customField/#{custom_field_id}/item"
end
def remove
params = { value: {} }
client.put(element_path, params)
end
def type
custom_field.type
end
def option_value
if option_id
option_endpoint = "/customFields/#{custom_field_id}/options/#{option_id}"
option = CustomFieldOption.from_response client.get(option_endpoint)
option.value
end
end
end
|
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/trello/custom_field_item.rb', line 16
class CustomFieldItem < BasicData
schema do
attribute :id, readonly: true, primary_key: true
attribute :model_id, readonly: true, remote_key: 'idModel'
attribute :model_type, readonly: true, remote_key: 'modelType'
attribute :custom_field_id, readonly: true, remote_key: 'idCustomField'
attribute :option_id, readonly: true, remote_key: 'idValue'
attribute :value
end
validates_presence_of :id, :model_id, :custom_field_id
one :card, path: :cards, using: :model_id
one :custom_field, path: 'customFields', using: :custom_field_id
def save
return update! if id
payload = {}
schema.attrs.each do |_, attribute|
payload = attribute.build_payload_for_create(attributes, payload)
end
put(element_path, payload)
end
def collection_path
"/cards/#{model_id}/#{collection_name}"
end
def element_path
"/cards/#{model_id}/customField/#{custom_field_id}/item"
end
def remove
params = { value: {} }
client.put(element_path, params)
end
def type
custom_field.type
end
def option_value
if option_id
option_endpoint = "/customFields/#{custom_field_id}/options/#{option_id}"
option = CustomFieldOption.from_response client.get(option_endpoint)
option.value
end
end
end
|
#model_type ⇒ String
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/trello/custom_field_item.rb', line 16
class CustomFieldItem < BasicData
schema do
attribute :id, readonly: true, primary_key: true
attribute :model_id, readonly: true, remote_key: 'idModel'
attribute :model_type, readonly: true, remote_key: 'modelType'
attribute :custom_field_id, readonly: true, remote_key: 'idCustomField'
attribute :option_id, readonly: true, remote_key: 'idValue'
attribute :value
end
validates_presence_of :id, :model_id, :custom_field_id
one :card, path: :cards, using: :model_id
one :custom_field, path: 'customFields', using: :custom_field_id
def save
return update! if id
payload = {}
schema.attrs.each do |_, attribute|
payload = attribute.build_payload_for_create(attributes, payload)
end
put(element_path, payload)
end
def collection_path
"/cards/#{model_id}/#{collection_name}"
end
def element_path
"/cards/#{model_id}/customField/#{custom_field_id}/item"
end
def remove
params = { value: {} }
client.put(element_path, params)
end
def type
custom_field.type
end
def option_value
if option_id
option_endpoint = "/customFields/#{custom_field_id}/options/#{option_id}"
option = CustomFieldOption.from_response client.get(option_endpoint)
option.value
end
end
end
|
#option_id ⇒ String
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/trello/custom_field_item.rb', line 16
class CustomFieldItem < BasicData
schema do
attribute :id, readonly: true, primary_key: true
attribute :model_id, readonly: true, remote_key: 'idModel'
attribute :model_type, readonly: true, remote_key: 'modelType'
attribute :custom_field_id, readonly: true, remote_key: 'idCustomField'
attribute :option_id, readonly: true, remote_key: 'idValue'
attribute :value
end
validates_presence_of :id, :model_id, :custom_field_id
one :card, path: :cards, using: :model_id
one :custom_field, path: 'customFields', using: :custom_field_id
def save
return update! if id
payload = {}
schema.attrs.each do |_, attribute|
payload = attribute.build_payload_for_create(attributes, payload)
end
put(element_path, payload)
end
def collection_path
"/cards/#{model_id}/#{collection_name}"
end
def element_path
"/cards/#{model_id}/customField/#{custom_field_id}/item"
end
def remove
params = { value: {} }
client.put(element_path, params)
end
def type
custom_field.type
end
def option_value
if option_id
option_endpoint = "/customFields/#{custom_field_id}/options/#{option_id}"
option = CustomFieldOption.from_response client.get(option_endpoint)
option.value
end
end
end
|
#value ⇒ Hash
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/trello/custom_field_item.rb', line 16
class CustomFieldItem < BasicData
schema do
attribute :id, readonly: true, primary_key: true
attribute :model_id, readonly: true, remote_key: 'idModel'
attribute :model_type, readonly: true, remote_key: 'modelType'
attribute :custom_field_id, readonly: true, remote_key: 'idCustomField'
attribute :option_id, readonly: true, remote_key: 'idValue'
attribute :value
end
validates_presence_of :id, :model_id, :custom_field_id
one :card, path: :cards, using: :model_id
one :custom_field, path: 'customFields', using: :custom_field_id
def save
return update! if id
payload = {}
schema.attrs.each do |_, attribute|
payload = attribute.build_payload_for_create(attributes, payload)
end
put(element_path, payload)
end
def collection_path
"/cards/#{model_id}/#{collection_name}"
end
def element_path
"/cards/#{model_id}/customField/#{custom_field_id}/item"
end
def remove
params = { value: {} }
client.put(element_path, params)
end
def type
custom_field.type
end
def option_value
if option_id
option_endpoint = "/customFields/#{custom_field_id}/options/#{option_id}"
option = CustomFieldOption.from_response client.get(option_endpoint)
option.value
end
end
end
|
Instance Method Details
#collection_path ⇒ Object
48
49
50
|
# File 'lib/trello/custom_field_item.rb', line 48
def collection_path
"/cards/#{model_id}/#{collection_name}"
end
|
#element_path ⇒ Object
52
53
54
|
# File 'lib/trello/custom_field_item.rb', line 52
def element_path
"/cards/#{model_id}/customField/#{custom_field_id}/item"
end
|
#option_value ⇒ Object
Need to make another call to get the actual value if the custom field type == ‘list’
68
69
70
71
72
73
74
|
# File 'lib/trello/custom_field_item.rb', line 68
def option_value
if option_id
option_endpoint = "/customFields/#{custom_field_id}/options/#{option_id}"
option = CustomFieldOption.from_response client.get(option_endpoint)
option.value
end
end
|
#remove ⇒ Object
You can’t “delete” a custom field item, you can only clear the value
57
58
59
60
|
# File 'lib/trello/custom_field_item.rb', line 57
def remove
params = { value: {} }
client.put(element_path, params)
end
|
#save ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/trello/custom_field_item.rb', line 36
def save
return update! if id
payload = {}
schema.attrs.each do |_, attribute|
payload = attribute.build_payload_for_create(attributes, payload)
end
put(element_path, payload)
end
|
#type ⇒ Object
Type is saved at the CustomField level
63
64
65
|
# File 'lib/trello/custom_field_item.rb', line 63
def type
custom_field.type
end
|