tacokit 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.pryrc +7 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +18 -0
  6. data/Gemfile +28 -0
  7. data/Guardfile +12 -0
  8. data/LICENSE +22 -0
  9. data/README.md +134 -0
  10. data/Rakefile +8 -0
  11. data/config.ru +7 -0
  12. data/lib/tacokit/authorization.rb +46 -0
  13. data/lib/tacokit/client/actions.rb +54 -0
  14. data/lib/tacokit/client/boards.rb +124 -0
  15. data/lib/tacokit/client/cards.rb +143 -0
  16. data/lib/tacokit/client/checklists.rb +59 -0
  17. data/lib/tacokit/client/labels.rb +44 -0
  18. data/lib/tacokit/client/lists.rb +54 -0
  19. data/lib/tacokit/client/members.rb +91 -0
  20. data/lib/tacokit/client/notifications.rb +48 -0
  21. data/lib/tacokit/client/organizations.rb +79 -0
  22. data/lib/tacokit/client/searches.rb +20 -0
  23. data/lib/tacokit/client/tokens.rb +41 -0
  24. data/lib/tacokit/client/types.rb +11 -0
  25. data/lib/tacokit/client/webhooks.rb +43 -0
  26. data/lib/tacokit/client.rb +169 -0
  27. data/lib/tacokit/configuration.rb +60 -0
  28. data/lib/tacokit/error.rb +31 -0
  29. data/lib/tacokit/middleware/boom.rb +26 -0
  30. data/lib/tacokit/middleware/debug.rb +22 -0
  31. data/lib/tacokit/middleware.rb +15 -0
  32. data/lib/tacokit/resource.rb +114 -0
  33. data/lib/tacokit/response.rb +23 -0
  34. data/lib/tacokit/transform.rb +97 -0
  35. data/lib/tacokit/utils.rb +51 -0
  36. data/lib/tacokit/version.rb +3 -0
  37. data/lib/tacokit.rb +20 -0
  38. data/script/console +6 -0
  39. data/spec/cassettes/Tacokit_Client/_connection/authorized_GET_request_with_app_key_and_token_params.json +1 -0
  40. data/spec/cassettes/Tacokit_Client_Actions/_action/returns_a_token_authorized_action.json +1 -0
  41. data/spec/cassettes/Tacokit_Client_Actions/_action/returns_oauth_authorized_board.json +1 -0
  42. data/spec/cassettes/Tacokit_Client_Actions/_action_field/returns_a_hash.json +1 -0
  43. data/spec/cassettes/Tacokit_Client_Actions/_action_field/returns_a_resource.json +1 -0
  44. data/spec/cassettes/Tacokit_Client_Actions/_action_field/returns_a_value.json +1 -0
  45. data/spec/cassettes/Tacokit_Client_Actions/_action_resource/returns_action_board.json +1 -0
  46. data/spec/cassettes/Tacokit_Client_Actions/_action_resource/returns_action_entities.json +1 -0
  47. data/spec/cassettes/Tacokit_Client_Actions/_action_resource/returns_action_memberships.json +1 -0
  48. data/spec/cassettes/Tacokit_Client_Actions/_delete_action/deletes_an_action.json +1 -0
  49. data/spec/cassettes/Tacokit_Client_Actions/_update_action/updates_a_action.json +1 -0
  50. data/spec/cassettes/Tacokit_Client_Actions/_update_action/updates_an_action.json +1 -0
  51. data/spec/cassettes/Tacokit_Client_Actions/_update_action_text/updates_an_action.json +1 -0
  52. data/spec/cassettes/Tacokit_Client_Boards/_add_board_member/adds_invites_member_to_board.json +1 -0
  53. data/spec/cassettes/Tacokit_Client_Boards/_board/returns_a_token_authorized_board.json +1 -0
  54. data/spec/cassettes/Tacokit_Client_Boards/_board/returns_oauth_authorized_board.json +1 -0
  55. data/spec/cassettes/Tacokit_Client_Boards/_board_field/returns_a_hash.json +1 -0
  56. data/spec/cassettes/Tacokit_Client_Boards/_board_field/returns_a_value.json +1 -0
  57. data/spec/cassettes/Tacokit_Client_Boards/_board_field/returns_an_array.json +1 -0
  58. data/spec/cassettes/Tacokit_Client_Boards/_board_resource/returns_board_actions.json +1 -0
  59. data/spec/cassettes/Tacokit_Client_Boards/_board_resource/returns_board_cards.json +1 -0
  60. data/spec/cassettes/Tacokit_Client_Boards/_board_resource/returns_board_members.json +1 -0
  61. data/spec/cassettes/Tacokit_Client_Boards/_create_board/creates_a_board.json +1 -0
  62. data/spec/cassettes/Tacokit_Client_Boards/_create_board_resource/creates_a_board_calendar_key.json +1 -0
  63. data/spec/cassettes/Tacokit_Client_Boards/_create_board_resource/creates_a_board_label.json +1 -0
  64. data/spec/cassettes/Tacokit_Client_Boards/_create_board_resource/creates_a_board_resource.json +1 -0
  65. data/spec/cassettes/Tacokit_Client_Boards/_update_board/updates_a_board.json +1 -0
  66. data/spec/cassettes/Tacokit_Client_Boards/_update_board/updates_nested_resource.json +1 -0
  67. data/spec/cassettes/Tacokit_Client_Boards/_update_board_field/updates_a_board_field.json +1 -0
  68. data/spec/cassettes/Tacokit_Client_Boards/_update_board_resource/updates_member.json +1 -0
  69. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_id.json +1 -0
  70. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_short_link.json +1 -0
  71. data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_a_hash.json +1 -0
  72. data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_a_value.json +1 -0
  73. data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_an_array.json +1 -0
  74. data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_actions.json +1 -0
  75. data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_board.json +1 -0
  76. data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_check_item_states.json +1 -0
  77. data/spec/cassettes/Tacokit_Client_Cards/_create_card/creates_a_card.json +1 -0
  78. data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/attaches_external_url.json +1 -0
  79. data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/uploads_local_file.json +1 -0
  80. data/spec/cassettes/Tacokit_Client_Cards/_create_card_comment/creates_a_comment.json +1 -0
  81. data/spec/cassettes/Tacokit_Client_Cards/_delete_card/deletes_a_card.json +1 -0
  82. data/spec/cassettes/Tacokit_Client_Cards/_delete_card_resource/deletes_resource.json +1 -0
  83. data/spec/cassettes/Tacokit_Client_Cards/_update_card/updates_a_card.json +1 -0
  84. data/spec/cassettes/Tacokit_Client_Checklists/_checklist/returns_a_checklist_by_id.json +1 -0
  85. data/spec/cassettes/Tacokit_Client_Checklists/_checklist_field/returns_a_value.json +1 -0
  86. data/spec/cassettes/Tacokit_Client_Checklists/_checklist_resource/returns_checklist_actions.json +1 -0
  87. data/spec/cassettes/Tacokit_Client_Checklists/_checklist_resource/returns_checklist_board.json +1 -0
  88. data/spec/cassettes/Tacokit_Client_Checklists/_checklist_resource/returns_checklist_prefs.json +1 -0
  89. data/spec/cassettes/Tacokit_Client_Checklists/_create_checklist/creates_a_checklist.json +1 -0
  90. data/spec/cassettes/Tacokit_Client_Checklists/_delete_checklist/deletes_a_checklist.json +1 -0
  91. data/spec/cassettes/Tacokit_Client_Checklists/_update_checklist/updates_a_checklist.json +1 -0
  92. data/spec/cassettes/Tacokit_Client_Labels/_create_label/creates_a_label.json +1 -0
  93. data/spec/cassettes/Tacokit_Client_Labels/_delete_label/deletes_a_label.json +1 -0
  94. data/spec/cassettes/Tacokit_Client_Labels/_label/returns_a_label_by_id.json +1 -0
  95. data/spec/cassettes/Tacokit_Client_Labels/_label_resource/returns_a_board.json +1 -0
  96. data/spec/cassettes/Tacokit_Client_Labels/_labels/returns_a_label_by_id.json +1 -0
  97. data/spec/cassettes/Tacokit_Client_Labels/_update_label/updates_a_label.json +1 -0
  98. data/spec/cassettes/Tacokit_Client_Lists/_create_list/creates_a_list.json +1 -0
  99. data/spec/cassettes/Tacokit_Client_Lists/_list/returns_a_list_by_id.json +1 -0
  100. data/spec/cassettes/Tacokit_Client_Lists/_list_field/returns_a_value.json +1 -0
  101. data/spec/cassettes/Tacokit_Client_Lists/_list_resource/returns_list_actions.json +1 -0
  102. data/spec/cassettes/Tacokit_Client_Lists/_list_resource/returns_list_board.json +1 -0
  103. data/spec/cassettes/Tacokit_Client_Lists/_list_resource/returns_list_cards.json +1 -0
  104. data/spec/cassettes/Tacokit_Client_Lists/_update_list/updates_a_list.json +1 -0
  105. data/spec/cassettes/Tacokit_Client_Members/_member/authenticated/returns_self.json +1 -0
  106. data/spec/cassettes/Tacokit_Client_Members/_member/raises_error_for_missing_token.json +1 -0
  107. data/spec/cassettes/Tacokit_Client_Members/_member/returns_a_member.json +1 -0
  108. data/spec/cassettes/Tacokit_Client_Members/_member/returns_self.json +1 -0
  109. data/spec/cassettes/Tacokit_Client_Members/_member/supports_query_fields_as_string_or_array.json +1 -0
  110. data/spec/cassettes/Tacokit_Client_Members/_member_field/returns_a_hash.json +1 -0
  111. data/spec/cassettes/Tacokit_Client_Members/_member_field/returns_a_member_field.json +1 -0
  112. data/spec/cassettes/Tacokit_Client_Members/_member_field/returns_a_resource.json +1 -0
  113. data/spec/cassettes/Tacokit_Client_Members/_member_field/returns_a_value.json +1 -0
  114. data/spec/cassettes/Tacokit_Client_Members/_member_field/returns_an_array.json +1 -0
  115. data/spec/cassettes/Tacokit_Client_Members/_member_resource/returns_member_actions.json +1 -0
  116. data/spec/cassettes/Tacokit_Client_Members/_member_resource/returns_member_board_stars.json +1 -0
  117. data/spec/cassettes/Tacokit_Client_Members/_member_resource/returns_member_boards.json +1 -0
  118. data/spec/cassettes/Tacokit_Client_Members/_update_member/updates_a_member.json +1 -0
  119. data/spec/cassettes/Tacokit_Client_Members/_update_member/updates_nested_resource.json +1 -0
  120. data/spec/cassettes/Tacokit_Client_Notifications/_notification/returns_a_notification_by_id.json +1 -0
  121. data/spec/cassettes/Tacokit_Client_Notifications/_notification_field/returns_a_hash.json +1 -0
  122. data/spec/cassettes/Tacokit_Client_Notifications/_notification_field/returns_a_resource.json +1 -0
  123. data/spec/cassettes/Tacokit_Client_Notifications/_notification_field/returns_a_value.json +1 -0
  124. data/spec/cassettes/Tacokit_Client_Notifications/_notification_resource/returns_action_entities.json +1 -0
  125. data/spec/cassettes/Tacokit_Client_Notifications/_notification_resource/returns_notification_board.json +1 -0
  126. data/spec/cassettes/Tacokit_Client_Notifications/_update_notification/updates_a_notification.json +1 -0
  127. data/spec/cassettes/Tacokit_Client_Organizations/_create_organization/creates_a_organization.json +1 -0
  128. data/spec/cassettes/Tacokit_Client_Organizations/_delete_organization/deletes_a_organization.json +1 -0
  129. data/spec/cassettes/Tacokit_Client_Organizations/_organization/returns_an_organization_by_id.json +1 -0
  130. data/spec/cassettes/Tacokit_Client_Organizations/_organization_field/returns_a_hash.json +1 -0
  131. data/spec/cassettes/Tacokit_Client_Organizations/_organization_field/returns_a_resource.json +1 -0
  132. data/spec/cassettes/Tacokit_Client_Organizations/_organization_field/returns_a_value.json +1 -0
  133. data/spec/cassettes/Tacokit_Client_Organizations/_organization_field/returns_an_array.json +1 -0
  134. data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_actions.json +1 -0
  135. data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_boards.json +1 -0
  136. data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_members.json +1 -0
  137. data/spec/cassettes/Tacokit_Client_Organizations/_update_organization/updates_a_organization.json +1 -0
  138. data/spec/cassettes/Tacokit_Client_Searches/_search/returns_search_result.json +1 -0
  139. data/spec/cassettes/Tacokit_Client_Tokens/_delete_token/deletes_a_token.json +1 -0
  140. data/spec/cassettes/Tacokit_Client_Tokens/_token/returns_a_token_for_token_string.json +1 -0
  141. data/spec/cassettes/Tacokit_Client_Tokens/_token_field/returns_a_value.json +1 -0
  142. data/spec/cassettes/Tacokit_Client_Tokens/_token_field/returns_an_array.json +1 -0
  143. data/spec/cassettes/Tacokit_Client_Tokens/_token_resource/returns_token_member.json +1 -0
  144. data/spec/cassettes/Tacokit_Client_Tokens/_token_resource/returns_token_webhooks.json +1 -0
  145. data/spec/cassettes/Tacokit_Client_Types/_type/returns_a_type_by_id.json +1 -0
  146. data/spec/cassettes/Tacokit_Client_Webhooks/_create_webhook/creates_a_webhook.json +1 -0
  147. data/spec/cassettes/Tacokit_Client_Webhooks/_delete_webhook/deletes_a_webhook.json +1 -0
  148. data/spec/cassettes/Tacokit_Client_Webhooks/_update_webhook/updates_a_webhook.json +1 -0
  149. data/spec/cassettes/Tacokit_Client_Webhooks/_webhook/returns_a_webhook_by_short_link.json +1 -0
  150. data/spec/cassettes/Tacokit_Client_Webhooks/_webhook_field/returns_a_value.json +1 -0
  151. data/spec/fixtures/taco.png +0 -0
  152. data/spec/spec_helper.rb +162 -0
  153. data/spec/tacokit/authorization_spec.rb +47 -0
  154. data/spec/tacokit/client/actions_spec.rb +100 -0
  155. data/spec/tacokit/client/boards_spec.rb +168 -0
  156. data/spec/tacokit/client/cards_spec.rb +192 -0
  157. data/spec/tacokit/client/checklists_spec.rb +87 -0
  158. data/spec/tacokit/client/labels_spec.rb +70 -0
  159. data/spec/tacokit/client/lists_spec.rb +81 -0
  160. data/spec/tacokit/client/members_spec.rb +114 -0
  161. data/spec/tacokit/client/notifications_spec.rb +52 -0
  162. data/spec/tacokit/client/organizations_spec.rb +100 -0
  163. data/spec/tacokit/client/searches_spec.rb +13 -0
  164. data/spec/tacokit/client/tokens_spec.rb +49 -0
  165. data/spec/tacokit/client/types_spec.rb +12 -0
  166. data/spec/tacokit/client/webhooks_spec.rb +70 -0
  167. data/spec/tacokit/client_spec.rb +28 -0
  168. data/spec/tacokit/configuration_spec.rb +51 -0
  169. data/spec/tacokit/middleware/boom_spec.rb +35 -0
  170. data/spec/tacokit/resource_spec.rb +26 -0
  171. data/spec/tacokit/transform_spec.rb +131 -0
  172. data/spec/tacokit_spec.rb +16 -0
  173. data/tacokit.gemspec +28 -0
  174. metadata +436 -0
@@ -0,0 +1,59 @@
1
+ module Tacokit
2
+ class Client
3
+ module Checklists
4
+
5
+ # GET /1/checklists/[idChecklist]
6
+ def checklist(checklist_id, options = nil)
7
+ get checklist_path(checklist_id), options
8
+ end
9
+
10
+ # GET /1/checklists/[idChecklist]/[field]
11
+ def checklist_field(checklist_id, field)
12
+ get checklist_path(checklist_id, camp(field))
13
+ end
14
+
15
+ # GET /1/checklists/[idChecklist]/[resource]
16
+ # board
17
+ # board/[field]
18
+ # checklists
19
+ # checklists/[filter]
20
+ # checkItems
21
+ # checkItems/[idCheckItem]
22
+ def checklist_resource(checklist_id, resource, *paths)
23
+ paths, options = extract_options(camp(resource), *paths)
24
+ get checklist_path(checklist_id, *paths), options
25
+ end
26
+
27
+ # PUT /1/checklists/[idChecklist]
28
+ def update_checklist(checklist_id, options = {})
29
+ put checklist_path(checklist_id), options
30
+ end
31
+
32
+ # PUT /1/checklists/[idChecklist]/[field]
33
+ # idCard
34
+ # name
35
+ # pos
36
+
37
+ # POST /1/checklists
38
+ def create_checklist(card_id, name, options = {})
39
+ options.update \
40
+ card_id: card_id,
41
+ name: name
42
+ post checklist_path, options
43
+ end
44
+
45
+ # POST /1/checklists/[idChecklist]/checkItems
46
+
47
+ # DELETE /1/checklists/[idChecklist]
48
+ def delete_checklist(checklist_id)
49
+ delete checklist_path(checklist_id)
50
+ end
51
+
52
+ # DELETE /1/checklists/[idChecklist]/checkItems/[idCheckItem]
53
+
54
+ def checklist_path(*paths)
55
+ path_join("checklists", *paths)
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,44 @@
1
+ module Tacokit
2
+ class Client
3
+ module Labels
4
+
5
+ # GET /1/labels/[idLabel]
6
+ def label(label_id, options = nil)
7
+ get label_path(label_id), options
8
+ end
9
+
10
+ # GET /1/labels/[idLabel]/[resource]
11
+ # board
12
+ # board/[field]
13
+ def label_resource(label_id, resource, *paths)
14
+ paths, options = extract_options(camp(resource), *paths)
15
+ get label_path(label_id, *paths), options
16
+ end
17
+
18
+ # PUT /1/labels/[idLabel]
19
+ def update_label(label_id, options = {})
20
+ put label_path(label_id), options
21
+ end
22
+
23
+ # PUT /1/labels/[idLabel]/color
24
+ # PUT /1/labels/[idLabel]/name
25
+
26
+ # POST /1/labels
27
+ def create_label(board_id, name, color)
28
+ post label_path,
29
+ board_id: board_id,
30
+ name: name,
31
+ color: color
32
+ end
33
+
34
+ # DELETE /1/labels/[idLabel]
35
+ def delete_label(label_id)
36
+ delete label_path(label_id)
37
+ end
38
+
39
+ def label_path(*paths)
40
+ path_join "labels", *paths
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,54 @@
1
+ module Tacokit
2
+ class Client
3
+ module Lists
4
+
5
+ # GET /1/lists/[idList]
6
+ def list(list_id, options = nil)
7
+ get list_path(list_id), options
8
+ end
9
+
10
+ # GET /1/lists/[idList]/[field]
11
+ def list_field(list_id, field, options = nil)
12
+ get list_path(list_id, camp(field)), options
13
+ end
14
+
15
+ # GET /1/lists/[idList]/[resource]
16
+ # actions
17
+ # board
18
+ # board/[field]
19
+ # lists
20
+ # lists/[filter]
21
+ def list_resource(list_id, resource, *paths)
22
+ paths, options = extract_options(camp(resource), *paths)
23
+ get list_path(list_id, *paths), options
24
+ end
25
+
26
+ # PUT /1/lists/[idList]
27
+ def update_list(list_id, options = {})
28
+ put list_path(list_id), options
29
+ end
30
+
31
+ # PUT /1/lists/[idList]/[field]
32
+ # closed
33
+ # idBoard
34
+ # name
35
+ # pos
36
+ # subscribed
37
+
38
+ # POST /1/lists
39
+ def create_list(board_id, name, options = {})
40
+ post list_path, options.merge(name: name, board_id: board_id)
41
+ end
42
+
43
+ # POST /1/lists/[idList]/[resource]
44
+ # archiveAllCards
45
+ # cards
46
+ # moveAllCards
47
+
48
+ def list_path(*paths)
49
+ path_join("lists", *paths)
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,91 @@
1
+ module Tacokit
2
+ class Client
3
+ module Members
4
+
5
+ # GET /1/members/[idMember or username]
6
+ def member(username = 'me', options = nil)
7
+ get member_path(username), options
8
+ end
9
+
10
+ # GET /1/members/[idMember or username]/[field]
11
+ def member_field(username, field, options = nil)
12
+ get member_path(username, camp(field)), options
13
+ end
14
+
15
+ # GET /1/members/[idMember or username]/[resource]
16
+ # actions
17
+ # boardBackgrounds
18
+ # boardBackgrounds/[idBoardBackground]
19
+ # boardStars
20
+ # boardStars/[idBoardStar]
21
+ # boards/[filter]
22
+ # boardsInvited
23
+ # boardsInvited/[field]
24
+ # cards
25
+ # cards/[filter]
26
+ # customBoardBackgrounds
27
+ # customBoardBackgrounds/[idBoardBackground]
28
+ # customEmoji
29
+ # customEmoji/[idCustomEmoji]
30
+ # customStickers
31
+ # customStickers/[idCustomSticker]
32
+ # deltas
33
+ # notifications
34
+ # notifications/[filter]
35
+ # organizations
36
+ # organizations/[filter]
37
+ # organizationsInvited
38
+ # organizationsInvited/[field]
39
+ # savedSearches
40
+ # savedSearches/[idSavedSearch]
41
+ # tokens
42
+ def member_resource(username, resource, *paths)
43
+ paths, options = extract_options(camp(resource), *paths)
44
+ get member_path(username, *paths), options
45
+ end
46
+
47
+ # POST /1/members/[idMember or username]/[resource]
48
+ # avatar
49
+ # boardBackgrounds
50
+ # boardStars
51
+ # customBoardBackgrounds
52
+ # customEmoji
53
+ # customStickers
54
+ # oneTimeMessagesDismissed
55
+ # savedSearches
56
+
57
+ # PUT /1/members/[idMember or username]
58
+ def update_member(username, options = {})
59
+ put member_path(username), options
60
+ end
61
+
62
+ # PUT /1/members/[idMember or username]/[field]
63
+ # avatarSource
64
+ # fullName
65
+ # initials
66
+ # username
67
+ # boardBackgrounds/[idBoardBackground]
68
+ # boardStars/[idBoardStar]
69
+ # boardStars/[idBoardStar]/idBoard
70
+ # boardStars/[idBoardStar]/pos
71
+ # customBoardBackgrounds/[idBoardBackground]
72
+ # prefs/colorBlind
73
+ # prefs/minutesBetweenSummaries
74
+ # savedSearches/[idSavedSearch]
75
+ # savedSearches/[idSavedSearch]/name
76
+ # savedSearches/[idSavedSearch]/pos
77
+ # savedSearches/[idSavedSearch]/query
78
+
79
+ # DELETE /1/members/[idMember or username]/[resource]/[resource_id]
80
+ # boardBackgrounds/[idBoardBackground]
81
+ # boardStars/[idBoardStar]
82
+ # customBoardBackgrounds/[idBoardBackground]
83
+ # customStickers/[idCustomSticker]
84
+ # savedSearches/[idSavedSearch]
85
+
86
+ def member_path(*paths)
87
+ path_join "members", *paths
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,48 @@
1
+ module Tacokit
2
+ class Client
3
+ module Notifications
4
+
5
+ # GET /1/notifications/[idNotification]
6
+ def notification(notification_id, options = nil)
7
+ get notification_path(notification_id), options
8
+ end
9
+
10
+ # GET /1/notifications/[idNotification]/[field]
11
+ def notification_field(notification_id, field)
12
+ get notification_path(notification_id, camp(field))
13
+ end
14
+
15
+ # GET /1/notifications/[idNotification]/[resource]
16
+ # board
17
+ # board/[field]
18
+ # notification
19
+ # notification/[field]
20
+ # entities
21
+ # list
22
+ # list/[field]
23
+ # member
24
+ # member/[field]
25
+ # memberCreator
26
+ # memberCreator/[field]
27
+ # organization
28
+ # organization/[field]
29
+ def notification_resource(notification_id, resource, *paths)
30
+ paths, options = extract_options(camp(resource), *paths)
31
+ get notification_path(notification_id, *paths), options
32
+ end
33
+
34
+ # PUT /1/notifications/[idNotification]
35
+ def update_notification(notification_id, options = {})
36
+ put notification_path(notification_id), options
37
+ end
38
+
39
+ # PUT /1/notifications/[idNotification]/unread
40
+
41
+ # POST /1/notifications/all/read
42
+
43
+ def notification_path(*paths)
44
+ path_join "notifications", *paths
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,79 @@
1
+ module Tacokit
2
+ class Client
3
+ module Organizations
4
+
5
+ # GET /1/organizations/[idOrg or name]
6
+ def organization(org_id, options = nil)
7
+ get organization_path(org_id), options
8
+ end
9
+
10
+ # GET /1/organizations/[idOrg or name]/[field]
11
+ def organization_field(org_id, field, options = nil)
12
+ get organization_path(org_id, camp(field)), options
13
+ end
14
+
15
+ # GET /1/organizations/[idOrg or name]/[resource]
16
+ # actions
17
+ # boards
18
+ # boards/[filter]
19
+ # deltas
20
+ # members
21
+ # members/[filter]
22
+ # members/[idMember]/cards
23
+ # membersInvited
24
+ # membersInvited/[field]
25
+ # memberships
26
+ # memberships/[idMembership]
27
+ def organization_resource(org_id, resource, *paths)
28
+ paths, options = extract_options(camp(resource), *paths)
29
+ get organization_path(org_id, *paths), options
30
+ end
31
+
32
+ # PUT /1/organizations/[idOrg or name]
33
+ def update_organization(org_id, options = {})
34
+ put organization_path(org_id), options
35
+ end
36
+
37
+ # PUT /1/organizations/[idOrg or name]/[field]
38
+ # desc
39
+ # displayName
40
+ # members
41
+ # members/[idMember]
42
+ # members/[idMember]/deactivated
43
+ # memberships/[idMembership]
44
+ # name
45
+ # prefs/associatedDomain
46
+ # prefs/boardVisibilityRestrict/org
47
+ # prefs/boardVisibilityRestrict/private
48
+ # prefs/boardVisibilityRestrict/public
49
+ # prefs/externalMembersDisabled
50
+ # prefs/googleAppsVersion
51
+ # prefs/orgInviteRestrict
52
+ # prefs/permissionLevel
53
+ # website
54
+
55
+ # POST /1/organizations
56
+ def create_organization(display_name, options = {})
57
+ post organization_path, options.merge(display_name: display_name)
58
+ end
59
+
60
+ # POST /1/organizations/[idOrg or name]/logo
61
+
62
+ # DELETE /1/organizations/[idOrg or name]
63
+ def delete_organization(org_id)
64
+ delete organization_path(org_id)
65
+ end
66
+
67
+ # DELETE /1/organizations/[idOrg or name]/[resource]
68
+ # logo
69
+ # members/[idMember]
70
+ # members/[idMember]/all
71
+ # prefs/associatedDomain
72
+ # prefs/orgInviteRestrict
73
+
74
+ def organization_path(*paths)
75
+ path_join "organizations", *paths
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,20 @@
1
+ module Tacokit
2
+ class Client
3
+ module Searches
4
+
5
+ # GET /1/search
6
+ def search(query, options = {})
7
+ get search_path, options.merge(query: query)
8
+ end
9
+
10
+ # GET /1/search/members
11
+ def search_members(query, options = {})
12
+ get search_path("members"), options.merge(query: query)
13
+ end
14
+
15
+ def search_path(*paths)
16
+ path_join "search", *paths
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,41 @@
1
+ module Tacokit
2
+ class Client
3
+ module Tokens
4
+
5
+ # GET /1/tokens/[token]
6
+ def token(token, options = nil)
7
+ get token_path(token), options
8
+ end
9
+
10
+ # GET /1/tokens/[token]/[field]
11
+ def token_field(token, field, options = nil)
12
+ get token_path(token, camp(field)), options
13
+ end
14
+
15
+ # GET /1/tokens/[token]/[resource]
16
+ # member
17
+ # webhooks
18
+ # member/[field]
19
+ # webhooks/[idWebhook]
20
+ def token_resource(token, resource, *paths)
21
+ paths, options = extract_options(camp(resource), *paths)
22
+ get token_path(token, *paths), options
23
+ end
24
+
25
+ # POST /1/tokens/[token]/webhooks
26
+
27
+ # PUT /1/tokens/[token]/webhooks
28
+
29
+ # DELETE /1/tokens/[token]
30
+ def delete_token(token)
31
+ delete token_path(token)
32
+ end
33
+
34
+ # DELETE /1/tokens/[token]/webhooks/[idWebhook]
35
+
36
+ def token_path(*paths)
37
+ path_join "tokens", *paths
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,11 @@
1
+ module Tacokit
2
+ class Client
3
+ module Types
4
+
5
+ # GET /1/types/[id]
6
+ def type(model_id)
7
+ get path_join "types", model_id
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,43 @@
1
+ module Tacokit
2
+ class Client
3
+ module Webhooks
4
+
5
+ # GET /1/webhooks/[idWebhook]
6
+ def webhook(webhook_id)
7
+ get webhook_path(webhook_id)
8
+ end
9
+
10
+ # GET /1/webhooks/[idWebhook]/[field]
11
+ def webhook_field(webhook_id, field, options = nil)
12
+ get webhook_path(webhook_id, camp(field)), options
13
+ end
14
+
15
+ # PUT /1/webhooks/[idWebhook]
16
+ def update_webhook(webhook_id, options = {})
17
+ put webhook_path(webhook_id), options
18
+ end
19
+
20
+ # PUT /1/webhooks/[idWebhook]/[field]
21
+ # active
22
+ # callbackURL
23
+ # description
24
+ # idModel
25
+
26
+ # POST /1/webhooks
27
+ def create_webhook(token, model_id, callback_url, options = {})
28
+ post webhook_path, options.merge(
29
+ model_id: model_id,
30
+ callback_url: callback_url)
31
+ end
32
+
33
+ # DELETE /1/webhooks/[idWebhook]
34
+ def delete_webhook(webhook_id)
35
+ delete webhook_path(webhook_id)
36
+ end
37
+
38
+ def webhook_path(*paths)
39
+ path_join "webhooks", *paths
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,169 @@
1
+ require 'forwardable'
2
+
3
+ require 'faraday'
4
+ require 'faraday_middleware'
5
+
6
+ require 'tacokit/authorization'
7
+ require 'tacokit/configuration'
8
+ require 'tacokit/middleware'
9
+ require 'tacokit/response'
10
+ require 'tacokit/transform'
11
+
12
+ require 'tacokit/client/actions'
13
+ require 'tacokit/client/boards'
14
+ require 'tacokit/client/cards'
15
+ require 'tacokit/client/checklists'
16
+ require 'tacokit/client/labels'
17
+ require 'tacokit/client/lists'
18
+ require 'tacokit/client/members'
19
+ require 'tacokit/client/notifications'
20
+ require 'tacokit/client/organizations'
21
+ require 'tacokit/client/searches'
22
+ require 'tacokit/client/tokens'
23
+ require 'tacokit/client/types'
24
+ require 'tacokit/client/webhooks'
25
+
26
+ module Tacokit
27
+ class Client
28
+ extend Forwardable
29
+
30
+ include Tacokit::Authorization
31
+ include Tacokit::Utils
32
+
33
+ include Tacokit::Client::Actions
34
+ include Tacokit::Client::Boards
35
+ include Tacokit::Client::Cards
36
+ include Tacokit::Client::Checklists
37
+ include Tacokit::Client::Labels
38
+ include Tacokit::Client::Lists
39
+ include Tacokit::Client::Members
40
+ include Tacokit::Client::Notifications
41
+ include Tacokit::Client::Organizations
42
+ include Tacokit::Client::Searches
43
+ include Tacokit::Client::Tokens
44
+ include Tacokit::Client::Types
45
+ include Tacokit::Client::Webhooks
46
+
47
+ def_delegators :configuration, *Configuration.keys
48
+ def_delegators :configuration, :user_authenticated?, :user_credentials
49
+ def_delegators :configuration, :app_authenticated?, :app_credentials
50
+ def_delegators :transform, :serialize, :deserialize
51
+
52
+ def initialize(options = {})
53
+ self.configuration.options = options
54
+ end
55
+
56
+ def reset!
57
+ @configuration = nil
58
+ end
59
+
60
+ def configure
61
+ yield configuration if block_given?
62
+ end
63
+
64
+ def configuration
65
+ @configuration ||= Configuration.new
66
+ end
67
+
68
+ def get(url, options = {})
69
+ request :get, url, options
70
+ end
71
+
72
+ def post(url, options = {})
73
+ request :post, url, options
74
+ end
75
+
76
+ def put(url, options = {})
77
+ request :put, url, options
78
+ end
79
+
80
+ def delete(url, options = {})
81
+ request :delete, url, options
82
+ end
83
+
84
+ def request(method, url, data = nil, params = nil)
85
+ if [:get, :body].include?(method)
86
+ params ||= data
87
+ data = nil
88
+ end
89
+
90
+ params = normalize_request_params(params || {})
91
+ response = connection.send method, url do |req|
92
+ req.params.update params
93
+ req.body = serialize(data) if data
94
+ end
95
+
96
+ Response.new(self, response).data
97
+ end
98
+
99
+ def transform
100
+ @transform ||= Transform.new
101
+ end
102
+
103
+ # Prepare ruby-style params for trello request
104
+ def normalize_request_params(params)
105
+ {}.tap do |norm|
106
+ params.each do |key,value|
107
+ norm[key] = normalize_param_value(value)
108
+ end
109
+ end
110
+ end
111
+
112
+ def normalize_param_value(value)
113
+ case value
114
+ when Array
115
+ value.map { |v| camp(v) }.join(',')
116
+ when /\,/
117
+ normalize_param_value(value.split(','))
118
+ else
119
+ camp(value)
120
+ end
121
+ end
122
+
123
+ def path_join(*paths)
124
+ paths.join('/')
125
+ end
126
+
127
+ def to_path(*paths)
128
+ warn "to_path is deprecated"
129
+ path_join(*paths)
130
+ end
131
+
132
+ def camel_path(path)
133
+ camelize(path.to_s, :lower)
134
+ end
135
+ alias camp camel_path
136
+
137
+ def camel_join(*paths)
138
+ path_join paths.map { |p| camel_path(p) }
139
+ end
140
+
141
+ def to_s
142
+ "<#{self.class}:#{object_id}>"
143
+ end
144
+ alias_method :inspect, :to_s
145
+
146
+ def connection
147
+ @connection = Faraday.new(url: api_endpoint) do |http|
148
+ http.headers[:user_agent] = 'TacoKit 0.0.1'
149
+
150
+ if user_authenticated?
151
+ http.request :oauth, user_credentials
152
+ else app_authenticated?
153
+ http.params.update app_credentials
154
+ end
155
+
156
+ http.request :json
157
+ http.request :multipart
158
+ http.request :url_encoded
159
+
160
+ http.response :json, content_type: /\bjson$/
161
+ http.response :boom
162
+ http.response :logger if ENV['DEBUG']
163
+
164
+ http.adapter Faraday.default_adapter
165
+ end
166
+ end
167
+
168
+ end
169
+ end