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
76
77
|
# File 'lib/trello/custom_field.rb', line 22
class CustomField < BasicData
schema do
attribute :id, readonly: true, primary_key: true
attribute :field_group, readonly: true, remote_key: 'fieldGroup'
attribute :name
attribute :position, remote_key: 'pos'
attribute :enable_display_on_card, remote_key: 'cardFront', class_name: 'CustomFieldDisplay'
attribute :model_id, remote_key: 'idModel', create_only: true
attribute :model_type, remote_key: 'modelType', create_only: true
attribute :type, create_only: true
attribute :checkbox_options, remote_key: 'options', create_only: true
end
validates_presence_of :id, :model_id, :model_type, :name, :type, :position
class << self
def find(id, params = {})
client.find('customFields', id, params)
end
end
def collection_name
'customFields'
end
one :board, path: :boards, using: :model_id
many :custom_field_options, path: 'options'
def delete
client.delete("/customFields/#{id}")
end
def create_new_option(value)
payload = { value: value }
client.post("/customFields/#{id}/options", payload)
end
def delete_option(option_id)
client.delete("/customFields/#{id}/options/#{option_id}")
end
end
|