ruby-trello 2.2.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (314) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +63 -10
  3. data/lib/trello/action.rb +31 -23
  4. data/lib/trello/association_builder/has_many.rb +17 -0
  5. data/lib/trello/association_builder/has_one.rb +16 -0
  6. data/lib/trello/association_fetcher/has_many/fetch.rb +47 -0
  7. data/lib/trello/association_fetcher/has_many/params.rb +56 -0
  8. data/lib/trello/association_fetcher/has_many.rb +26 -0
  9. data/lib/trello/association_fetcher/has_one/fetch.rb +49 -0
  10. data/lib/trello/association_fetcher/has_one/params.rb +36 -0
  11. data/lib/trello/association_fetcher/has_one.rb +25 -0
  12. data/lib/trello/association_infer_tool.rb +13 -0
  13. data/lib/trello/association_proxy.rb +1 -1
  14. data/lib/trello/attachment.rb +40 -27
  15. data/lib/trello/basic_data.rb +103 -49
  16. data/lib/trello/board.rb +88 -102
  17. data/lib/trello/card.rb +49 -198
  18. data/lib/trello/checklist.rb +17 -71
  19. data/lib/trello/comment.rb +39 -26
  20. data/lib/trello/cover_image.rb +20 -0
  21. data/lib/trello/custom_field.rb +31 -67
  22. data/lib/trello/custom_field_item.rb +37 -39
  23. data/lib/trello/custom_field_option.rb +40 -13
  24. data/lib/trello/item.rb +27 -16
  25. data/lib/trello/item_state.rb +7 -15
  26. data/lib/trello/json_utils.rb +1 -1
  27. data/lib/trello/label.rb +15 -85
  28. data/lib/trello/label_name.rb +22 -25
  29. data/lib/trello/list.rb +31 -44
  30. data/lib/trello/member.rb +77 -32
  31. data/lib/trello/notification.rb +27 -20
  32. data/lib/trello/organization.rb +53 -25
  33. data/lib/trello/plugin_datum.rb +11 -16
  34. data/lib/trello/schema/attribute/base.rb +79 -0
  35. data/lib/trello/schema/attribute/board_pref.rb +45 -0
  36. data/lib/trello/schema/attribute/custom_field_display.rb +45 -0
  37. data/lib/trello/schema/attribute/default.rb +45 -0
  38. data/lib/trello/schema/attribute_builder.rb +42 -0
  39. data/lib/trello/schema/attribute_registration.rb +47 -0
  40. data/lib/trello/schema/serializer/default.rb +17 -0
  41. data/lib/trello/schema/serializer/labels.rb +23 -0
  42. data/lib/trello/schema/serializer/time.rb +25 -0
  43. data/lib/trello/schema/serializer/webhooks.rb +25 -0
  44. data/lib/trello/schema.rb +31 -0
  45. data/lib/trello/token.rb +15 -12
  46. data/lib/trello/webhook.rb +18 -71
  47. data/lib/trello.rb +57 -39
  48. data/spec/action_spec.rb +2 -3
  49. data/spec/board_spec.rb +43 -103
  50. data/spec/card_spec.rb +143 -66
  51. data/spec/cassettes/action_find_with_id_and_get_all_fields.yml +104 -0
  52. data/spec/cassettes/board_find_with_id_and_get_all_fields.yml +96 -0
  53. data/spec/cassettes/board_find_with_id_and_get_specific_fields.yml +96 -0
  54. data/spec/cassettes/can_add_a_file_from_url_on_a_card.yml +189 -0
  55. data/spec/cassettes/can_add_a_file_on_a_card.yml +200 -0
  56. data/spec/cassettes/can_add_a_member_to_a_board.yml +191 -0
  57. data/spec/cassettes/can_add_a_member_to_a_card.yml +190 -0
  58. data/spec/cassettes/can_add_label_on_a_card.yml +281 -0
  59. data/spec/cassettes/can_arvhice_all_cards_of_list.yml +397 -0
  60. data/spec/cassettes/can_close_bong_a_card.yml +189 -0
  61. data/spec/cassettes/can_get_actions.yml +196 -0
  62. data/spec/cassettes/can_get_actions_of_board.yml +188 -0
  63. data/spec/cassettes/can_get_actions_of_list.yml +202 -0
  64. data/spec/cassettes/can_get_actions_of_members.yml +199 -0
  65. data/spec/cassettes/can_get_actions_of_organization.yml +201 -0
  66. data/spec/cassettes/can_get_attachments.yml +187 -0
  67. data/spec/cassettes/can_get_boards_of_custom_field.yml +198 -0
  68. data/spec/cassettes/can_get_boards_of_label.yml +197 -0
  69. data/spec/cassettes/can_get_boards_of_organization.yml +207 -0
  70. data/spec/cassettes/can_get_cards_of_board.yml +193 -0
  71. data/spec/cassettes/can_get_cards_of_list.yml +201 -0
  72. data/spec/cassettes/can_get_cards_of_member.yml +204 -0
  73. data/spec/cassettes/can_get_checklists_of_board.yml +187 -0
  74. data/spec/cassettes/can_get_comments.yml +193 -0
  75. data/spec/cassettes/can_get_comments_board.yml +109 -0
  76. data/spec/cassettes/can_get_comments_card.yml +111 -0
  77. data/spec/cassettes/can_get_comments_list.yml +109 -0
  78. data/spec/cassettes/can_get_custom_field_options_of_custom_field.yml +197 -0
  79. data/spec/cassettes/can_get_custom_fields_of_board.yml +187 -0
  80. data/spec/cassettes/can_get_label_names_of_board.yml +187 -0
  81. data/spec/cassettes/can_get_labels_of_board.yml +187 -0
  82. data/spec/cassettes/can_get_lists_of_board.yml +187 -0
  83. data/spec/cassettes/can_get_members_of_board.yml +188 -0
  84. data/spec/cassettes/can_get_members_of_organization.yml +200 -0
  85. data/spec/cassettes/can_get_notifications_of_member.yml +199 -0
  86. data/spec/cassettes/can_get_organization_of_board.yml +189 -0
  87. data/spec/cassettes/can_get_organizations_of_member.yml +203 -0
  88. data/spec/cassettes/can_get_plugin_data_of_board.yml +187 -0
  89. data/spec/cassettes/can_move_a_card_to_another_board_with_specific_list.yml +373 -0
  90. data/spec/cassettes/can_move_a_card_to_another_board_without_specific_list.yml +281 -0
  91. data/spec/cassettes/can_move_a_card_to_another_list.yml +281 -0
  92. data/spec/cassettes/can_move_all_cards_to_another_list.yml +886 -0
  93. data/spec/cassettes/can_remove_a_member_from_a_card.yml +185 -0
  94. data/spec/cassettes/can_remove_an_attachment_on_a_card.yml +277 -0
  95. data/spec/cassettes/can_remove_an_upvote_on_a_card.yml +465 -0
  96. data/spec/cassettes/can_remove_label_on_a_card.yml +279 -0
  97. data/spec/cassettes/can_success_add_comment_to_a_card.yml +196 -0
  98. data/spec/cassettes/can_success_copy_checklist_to_a_card.yml +281 -0
  99. data/spec/cassettes/can_success_copy_checklist_to_a_card_without_name_pos.yml +281 -0
  100. data/spec/cassettes/can_success_create_a_board.yml +98 -0
  101. data/spec/cassettes/can_success_create_a_board_with_full_parameters.yml +97 -0
  102. data/spec/cassettes/can_success_create_a_board_without_clone_from_other.yml +98 -0
  103. data/spec/cassettes/can_success_create_a_card.yml +99 -0
  104. data/spec/cassettes/can_success_create_a_card_when_due_is_datetime.yml +98 -0
  105. data/spec/cassettes/can_success_create_a_card_when_due_is_time.yml +98 -0
  106. data/spec/cassettes/can_success_create_a_checklist.yml +102 -0
  107. data/spec/cassettes/can_success_create_a_custom_field.yml +102 -0
  108. data/spec/cassettes/can_success_create_a_custom_field_option.yml +102 -0
  109. data/spec/cassettes/can_success_create_a_label.yml +102 -0
  110. data/spec/cassettes/can_success_create_a_list.yml +102 -0
  111. data/spec/cassettes/can_success_create_a_list_with_full_parameters.yml +102 -0
  112. data/spec/cassettes/can_success_create_a_organization.yml +104 -0
  113. data/spec/cassettes/can_success_create_a_webhook.yml +102 -0
  114. data/spec/cassettes/can_success_create_new_checklist_to_a_card.yml +189 -0
  115. data/spec/cassettes/can_success_delete_a_custom_field_option.yml +389 -0
  116. data/spec/cassettes/can_success_delete_card.yml +185 -0
  117. data/spec/cassettes/can_success_delete_checklist.yml +284 -0
  118. data/spec/cassettes/can_success_get_card_of_board_by_card_id.yml +188 -0
  119. data/spec/cassettes/can_success_remove_member_from_board.yml +186 -0
  120. data/spec/cassettes/can_success_return_all_boards_of_current_user.yml +195 -0
  121. data/spec/cassettes/can_success_upate_a_board.yml +191 -0
  122. data/spec/cassettes/can_success_upate_a_card.yml +189 -0
  123. data/spec/cassettes/can_success_upate_a_list.yml +296 -0
  124. data/spec/cassettes/can_success_update_bong_a_board.yml +283 -0
  125. data/spec/cassettes/can_success_update_bong_a_board_with_specific_fields.yml +284 -0
  126. data/spec/cassettes/can_success_update_bong_a_card.yml +191 -0
  127. data/spec/cassettes/can_success_update_bong_a_checklist_with_specific_fields.yml +296 -0
  128. data/spec/cassettes/can_success_update_bong_a_custom_field.yml +200 -0
  129. data/spec/cassettes/can_success_update_bong_a_label.yml +200 -0
  130. data/spec/cassettes/can_success_update_bong_a_list.yml +199 -0
  131. data/spec/cassettes/can_success_update_bong_a_list_with_specific_fields.yml +296 -0
  132. data/spec/cassettes/can_success_update_bong_a_organization.yml +203 -0
  133. data/spec/cassettes/can_success_update_bong_a_webhook.yml +296 -0
  134. data/spec/cassettes/can_upvote_on_a_card.yml +469 -0
  135. data/spec/cassettes/card_find_with_id_and_get_all_fields.yml +95 -0
  136. data/spec/cassettes/card_find_with_id_and_get_specific_fields.yml +96 -0
  137. data/spec/cassettes/checklist_can_add_an_item.yml +296 -0
  138. data/spec/cassettes/checklist_can_update_the_item_state.yml +296 -0
  139. data/spec/cassettes/checklist_find_with_id_and_get_all_fields.yml +100 -0
  140. data/spec/cassettes/comment_delete.yml +331 -0
  141. data/spec/cassettes/comment_find_with_id.yml +116 -0
  142. data/spec/cassettes/custom_field_find_with_id_and_get_all_fields.yml +100 -0
  143. data/spec/cassettes/custom_field_find_with_id_and_get_specific_fields.yml +100 -0
  144. data/spec/cassettes/custom_field_item_save_1.yml +97 -0
  145. data/spec/cassettes/custom_field_item_save_2.yml +281 -0
  146. data/spec/cassettes/custom_field_option_find_with_id.yml +100 -0
  147. data/spec/cassettes/get_board_of_card.yml +187 -0
  148. data/spec/cassettes/get_board_of_list.yml +197 -0
  149. data/spec/cassettes/get_boards_of_member.yml +207 -0
  150. data/spec/cassettes/get_check_item_states_of_card.yml +188 -0
  151. data/spec/cassettes/get_checklists_of_card.yml +187 -0
  152. data/spec/cassettes/get_cover_image_of_card.yml +187 -0
  153. data/spec/cassettes/get_custom_field_items_of_card.yml +187 -0
  154. data/spec/cassettes/get_list_of_card.yml +188 -0
  155. data/spec/cassettes/get_lists.yml +187 -0
  156. data/spec/cassettes/get_members_of_card.yml +189 -0
  157. data/spec/cassettes/get_plugin_data_of_card.yml +187 -0
  158. data/spec/cassettes/get_voters_of_card.yml +188 -0
  159. data/spec/cassettes/label_delete.yml +285 -0
  160. data/spec/cassettes/label_find_with_id.yml +100 -0
  161. data/spec/cassettes/list_find_with_id_and_get_all_fields.yml +100 -0
  162. data/spec/cassettes/list_find_with_id_and_get_specific_fields.yml +100 -0
  163. data/spec/cassettes/member_find_with_id_and_get_all_fields.yml +101 -0
  164. data/spec/cassettes/member_find_with_id_and_get_specific_fields.yml +100 -0
  165. data/spec/cassettes/notification_find_with_id.yml +103 -0
  166. data/spec/cassettes/organization_find_with_id_and_get_all_fields.yml +102 -0
  167. data/spec/cassettes/organization_find_with_id_and_get_specific_fields.yml +100 -0
  168. data/spec/cassettes/remove_upvote_on_a_card_when_have_not_voted.yml +366 -0
  169. data/spec/cassettes/revote_on_a_card.yml +464 -0
  170. data/spec/cassettes/token_find_with_token_string.yml +100 -0
  171. data/spec/cassettes/webhook_delete.yml +286 -0
  172. data/spec/cassettes/webhook_find_with_id.yml +100 -0
  173. data/spec/checklist_spec.rb +27 -43
  174. data/spec/custom_field_item_spec.rb +74 -0
  175. data/spec/custom_field_option_spec.rb +2 -2
  176. data/spec/custom_field_spec.rb +98 -10
  177. data/spec/integration/action/find_spec.rb +23 -0
  178. data/spec/integration/basic_data/many_spec.rb +127 -0
  179. data/spec/integration/basic_data/one_spec.rb +84 -0
  180. data/spec/integration/basic_data/schema_spec.rb +156 -0
  181. data/spec/integration/board/add_member_spec.rb +21 -0
  182. data/spec/integration/board/all_spec.rb +20 -0
  183. data/spec/integration/board/associations/actions_spec.rb +18 -0
  184. data/spec/integration/board/associations/cards_spec.rb +18 -0
  185. data/spec/integration/board/associations/checklists_spec.rb +18 -0
  186. data/spec/integration/board/associations/custom_fields_spec.rb +18 -0
  187. data/spec/integration/board/associations/label_names_spec.rb +17 -0
  188. data/spec/integration/board/associations/labels_spec.rb +18 -0
  189. data/spec/integration/board/associations/lists_spec.rb +18 -0
  190. data/spec/integration/board/associations/members_spec.rb +18 -0
  191. data/spec/integration/board/associations/organization_spec.rb +19 -0
  192. data/spec/integration/board/associations/plugin_data_spec.rb +18 -0
  193. data/spec/integration/board/create_spec.rb +95 -0
  194. data/spec/integration/board/find_card_spec.rb +18 -0
  195. data/spec/integration/board/find_spec.rb +42 -0
  196. data/spec/integration/board/remove_member_spec.rb +21 -0
  197. data/spec/integration/board/save_spec.rb +37 -0
  198. data/spec/integration/board/update!_spec.rb +62 -0
  199. data/spec/integration/board_lists_spec.rb +21 -0
  200. data/spec/integration/card/add_and_remove_attachment_spec.rb +45 -0
  201. data/spec/integration/card/add_and_remove_label_spec.rb +35 -0
  202. data/spec/integration/card/add_checklist_spec.rb +32 -0
  203. data/spec/integration/card/add_comment_spec.rb +19 -0
  204. data/spec/integration/card/add_memeber_spec.rb +19 -0
  205. data/spec/integration/card/associations/actions_spec.rb +17 -0
  206. data/spec/integration/card/associations/attachments_spec.rb +18 -0
  207. data/spec/integration/card/associations/board_spec.rb +17 -0
  208. data/spec/integration/card/associations/check_item_states_spec.rb +17 -0
  209. data/spec/integration/card/associations/checklists_spec.rb +18 -0
  210. data/spec/integration/card/associations/comments_spec.rb +19 -0
  211. data/spec/integration/card/associations/cover_image_spec.rb +18 -0
  212. data/spec/integration/card/associations/custom_field_items_spec.rb +18 -0
  213. data/spec/integration/card/associations/list_spec.rb +16 -0
  214. data/spec/integration/card/associations/members_spec.rb +18 -0
  215. data/spec/integration/card/associations/plugin_data_spec.rb +18 -0
  216. data/spec/integration/card/associations/voters_spec.rb +17 -0
  217. data/spec/integration/card/close!_spec.rb +16 -0
  218. data/spec/integration/card/create_new_check_list_spec.rb +19 -0
  219. data/spec/integration/card/create_spec.rb +84 -0
  220. data/spec/integration/card/delete_spec.rb +16 -0
  221. data/spec/integration/card/find_spec.rb +67 -0
  222. data/spec/integration/card/move_to_board_spec.rb +36 -0
  223. data/spec/integration/card/move_to_list_spec.rb +20 -0
  224. data/spec/integration/card/remove_member_spec.rb +19 -0
  225. data/spec/integration/card/save_spec.rb +61 -0
  226. data/spec/integration/card/update!_spec.rb +53 -0
  227. data/spec/integration/card/vote_spec.rb +50 -0
  228. data/spec/integration/checklist/add_item_spec.rb +20 -0
  229. data/spec/integration/checklist/create_spec.rb +23 -0
  230. data/spec/integration/checklist/delete_spec.rb +17 -0
  231. data/spec/integration/checklist/find_spec.rb +22 -0
  232. data/spec/integration/checklist/update!_spec.rb +21 -0
  233. data/spec/integration/checklist/update_item_state_spec.rb +20 -0
  234. data/spec/integration/comment/association/board_spec.rb +17 -0
  235. data/spec/integration/comment/association/card_spec.rb +17 -0
  236. data/spec/integration/comment/association/list_spec.rb +17 -0
  237. data/spec/integration/comment/delete_spec.rb +20 -0
  238. data/spec/integration/comment/find_spec.rb +17 -0
  239. data/spec/integration/custom_field/association/board_spec.rb +18 -0
  240. data/spec/integration/custom_field/association/custom_field_options_spec.rb +18 -0
  241. data/spec/integration/custom_field/create_spec.rb +29 -0
  242. data/spec/integration/custom_field/find_spec.rb +41 -0
  243. data/spec/integration/custom_field/update!_spec.rb +25 -0
  244. data/spec/integration/custom_field_item_spec.rb +47 -0
  245. data/spec/integration/custom_field_option/create_spec.rb +23 -0
  246. data/spec/integration/custom_field_option/delete_spec.rb +19 -0
  247. data/spec/integration/custom_field_option/find_spec.rb +21 -0
  248. data/spec/integration/label/association/board_spec.rb +18 -0
  249. data/spec/integration/label/create_spec.rb +23 -0
  250. data/spec/integration/label/delete_spec.rb +21 -0
  251. data/spec/integration/label/find_spec.rb +20 -0
  252. data/spec/integration/label/update!_spec.rb +25 -0
  253. data/spec/integration/list/archive_all_cards_spec.rb +20 -0
  254. data/spec/integration/list/associations/actions_spec.rb +18 -0
  255. data/spec/integration/list/associations/board_spec.rb +18 -0
  256. data/spec/integration/list/associations/cards_spec.rb +18 -0
  257. data/spec/integration/list/create_spec.rb +44 -0
  258. data/spec/integration/list/find_spec.rb +37 -0
  259. data/spec/integration/list/move_all_cards_spec.rb +31 -0
  260. data/spec/integration/list/save_spec.rb +40 -0
  261. data/spec/integration/list/update!_spec.rb +43 -0
  262. data/spec/integration/member/associations/actions_spec.rb +17 -0
  263. data/spec/integration/member/associations/boards_spec.rb +18 -0
  264. data/spec/integration/member/associations/cards_spec.rb +18 -0
  265. data/spec/integration/member/associations/notifications_spec.rb +18 -0
  266. data/spec/integration/member/associations/organizations_spec.rb +18 -0
  267. data/spec/integration/member/find_spec.rb +39 -0
  268. data/spec/integration/member/update!_spec.rb +18 -0
  269. data/spec/integration/notification/find_spec.rb +27 -0
  270. data/spec/integration/organization/associations/actions_spec.rb +18 -0
  271. data/spec/integration/organization/associations/boards_spec.rb +18 -0
  272. data/spec/integration/organization/associations/members_spec.rb +18 -0
  273. data/spec/integration/organization/create_spec.rb +23 -0
  274. data/spec/integration/organization/find_spec.rb +37 -0
  275. data/spec/integration/organization/update!_spec.rb +28 -0
  276. data/spec/integration/token/find_spec.rb +24 -0
  277. data/spec/integration/webhook/create_spec.rb +27 -0
  278. data/spec/integration/webhook/delete_spec.rb +21 -0
  279. data/spec/integration/webhook/find_spec.rb +22 -0
  280. data/spec/integration/webhook/update!_spec.rb +24 -0
  281. data/spec/item_spec.rb +2 -2
  282. data/spec/label_spec.rb +105 -28
  283. data/spec/list_spec.rb +32 -14
  284. data/spec/notification_spec.rb +3 -3
  285. data/spec/organization_spec.rb +6 -5
  286. data/spec/spec_helper.rb +70 -37
  287. data/spec/token_spec.rb +10 -11
  288. data/spec/unit/trello/association_builder/has_many_spec.rb +36 -0
  289. data/spec/unit/trello/association_builder/has_one_spec.rb +36 -0
  290. data/spec/unit/trello/association_fetcher/has_many/fetch_spec.rb +38 -0
  291. data/spec/unit/trello/association_fetcher/has_many/params_spec.rb +107 -0
  292. data/spec/unit/trello/association_fetcher/has_many_spec.rb +50 -0
  293. data/spec/unit/trello/association_fetcher/has_one/fetch_spec.rb +51 -0
  294. data/spec/unit/trello/association_fetcher/has_one/params_spec.rb +81 -0
  295. data/spec/unit/trello/association_fetcher/has_one_spec.rb +49 -0
  296. data/spec/unit/trello/association_infer_tool_spec.rb +41 -0
  297. data/spec/unit/trello/basic_data_spec.rb +113 -0
  298. data/spec/unit/trello/board/new_spec.rb +370 -0
  299. data/spec/unit/trello/board/save_spec.rb +49 -0
  300. data/spec/unit/trello/board/update_fields_spec.rb +129 -0
  301. data/spec/unit/trello/board/update_spec.rb +197 -0
  302. data/spec/unit/trello/card_spec.rb +103 -0
  303. data/spec/unit/trello/member/new_spec.rb +62 -0
  304. data/spec/unit/trello/member/update_fields_spec.rb +80 -0
  305. data/spec/unit/trello/schema/attribute/base_spec.rb +349 -0
  306. data/spec/unit/trello/schema/attribute/board_pref_spec.rb +208 -0
  307. data/spec/unit/trello/schema/attribute/default_spec.rb +236 -0
  308. data/spec/unit/trello/schema/attribute_builder_spec.rb +55 -0
  309. data/spec/unit/trello/schema/attribute_registration_spec.rb +59 -0
  310. data/spec/unit/trello/schema/serializer/default_spec.rb +19 -0
  311. data/spec/unit/trello/schema/serializer/time_spec.rb +39 -0
  312. data/spec/unit/trello/schema_spec.rb +25 -0
  313. data/spec/webhook_spec.rb +23 -7
  314. metadata +556 -33
data/lib/trello/card.rb CHANGED
@@ -43,162 +43,54 @@ module Trello
43
43
  # @return [Array<String>] Array of strings
44
44
 
45
45
  class Card < BasicData
46
- register_attributes :id, :short_id, :name, :desc, :due, :due_complete, :closed, :url, :short_url,
47
- :board_id, :member_ids, :list_id, :pos, :last_activity_date, :labels, :card_labels,
48
- :cover_image_id, :badges, :card_members, :source_card_id, :source_card_properties,
49
- readonly: [ :id, :short_id, :url, :short_url, :last_activity_date, :badges, :card_members ]
46
+ schema do
47
+ # readonly
48
+ attribute :id, readonly: true, primary_key: true
49
+ attribute :short_id, readonly: true, remote_key: 'idShort'
50
+ attribute :url, readonly: true
51
+ attribute :short_url, readonly: true, remote_key: 'shortUrl'
52
+ attribute :last_activity_date, readonly: true, remote_key: 'dateLastActivity', serializer: 'Time'
53
+ attribute :labels, readonly: true, default: [], serializer: 'Labels'
54
+ attribute :badges, readonly: true
55
+ attribute :card_members, readonly: true, remote_key: 'members'
56
+
57
+ # Writable
58
+ attribute :name
59
+ attribute :desc
60
+ attribute :due, serializer: 'Time'
61
+ attribute :due_complete, remote_key: 'dueComplete'
62
+ attribute :member_ids, remote_key: 'idMembers'
63
+ attribute :list_id, remote_key: 'idList'
64
+ attribute :pos
65
+ attribute :card_labels, remote_key: 'idLabels'
66
+
67
+ # Writable but for create only
68
+ attribute :source_card_id, create_only: true, remote_key: 'idCardSource'
69
+ attribute :keep_from_source, create_only: true, remote_key: 'keepFromSource'
70
+
71
+ # Writable but for update only
72
+ attribute :closed, update_only: true
73
+ attribute :board_id, update_only: true, remote_key: 'idBoard'
74
+ attribute :cover_image_id, update_only: true, remote_key: 'idAttachmentCover'
75
+
76
+ # Deprecated
77
+ attribute :source_card_properties, create_only: true, remote_key: 'keepFromSource'
78
+ end
79
+
50
80
  validates_presence_of :id, :name, :list_id
51
81
  validates_length_of :name, in: 1..16384
52
82
  validates_length_of :desc, in: 0..16384
53
83
 
54
84
  include HasActions
55
85
 
56
- SYMBOL_TO_STRING = {
57
- id: 'id',
58
- short_id: 'idShort',
59
- name: 'name',
60
- desc: 'desc',
61
- due: 'due',
62
- due_complete: 'dueComplete',
63
- closed: 'closed',
64
- url: 'url',
65
- short_url: 'shortUrl',
66
- board_id: 'idBoard',
67
- member_ids: 'idMembers',
68
- cover_image_id: 'idAttachmentCover',
69
- list_id: 'idList',
70
- pos: 'pos',
71
- last_activity_date: 'dateLastActivity',
72
- card_labels: 'idLabels',
73
- labels: 'labels',
74
- badges: 'badges',
75
- card_members: 'members',
76
- source_card_id: "idCardSource",
77
- source_card_properties: "keepFromSource"
78
- }
79
-
80
- class << self
81
- # Find a specific card by its id.
82
- #
83
- # @raise [Trello::Error] if the card could not be found.
84
- #
85
- # @return [Trello::Card]
86
- def find(id, params = {})
87
- client.find(:card, id, params)
88
- end
89
-
90
- # Create a new card and save it on Trello.
91
- #
92
- # If using source_card_id to duplicate a card, make sure to save
93
- # the source card to Trello before calling this method to assure
94
- # the correct data is used in the duplication.
95
- #
96
- # @param [Hash] options
97
- # @option options [String] :name The name of the new card.
98
- # @option options [String] :list_id ID of the list that the card should
99
- # be added to.
100
- # @option options [String] :desc A string with a
101
- # length from 0 to 16384.
102
- # @option options [String] :member_ids A comma-separated list of
103
- # objectIds (24-character hex strings).
104
- # @option options [String] :card_labels A comma-separated list of
105
- # objectIds (24-character hex strings).
106
- # @option options [Date] :due A date, or `nil`.
107
- # @option options [String] :pos A position. `"top"`, `"bottom"`, or a
108
- # positive number. Defaults to `"bottom"`.
109
- # @option options [String] :source_card_id ID of the card to copy
110
- # @option options [String] :source_card_properties A single, or array of,
111
- # string properties to copy from source card.
112
- # `"all"`, `"checklists"`, `"due"`, `"members"`, or `nil`.
113
- # Defaults to `"all"`.
114
- #
115
- # @raise [Trello::Error] if the card could not be created.
116
- #
117
- # @return [Trello::Card]
118
- def create(options)
119
- client.create(:card,
120
- 'name' => options[:name],
121
- 'idList' => options[:list_id],
122
- 'desc' => options[:desc],
123
- 'idMembers' => options[:member_ids],
124
- 'idLabels' => options[:card_labels],
125
- 'due' => options[:due],
126
- 'due_complete' => options[:due_complete] || false,
127
- 'pos' => options[:pos],
128
- 'idCardSource' => options[:source_card_id],
129
- 'keepFromSource' => options.key?(:source_card_properties) ? options[:source_card_properties] : 'all'
130
- )
131
- end
132
- end
133
-
134
- # Update the fields of a card.
135
- #
136
- # Supply a hash of string keyed data retrieved from the Trello API representing
137
- # a card.
138
- #
139
- # Note that this this method does not save anything new to the Trello API,
140
- # it just assigns the input attributes to your local object. If you use
141
- # this method to assign attributes, call `save` or `update!` afterwards if
142
- # you want to persist your changes to Trello.
143
- #
144
- # @param [Hash] fields
145
- # @option fields [String] :id
146
- # @option fields [String] :short_id
147
- # @option fields [String] :name The new name of the card.
148
- # @option fields [String] :desc A string with a length from 0 to
149
- # 16384.
150
- # @option fields [Date] :due A date, or `nil`.
151
- # @option fields [Boolean] :due_complete
152
- # @option fields [Boolean] :closed
153
- # @option fields [String] :url
154
- # @option fields [String] :short_url
155
- # @option fields [String] :board_id
156
- # @option fields [String] :member_ids A comma-separated list of objectIds
157
- # (24-character hex strings).
158
- # @option fields [String] :pos A position. `"top"`, `"bottom"`, or a
159
- # positive number. Defaults to `"bottom"`.
160
- # @option fields [Array] :labels An Array of Trello::Label objects
161
- # derived from the JSON response
162
- # @option fields [String] :card_labels A comma-separated list of
163
- # objectIds (24-character hex strings).
164
- # @option fields [Object] :cover_image_id
165
- # @option fields [Object] :badges
166
- # @option fields [Object] :card_members
167
- # @option fields [String] :source_card_id
168
- # @option fields [Array] :source_card_properties
169
- #
170
- # @return [Trello::Card] self
171
- def update_fields(fields)
172
- attributes[:id] = fields[SYMBOL_TO_STRING[:id]] || attributes[:id]
173
- attributes[:short_id] = fields[SYMBOL_TO_STRING[:short_id]] || attributes[:short_id]
174
- attributes[:name] = fields[SYMBOL_TO_STRING[:name]] || fields[:name] || attributes[:name]
175
- attributes[:desc] = fields[SYMBOL_TO_STRING[:desc]] || fields[:desc] || attributes[:desc]
176
- attributes[:due] = Time.iso8601(fields[SYMBOL_TO_STRING[:due]]) rescue nil if fields.has_key?(SYMBOL_TO_STRING[:due])
177
- attributes[:due] = fields[:due] if fields.has_key?(:due)
178
- attributes[:due_complete] = fields[SYMBOL_TO_STRING[:due_complete]] if fields.has_key?(SYMBOL_TO_STRING[:due_complete])
179
- attributes[:due_complete] ||= false
180
- attributes[:closed] = fields[SYMBOL_TO_STRING[:closed]] if fields.has_key?(SYMBOL_TO_STRING[:closed])
181
- attributes[:url] = fields[SYMBOL_TO_STRING[:url]] || attributes[:url]
182
- attributes[:short_url] = fields[SYMBOL_TO_STRING[:short_url]] || attributes[:short_url]
183
- attributes[:board_id] = fields[SYMBOL_TO_STRING[:board_id]] || attributes[:board_id]
184
- attributes[:member_ids] = fields[SYMBOL_TO_STRING[:member_ids]] || fields[:member_ids] || attributes[:member_ids]
185
- attributes[:list_id] = fields[SYMBOL_TO_STRING[:list_id]] || fields[:list_id] || attributes[:list_id]
186
- attributes[:pos] = fields[SYMBOL_TO_STRING[:pos]] || fields[:pos] || attributes[:pos]
187
- attributes[:labels] = (fields[SYMBOL_TO_STRING[:labels]] || []).map { |lbl| Trello::Label.new(lbl) }.presence || attributes[:labels].presence || []
188
- attributes[:card_labels] = fields[SYMBOL_TO_STRING[:card_labels]] || fields[:card_labels] || attributes[:card_labels]
189
- attributes[:last_activity_date] = Time.iso8601(fields[SYMBOL_TO_STRING[:last_activity_date]]) rescue nil if fields.has_key?(SYMBOL_TO_STRING[:last_activity_date])
190
- attributes[:cover_image_id] = fields[SYMBOL_TO_STRING[:cover_image_id]] || attributes[:cover_image_id]
191
- attributes[:badges] = fields[SYMBOL_TO_STRING[:badges]] || attributes[:badges]
192
- attributes[:card_members] = fields[SYMBOL_TO_STRING[:card_members]] || attributes[:card_members]
193
- attributes[:source_card_id] = fields[SYMBOL_TO_STRING[:source_card_id]] || fields[:source_card_id] || attributes[:source_card_id]
194
- attributes[:source_card_properties] = fields[SYMBOL_TO_STRING[:source_card_properties]] || fields[:source_card_properties] || attributes[:source_card_properties]
195
- self
196
- end
197
-
198
86
  # Returns a reference to the board this card is part of.
199
87
  one :board, path: :boards, using: :board_id
88
+
200
89
  # Returns a reference to the cover image attachment
201
- one :cover_image, path: :attachments, using: :cover_image_id
90
+ def cover_image(params = {})
91
+ response = client.get("/cards/#{id}/attachments/#{cover_image_id}", params)
92
+ CoverImage.from_response(response)
93
+ end
202
94
 
203
95
  # Returns a list of checklists associated with the card.
204
96
  #
@@ -239,50 +131,6 @@ module Trello
239
131
  Member.from_response client.get("/cards/#{id}/membersVoted")
240
132
  end
241
133
 
242
- # Saves a record.
243
- #
244
- # @raise [Trello::Error] if the card could not be saved
245
- #
246
- # @return [String] The JSON representation of the saved card returned by
247
- # the Trello API.
248
- def save
249
- # If we have an id, just update our fields.
250
- return update! if id
251
-
252
- from_response client.post("/cards", {
253
- name: name,
254
- desc: desc,
255
- idList: list_id,
256
- idMembers: member_ids,
257
- idLabels: card_labels,
258
- pos: pos,
259
- due: due,
260
- dueComplete: due_complete,
261
- idCardSource: source_card_id,
262
- keepFromSource: source_card_properties
263
- })
264
- end
265
-
266
- # Update an existing record.
267
- #
268
- # Warning: this updates all fields using values already in memory. If
269
- # an external resource has updated these fields, you should refresh!
270
- # this object before making your changes, and before updating the record.
271
- #
272
- # @raise [Trello::Error] if the card could not be updated.
273
- #
274
- # @return [String] The JSON representation of the updated card returned by
275
- # the Trello API.
276
- def update!
277
- @previously_changed = changes
278
- # extract only new values to build payload
279
- payload = Hash[changes.map { |key, values| [SYMBOL_TO_STRING[key.to_sym].to_sym, values[1]] }]
280
- @changed_attributes.try(:clear)
281
- changes_applied if respond_to?(:changes_applied)
282
-
283
- client.put("/cards/#{id}", payload)
284
- end
285
-
286
134
  # Delete this card
287
135
  #
288
136
  # @return [String] the JSON response from the Trello API
@@ -315,7 +163,7 @@ module Trello
315
163
 
316
164
  # Is the record valid?
317
165
  def valid?
318
- name && list_id
166
+ !(name && list_id).nil?
319
167
  end
320
168
 
321
169
  # Add a comment with the supplied text.
@@ -324,10 +172,12 @@ module Trello
324
172
  end
325
173
 
326
174
  # Add a checklist to this card
327
- def add_checklist(checklist)
328
- client.post("/cards/#{id}/checklists", {
329
- value: checklist.id
330
- })
175
+ def add_checklist(checklist, name: nil, position: nil)
176
+ payload = { idChecklistSource: checklist.id }
177
+ payload[:name] = name if name
178
+ payload[:pos] = position if position
179
+
180
+ client.post("/cards/#{id}/checklists", payload)
331
181
  end
332
182
 
333
183
  # create a new checklist and add it to this card
@@ -366,14 +216,14 @@ module Trello
366
216
 
367
217
  # Add a member to this card
368
218
  def add_member(member)
369
- client.post("/cards/#{id}/members", {
219
+ client.post("/cards/#{id}/idMembers", {
370
220
  value: member.id
371
221
  })
372
222
  end
373
223
 
374
224
  # Remove a member from this card
375
225
  def remove_member(member)
376
- client.delete("/cards/#{id}/members/#{member.id}")
226
+ client.delete("/cards/#{id}/idMembers/#{member.id}")
377
227
  end
378
228
 
379
229
  # Current authenticated user upvotes a card
@@ -465,5 +315,6 @@ module Trello
465
315
  def me
466
316
  @me ||= Member.find(:me)
467
317
  end
318
+
468
319
  end
469
320
  end
@@ -5,78 +5,35 @@ module Trello
5
5
  # @return [String]
6
6
  # @!attribute [rw] name
7
7
  # @return [String]
8
- # @!attribute [r] description
9
- # @return [String]
10
- # @!attribute [r] closed
11
- # @return [Boolean]
12
8
  # @!attribute [rw] position
13
9
  # @return [Object]
14
- # @!attribute [r] url
15
- # @return [String]
16
10
  # @!attribute [r] check_items
17
11
  # @return [Object]
18
12
  # @!attribute [r] board_id
19
13
  # @return [String] A 24-character hex string
20
- # @!attribute [r] list_id
21
- # @return [String] A 24-character hex string
22
- # @!attribute [r] member_ids
23
- # @return [Array<String>] An array of 24-character hex strings
14
+ # @!attribute [rw] card_id
15
+ # @return [String]
16
+ # @!attribute [w] source_checklist_id
17
+ # @return [String]
24
18
  class Checklist < BasicData
25
- register_attributes :id, :name, :description, :closed, :position, :url, :check_items, :board_id, :list_id, :card_id, :member_ids,
26
- readonly: [:id, :description, :closed, :url, :check_items, :board_id, :list_id, :card_id, :member_ids]
27
- validates_presence_of :id, :board_id, :list_id
28
- validates_length_of :name, in: 1..16384
29
-
30
- class << self
31
- # Locate a specific checklist by its id.
32
- def find(id, params = {})
33
- client.find(:checklist, id, params)
34
- end
35
-
36
- def create(options)
37
- client.create(:checklist,
38
- 'name' => options[:name],
39
- 'idCard' => options[:card_id])
40
- end
41
- end
19
+ schema do
20
+ attribute :id, readonly: true, primary_key: true
42
21
 
43
- # Update the fields of a checklist.
44
- #
45
- # Supply a hash of string keyed data retrieved from the Trello API representing
46
- # a checklist.
47
- def update_fields(fields)
48
- attributes[:id] = fields['id'] || attributes[:id]
49
- attributes[:name] = fields['name'] || fields[:name] || attributes[:name]
50
- attributes[:description] = fields['desc'] || attributes[:description]
51
- attributes[:closed] = fields['closed'] if fields.has_key?('closed')
52
- attributes[:url] = fields['url'] || attributes[:url]
53
- attributes[:check_items] = fields['checkItems'] if fields.has_key?('checkItems')
54
- attributes[:position] = fields['pos'] || attributes[:position]
55
- attributes[:board_id] = fields['idBoard'] || attributes[:board_id]
56
- attributes[:card_id] = fields['idCard'] || fields[:card_id] || attributes[:card_id]
57
- attributes[:list_id] = fields['idList'] || attributes[:list_id]
58
- attributes[:member_ids] = fields['idMembers'] || attributes[:member_ids]
59
- self
60
- end
22
+ # Readonly
23
+ attribute :check_items, readonly: true, remote_key: 'checkItems'
24
+ attribute :board_id, readonly: true, remote_key: 'idBoard'
61
25
 
62
- # Check if the checklist is currently active.
63
- def closed?
64
- closed
65
- end
26
+ # Writable
27
+ attribute :name
28
+ attribute :position, remote_key: 'pos'
66
29
 
67
- # Save a record.
68
- def save
69
- return update! if id
70
-
71
- from_response(client.post("/checklists", {
72
- name: name,
73
- idCard: card_id
74
- }))
30
+ # Writable but for update only
31
+ attribute :card_id, create_only: true, remote_key: 'idCard'
32
+ attribute :source_checklist_id, create_only: true, remote_key: 'idChecklistSource'
75
33
  end
76
34
 
77
- def update!
78
- from_response(client.put("/checklists/#{id}", {name: name, pos: position}))
79
- end
35
+ validates_presence_of :id
36
+ validates_length_of :name, in: 1..16384
80
37
 
81
38
  # Return a list of items on the checklist.
82
39
  def items
@@ -91,17 +48,6 @@ module Trello
91
48
  # Return a reference to the card the checklist is on.
92
49
  one :card, path: :checklists, using: :card_id
93
50
 
94
- # Return a reference to the list the checklist is on.
95
- one :list, path: :lists, using: :list_id
96
-
97
- # Return a list of members active in this checklist.
98
- def members
99
- members = member_ids.map do |member_id|
100
- Member.find(member_id)
101
- end
102
- MultiAssociation.new(self, members).proxy
103
- end
104
-
105
51
  # Add an item to the checklist
106
52
  def add_item(name, checked = false, position = 'bottom')
107
53
  client.post("/checklists/#{id}/checkItems", {name: name, checked: checked, pos: position})
@@ -1,62 +1,75 @@
1
1
  module Trello
2
2
  # A Comment is a string with a creation date; it resides inside a Card and belongs to a User.
3
3
  #
4
- # @!attribute [r] action_id
4
+ # @!attribute [r] id
5
5
  # @return [String]
6
- # @!attribute [r] text
6
+ # @!attribute [w] text
7
7
  # @return [String]
8
8
  # @!attribute [r] date
9
9
  # @return [Datetime]
10
- # @!attribute [r] member_creator_id
10
+ # @!attribute [r] creator_id
11
11
  # @return [String]
12
+ # @!attribute [r] data
13
+ # @return [Hash]
14
+ # @!attribute [r] type
15
+ # @return [String]
16
+ # @!attribute [r] limits
17
+ # @return [Hash]
18
+ # @!attribute [r] app_creator
19
+ # @return [String]
20
+ # @!attribute [r] display
21
+ # @return [Hash]
12
22
  class Comment < BasicData
13
- register_attributes :action_id, :text, :date, :member_creator_id,
14
- readonly: [ :action_id, :text, :date, :member_creator_id ]
15
- validates_presence_of :action_id, :text, :date, :member_creator_id
23
+
24
+ schema do
25
+ # Readonly
26
+ attribute :id, readonly: true, primary_key: true
27
+ attribute :creator_id, readonly: true, remote_key: 'idMemberCreator'
28
+ attribute :data, readonly: true
29
+ attribute :type, readonly: true
30
+ attribute :date, readonly: true, serializer: 'Time'
31
+ attribute :limits, readonly: true
32
+ attribute :app_creator, readonly: true, remote_key: 'appCreator'
33
+ attribute :display, readonly: true
34
+
35
+ # Writable
36
+ attribute :text, update_only: true
37
+ end
38
+
39
+ validates_presence_of :id, :text, :date, :creator_id
16
40
  validates_length_of :text, in: 1..16384
17
41
 
18
42
  class << self
19
- # Locate a specific action and return a new Comment object.
20
43
  def find(action_id)
21
- client.find(:action, action_id, filter: commentCard)
44
+ response = client.get("/actions/#{action_id}")
45
+ self.parse response do |data|
46
+ data.client = client
47
+ end
22
48
  end
23
49
  end
24
50
 
25
- # Update the attributes of a Comment
26
- #
27
- # Supply a hash of string keyed data retrieved from the Trello API representing
28
- # a Comment.
29
- def update_fields(fields)
30
- attributes[:action_id] = fields['id'] || attributes[:action_id]
31
- attributes[:text] = fields['data']['text'] || attributes[:text]
32
- attributes[:date] = Time.iso8601(fields['date']) if fields.has_key?('date')
33
- attributes[:member_creator_id] = fields['idMemberCreator'] || attributes[:member_creator_id]
34
- self
35
- end
36
-
37
51
  # Returns the board this comment is located
38
52
  def board
39
- Board.from_response client.get("/actions/#{action_id}/board")
53
+ Board.from_response client.get("/actions/#{id}/board")
40
54
  end
41
55
 
42
56
  # Returns the card the comment is located
43
57
  def card
44
- Card.from_response client.get("/actions/#{action_id}/card")
58
+ Card.from_response client.get("/actions/#{id}/card")
45
59
  end
46
60
 
47
61
  # Returns the list the comment is located
48
62
  def list
49
- List.from_response client.get("/actions/#{action_id}/list")
63
+ List.from_response client.get("/actions/#{id}/list")
50
64
  end
51
65
 
52
66
  # Deletes the comment from the card
53
67
  def delete
54
- ruta = "/actions/#{action_id}"
68
+ ruta = "/actions/#{id}"
55
69
  client.delete(ruta)
56
70
  end
57
71
 
58
-
59
72
  # Returns the member who created the comment.
60
- one :member_creator, via: Member, path: :members, using: :member_creator_id
73
+ one :member_creator, via: Member, path: :members, using: :creator_id
61
74
  end
62
75
  end
@@ -4,5 +4,25 @@ module Trello
4
4
  # This is normally an attachment that the user (or trello) has set
5
5
  # as the cover image
6
6
  class CoverImage < Attachment
7
+ # Same with Attachment may need refactor it to support inheritance
8
+ schema do
9
+ # Readonly
10
+ attribute :id, readonly: true, primary_key: true
11
+ attribute :position, readonly: true, remote_key: 'pos'
12
+ attribute :bytes, readonly: true
13
+ attribute :member_id, remote_key: 'idMember', readonly: true
14
+ attribute :date, serializer: 'Time', readonly: true
15
+ attribute :is_upload, remote_key: 'isUpload', readonly: true
16
+ attribute :previews, readonly: true
17
+ attribute :file_name, remote_key: 'fileName', readonly: true
18
+ attribute :edge_color, remote_key: 'edgeColor', readonly: true
19
+
20
+ # Writable but create only
21
+ attribute :name, create_only: true
22
+ attribute :url, create_only: true
23
+ attribute :mime_type, remote_key: 'mimeType', create_only: true
24
+ attribute :file, create_only: true
25
+ attribute :set_as_cover, remote_key: 'setCover', create_only: true
26
+ end
7
27
  end
8
28
  end
@@ -1,53 +1,54 @@
1
1
  module Trello
2
2
  # A Custom Field can be activated on a board. Values are stored at the card level.
3
3
  #
4
- # @!attribute id
4
+ # @!attribute [r] id
5
5
  # @return [String]
6
- # @!attribute model_id
6
+ # @!attribute [rw] model_id
7
7
  # @return [String]
8
- # @!attribute model_type
8
+ # @!attribute [rw] model_type
9
9
  # @return [String]
10
- # @!attribute field_group
10
+ # @!attribute [r] field_group
11
11
  # @return [String]
12
- # @!attribute name
12
+ # @!attribute [rw] name
13
13
  # @return [String]
14
- # @!attribute pos
14
+ # @!attribute [rw] position
15
15
  # @return [Float]
16
- # @!attribute type
16
+ # @!attribute [rw] type
17
17
  # @return [String]
18
- # @!attribute options
18
+ # @!attribute [rw] checkbox_options
19
19
  # @return [Array<Hash>]
20
+ # @!attribute [w] enable_display_on_card
21
+ # @return [Boolean]
20
22
  class CustomField < BasicData
21
- register_attributes :id, :model_id, :model_type, :field_group, :name, :pos, :type
22
- validates_presence_of :id, :model_id, :model_type, :name, :type, :pos
23
23
 
24
- SYMBOL_TO_STRING = {
25
- id: 'id',
26
- name: 'name',
27
- model_id: 'idModel',
28
- model_type: 'modelType',
29
- field_group: 'fieldGroup',
30
- type: 'type',
31
- pos: 'pos'
32
- }
24
+ schema do
25
+ # Readonly
26
+ attribute :id, readonly: true, primary_key: true
27
+ attribute :field_group, readonly: true, remote_key: 'fieldGroup'
28
+
29
+ # Writable
30
+ attribute :name
31
+ attribute :position, remote_key: 'pos'
32
+ attribute :enable_display_on_card, remote_key: 'cardFront', class_name: 'CustomFieldDisplay'
33
+
34
+ # Writable but for create only
35
+ attribute :model_id, remote_key: 'idModel', create_only: true
36
+ attribute :model_type, remote_key: 'modelType', create_only: true
37
+ attribute :type, create_only: true
38
+ attribute :checkbox_options, remote_key: 'options', create_only: true
39
+ end
40
+
41
+ validates_presence_of :id, :model_id, :model_type, :name, :type, :position
33
42
 
34
43
  class << self
35
44
  # Find a custom field by its id.
36
45
  def find(id, params = {})
37
46
  client.find('customFields', id, params)
38
47
  end
48
+ end
39
49
 
40
- # Create a new custom field and save it on Trello.
41
- def create(options)
42
- client.create('customFields',
43
- 'name' => options[:name],
44
- 'idModel' => options[:model_id],
45
- 'modelType' => options[:model_type],
46
- 'fieldGroup' => options[:field_group],
47
- 'type' => options[:type],
48
- 'pos' => options[:pos]
49
- )
50
- end
50
+ def collection_name
51
+ 'customFields'
51
52
  end
52
53
 
53
54
  # References Board where this custom field is located
@@ -57,43 +58,6 @@ module Trello
57
58
  # If type == 'list'
58
59
  many :custom_field_options, path: 'options'
59
60
 
60
- def update_fields(fields)
61
- attributes[:id] = fields[SYMBOL_TO_STRING[:id]] || fields[:id] || attributes[:id]
62
- attributes[:name] = fields[SYMBOL_TO_STRING[:name]] || fields[:name] || attributes[:name]
63
- attributes[:model_id] = fields[SYMBOL_TO_STRING[:model_id]] || fields[:model_id] || attributes[:model_id]
64
- attributes[:model_type] = fields[SYMBOL_TO_STRING[:model_type]] || fields[:model_type] || attributes[:model_type]
65
- attributes[:field_group] = fields[SYMBOL_TO_STRING[:field_group]] || fields[:field_group] || attributes[:field_group]
66
- attributes[:type] = fields[SYMBOL_TO_STRING[:type]] || fields[:type] || attributes[:type]
67
- attributes[:pos] = fields[SYMBOL_TO_STRING[:pos]] || fields[:pos] || attributes[:pos]
68
- self
69
- end
70
-
71
- # Saves a record.
72
- def save
73
- # If we have an id, just update our fields.
74
- return update! if id
75
-
76
- from_response client.post("/customFields", {
77
- name: name,
78
- idModel: model_id,
79
- modelType: model_type,
80
- type: type,
81
- pos: pos,
82
- fieldGroup: field_group
83
- })
84
- end
85
-
86
- # Update an existing custom field.
87
- def update!
88
- @previously_changed = changes
89
- # extract only new values to build payload
90
- payload = Hash[changes.map { |key, values| [SYMBOL_TO_STRING[key.to_sym].to_sym, values[1]] }]
91
- @changed_attributes.try(:clear)
92
- changes_applied if respond_to?(:changes_applied)
93
-
94
- client.put("/customFields/#{id}", payload)
95
- end
96
-
97
61
  # Delete this custom field
98
62
  # Also deletes all associated values across all cards
99
63
  def delete