3llo 0.3.1 → 1.0.0.pre.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +29 -0
- data/3llo.gemspec +4 -4
- data/CHANGELOG.md +11 -0
- data/{LICENSE.md → LICENSE} +1 -1
- data/README.md +118 -39
- data/bin/3llo +2 -38
- data/lib/3llo.rb +7 -4
- data/lib/3llo/api.rb +2 -0
- data/lib/3llo/api/board.rb +23 -16
- data/lib/3llo/api/card.rb +96 -53
- data/lib/3llo/api/checklist.rb +128 -0
- data/lib/3llo/api/list.rb +16 -13
- data/lib/3llo/api/token.rb +27 -0
- data/lib/3llo/api/user.rb +22 -13
- data/lib/3llo/application.rb +178 -0
- data/lib/3llo/command.rb +47 -0
- data/lib/3llo/{commands → command}/.gitkeep +0 -0
- data/lib/3llo/command/board.rb +42 -0
- data/lib/3llo/command/board/invalid.rb +18 -0
- data/lib/3llo/command/board/list.rb +18 -0
- data/lib/3llo/command/board/select.rb +29 -0
- data/lib/3llo/command/card.rb +151 -0
- data/lib/3llo/command/card/add.rb +33 -0
- data/lib/3llo/command/card/add_checklist.rb +22 -0
- data/lib/3llo/command/card/add_item.rb +22 -0
- data/lib/3llo/command/card/archive.rb +37 -0
- data/lib/3llo/command/card/assign.rb +56 -0
- data/lib/3llo/command/card/check_item.rb +22 -0
- data/lib/3llo/command/card/comment.rb +30 -0
- data/lib/3llo/command/card/comments.rb +28 -0
- data/lib/3llo/command/card/edit_checklist.rb +24 -0
- data/lib/3llo/command/card/edit_item.rb +26 -0
- data/lib/3llo/command/card/invalid.rb +18 -0
- data/lib/3llo/command/card/list.rb +40 -0
- data/lib/3llo/command/card/list_mine.rb +19 -0
- data/lib/3llo/command/card/move.rb +46 -0
- data/lib/3llo/command/card/remove_checklist.rb +20 -0
- data/lib/3llo/command/card/remove_item.rb +21 -0
- data/lib/3llo/command/card/self_assign.rb +35 -0
- data/lib/3llo/command/card/show.rb +37 -0
- data/lib/3llo/command/card/uncheck_item.rb +22 -0
- data/lib/3llo/command/exit.rb +17 -0
- data/lib/3llo/command/help.rb +15 -0
- data/lib/3llo/command/invalid.rb +15 -0
- data/lib/3llo/command/list.rb +50 -0
- data/lib/3llo/command/list/archive_cards.rb +33 -0
- data/lib/3llo/command/list/cards.rb +34 -0
- data/lib/3llo/command/list/invalid.rb +18 -0
- data/lib/3llo/command/list/list.rb +18 -0
- data/lib/3llo/controller.rb +21 -19
- data/lib/3llo/entities.rb +43 -0
- data/lib/3llo/errors.rb +5 -1
- data/lib/3llo/http/client.rb +20 -0
- data/lib/3llo/interface.rb +6 -0
- data/lib/3llo/registry.rb +43 -0
- data/lib/3llo/utils.rb +59 -0
- data/lib/3llo/version.rb +1 -1
- data/lib/3llo/view.rb +11 -0
- data/lib/3llo/{presenter → view}/.gitkeep +0 -0
- data/lib/3llo/view/board/help.rb +18 -0
- data/lib/3llo/view/board/list.rb +21 -0
- data/lib/3llo/view/card/comments.rb +32 -0
- data/lib/3llo/view/card/help.rb +37 -0
- data/lib/3llo/view/card/list.rb +57 -0
- data/lib/3llo/view/card/list_mine.rb +25 -0
- data/lib/3llo/view/card/show.rb +78 -0
- data/lib/3llo/view/help.rb +31 -0
- data/lib/3llo/view/list/cards.rb +34 -0
- data/lib/3llo/view/list/help.rb +19 -0
- data/lib/3llo/view/list/list.rb +21 -0
- metadata +65 -55
- data/.travis.yml +0 -22
- data/CODE_OF_CONDUCT.md +0 -49
- data/lib/3llo/board_command_factory.rb +0 -27
- data/lib/3llo/card_command_factory.rb +0 -70
- data/lib/3llo/command_factory.rb +0 -40
- data/lib/3llo/commands/board/invalid.rb +0 -33
- data/lib/3llo/commands/board/list.rb +0 -29
- data/lib/3llo/commands/board/select.rb +0 -38
- data/lib/3llo/commands/card/add.rb +0 -47
- data/lib/3llo/commands/card/archive.rb +0 -31
- data/lib/3llo/commands/card/assign.rb +0 -45
- data/lib/3llo/commands/card/comment.rb +0 -34
- data/lib/3llo/commands/card/comments.rb +0 -29
- data/lib/3llo/commands/card/invalid.rb +0 -41
- data/lib/3llo/commands/card/list.rb +0 -37
- data/lib/3llo/commands/card/list_mine.rb +0 -30
- data/lib/3llo/commands/card/move.rb +0 -42
- data/lib/3llo/commands/card/self_assign.rb +0 -33
- data/lib/3llo/commands/card/show.rb +0 -29
- data/lib/3llo/commands/error.rb +0 -18
- data/lib/3llo/commands/exit.rb +0 -16
- data/lib/3llo/commands/help.rb +0 -15
- data/lib/3llo/commands/invalid.rb +0 -18
- data/lib/3llo/commands/list/archive_cards.rb +0 -39
- data/lib/3llo/commands/list/cards.rb +0 -29
- data/lib/3llo/commands/list/invalid.rb +0 -34
- data/lib/3llo/commands/list/list.rb +0 -29
- data/lib/3llo/list_command_factory.rb +0 -33
- data/lib/3llo/presenter.rb +0 -11
- data/lib/3llo/presenter/board/list.rb +0 -25
- data/lib/3llo/presenter/card/assign.rb +0 -24
- data/lib/3llo/presenter/card/comments.rb +0 -33
- data/lib/3llo/presenter/card/list.rb +0 -53
- data/lib/3llo/presenter/card/list_mine.rb +0 -25
- data/lib/3llo/presenter/card/move.rb +0 -26
- data/lib/3llo/presenter/card/show.rb +0 -54
- data/lib/3llo/presenter/confirmation.rb +0 -18
- data/lib/3llo/presenter/help.rb +0 -55
- data/lib/3llo/presenter/list/cards.rb +0 -45
- data/lib/3llo/presenter/list/list.rb +0 -25
- data/lib/core_ext.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c80cabc5ec119676b74fbcc4bc8690d1a2bf55b2f53358f8069e788e36e4049
|
4
|
+
data.tar.gz: a1690b3ce4cbdb9ded4421f168037f458064769c802def01d21faf1e7f0bbab1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4aae96a782fda12b5f87ada27e76a173e04f6dc707f46a45779e2b3c9440833c90e9ab099e35717ad49d55132664f94207f1e9b26c68df1371c7dafd539a70b
|
7
|
+
data.tar.gz: 1d0a9482ace979945ff7f8f25ec6b92cb07e8d1733c9b9a97624aeeeaa319ad29e73eda694c5618a1ef2efe665d51d1be4923e20efea98f03e724d355b403ce9
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby_version: ['2.5.x', '2.6.x']
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v1
|
20
|
+
- name: Set up Ruby ${{ matrix.ruby_version }}
|
21
|
+
uses: actions/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby_version }}
|
24
|
+
- name: Install dependencies
|
25
|
+
run: |
|
26
|
+
gem install bundler
|
27
|
+
bundle install --jobs 4 --retry 3
|
28
|
+
- name: Run test
|
29
|
+
run: bundle exec rspec
|
data/3llo.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Cẩm Huỳnh"]
|
10
10
|
spec.email = ["huynhquancam@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{Trello CLI}
|
13
|
-
spec.description = %q{CLI for Trello}
|
12
|
+
spec.summary = %q{Trello CLI app}
|
13
|
+
spec.description = %q{Interactive CLI application for Trello}
|
14
14
|
spec.homepage = "https://github.com/qcam/3llo"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
@@ -25,9 +25,9 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^bin/}) { |filename| File.basename(filename) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
|
28
|
-
spec.required_ruby_version = '~> 2.
|
28
|
+
spec.required_ruby_version = '~> 2.5'
|
29
29
|
|
30
|
-
spec.add_runtime_dependency 'tty-prompt', '~> 0.
|
30
|
+
spec.add_runtime_dependency 'tty-prompt', '~> 0.20'
|
31
31
|
|
32
32
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
33
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v1.0.0
|
4
|
+
|
5
|
+
* Support using shortcuts to access entities.
|
6
|
+
* Introduce `--config` switch.
|
7
|
+
* Introduce `--init` switch.
|
8
|
+
* Introduce `--configure` switch.
|
9
|
+
* Deprecate using environment variables for configuration.
|
10
|
+
* Improve performance of several commands.
|
11
|
+
* Support checklist related commands.
|
12
|
+
* Support Ruby 2.5+.
|
13
|
+
|
3
14
|
## v0.3.1
|
4
15
|
|
5
16
|
* Improve self-documentation [#39](https://github.com/qcam/3llo/pull/39).
|
data/{LICENSE.md → LICENSE}
RENAMED
data/README.md
CHANGED
@@ -1,67 +1,146 @@
|
|
1
|
-
|
1
|
+
3llo - The interactive CLI application for Trello
|
2
|
+
================
|
2
3
|
|
3
|
-
3llo
|
4
|
-
leaving your awesome terminal.
|
4
|
+
3llo allows you to work with Trello without exiting your favorite terminal.
|
5
5
|
|
6
|
-
|
6
|
+
![video](intro.gif)
|
7
7
|
|
8
8
|
3llo was inspired by the awesome
|
9
9
|
[rainbowstream](https://github.com/DTVD/rainbowstream) and
|
10
10
|
[facy](https://github.com/huydx/facy).
|
11
11
|
|
12
|
-
## Why this named 3llo?
|
13
|
-
|
14
|
-
Good to know that `3 == "tre"` in Swedish.
|
15
|
-
|
16
12
|
## Installation
|
17
13
|
|
18
14
|
```ruby
|
19
15
|
gem install 3llo
|
20
16
|
```
|
21
17
|
|
22
|
-
|
18
|
+
Run `3llo --configure` and follow the instructions to complete the set up.
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
### "board" command family
|
23
|
+
|
24
|
+
Just like the web version of Trello, you need to select a board:
|
23
25
|
|
24
26
|
```
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
3llo > board list
|
28
|
+
|
29
|
+
[123abc000000000000000001 #1] - Weekend TODOs
|
30
|
+
[123abc000000000000000002 #2] - 3llo project
|
31
|
+
[123abc000000000000000003 #3] - Grocery list
|
32
|
+
|
33
|
+
3llo > board select #2
|
34
|
+
|
35
|
+
Board Work stuff selected
|
28
36
|
```
|
29
37
|
|
30
|
-
|
38
|
+
Please note that you can also access any entities with their Trello ID.
|
39
|
+
|
40
|
+
```
|
41
|
+
3llo > board select 123abc000000000000000002
|
31
42
|
|
32
|
-
|
33
|
-
|
34
|
-
1. Copy the `Key` that's displayed at the top of the page and set this as an environment variable (`TRELLO_KEY`).
|
35
|
-
1. Further down the page, follow the `Manually generate a token` link to generate a new API Token. Again, set this as an environment variable (`TRELLO_TOKEN`)
|
43
|
+
Board Work stuff selected
|
44
|
+
```
|
36
45
|
|
37
|
-
|
46
|
+
### "list" command family
|
47
|
+
|
48
|
+
Executing `list list` will list all the lists in the board.
|
49
|
+
|
50
|
+
```
|
51
|
+
3llo > list list
|
52
|
+
|
53
|
+
[123abc000000000000000001 #1] To Do
|
54
|
+
[123abc000000000000000002 #2] Doing
|
55
|
+
[123abc000000000000000003 #3] Pending
|
56
|
+
[123abc000000000000000004 #4] Done
|
57
|
+
```
|
58
|
+
|
59
|
+
`list cards <list_key>` will list all the cards.
|
60
|
+
|
61
|
+
```
|
62
|
+
3llo > list cards #1
|
63
|
+
|
64
|
+
[123abc000000000000000001 #1] Merge card editing command
|
65
|
+
[123abc000000000000000002 #2] Refactor code
|
66
|
+
...
|
67
|
+
```
|
68
|
+
|
69
|
+
### "card" command family
|
70
|
+
|
71
|
+
"card" command family comes with many commands to work with cards.
|
72
|
+
|
73
|
+
To list all the cards in the board, run `card list`.
|
38
74
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
75
|
+
```
|
76
|
+
3llo > card list
|
77
|
+
|
78
|
+
#To Do
|
79
|
+
======
|
80
|
+
[123abc000000000000000001 #1] Merge card editing command [#small]
|
81
|
+
[123abc000000000000000002 #2] Refactor code [#medium] [@qcam]
|
82
|
+
|
83
|
+
|
84
|
+
#Doing
|
85
|
+
======
|
86
|
+
[123abc000000000000000003 #3] Release v1.0 [#release] [@qcam]
|
87
|
+
|
88
|
+
#Pending
|
89
|
+
...
|
90
|
+
```
|
91
|
+
|
92
|
+
You can also list cards that have been assigned to you with `card list mine`.
|
93
|
+
|
94
|
+
```
|
95
|
+
3llo > card list mine
|
96
|
+
|
97
|
+
[123abc000000000000000002 #2] (To Do) Refactor code
|
98
|
+
[123abc000000000000000003 #3] (Doing) Release v1.0
|
99
|
+
```
|
100
|
+
|
101
|
+
To view a card in detail, `card show <card_key>` is your friend.
|
102
|
+
|
103
|
+
```
|
104
|
+
3llo > card show #2
|
105
|
+
|
106
|
+
Refactor code
|
107
|
+
[123abc000000000000000002 #2]
|
108
|
+
Link: https://trello.com/c/AbCdEfG
|
109
|
+
|
110
|
+
Things to do [123abc000000000000000001 #1]
|
111
|
+
[ ] Item 1 [123abc000000000000000001 #1]
|
112
|
+
[ ] Item 2 [123abc000000000000000002 #2]
|
113
|
+
[ ] Item 3 [123abc000000000000000003 #3]
|
114
|
+
[ ] Item 4 ...
|
115
|
+
```
|
116
|
+
|
117
|
+
Want to comment on a card? Run `card comment <card_key>`.
|
118
|
+
|
119
|
+
```
|
120
|
+
3llo > card comment #2
|
121
|
+
|
122
|
+
Comment: (Press CTRL-D or CTRL-Z to finish)
|
123
|
+
What else should we refactor more?<enter>
|
124
|
+
|
125
|
+
Comment has been posted
|
126
|
+
|
127
|
+
3llo > card comments #2
|
128
|
+
|
129
|
+
@just_another_person_on_the_internet on <Jan 01, 2020 00:55:55> wrote:
|
130
|
+
This card is awesome!
|
131
|
+
|
132
|
+
@qcam on <Jan 01, 2020 00:55:55> wrote:
|
133
|
+
What else should we refactor more?
|
134
|
+
```
|
56
135
|
|
57
136
|
## Contributing
|
58
137
|
|
59
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/qcam/3llo.
|
138
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/qcam/3llo.
|
60
139
|
|
61
|
-
###
|
140
|
+
### "3llo" sounds odd to me. Where did the name come from?
|
62
141
|
|
63
|
-
|
142
|
+
It might be interesting to know that `3 == "tre"` in Swedish 🇸🇪.
|
64
143
|
|
65
144
|
## License
|
66
145
|
|
67
|
-
|
146
|
+
MIT
|
data/bin/3llo
CHANGED
@@ -4,42 +4,6 @@ $:.unshift File.expand_path("../../lib", __FILE__)
|
|
4
4
|
require "3llo"
|
5
5
|
require 'container'
|
6
6
|
require 'tty-prompt'
|
7
|
+
require 'optparse'
|
7
8
|
|
8
|
-
|
9
|
-
$container.register(:api_client, Tr3llo::HTTP::Client)
|
10
|
-
prompt = TTY::Prompt.new
|
11
|
-
$container.register(:interface, Tr3llo::Interface.new(prompt, $stdout))
|
12
|
-
|
13
|
-
def print_help(stripped = false)
|
14
|
-
Tr3llo::Presenter::HelpPresenter
|
15
|
-
.new($container.resolve(:interface), stripped)
|
16
|
-
.print!
|
17
|
-
end
|
18
|
-
|
19
|
-
if ARGV.size == 1 && (ARGV[0] == "-h" || ARGV[0] == "--help")
|
20
|
-
print_help(true)
|
21
|
-
exit
|
22
|
-
end
|
23
|
-
|
24
|
-
configuration = Tr3llo::Configuration.new
|
25
|
-
begin
|
26
|
-
configuration.user_id = ENV.fetch('TRELLO_USER') { raise "Have you set TRELLO_USER?" }
|
27
|
-
configuration.api_key = ENV.fetch('TRELLO_KEY') { raise "Have you set TRELLO_KEY?" }
|
28
|
-
configuration.api_token = ENV.fetch('TRELLO_TOKEN') { raise "Have you set TRELLO_TOKEN?" }
|
29
|
-
rescue => error
|
30
|
-
abort "Invalid configuration: \e[1m#{error.message}".colorize(31)
|
31
|
-
end
|
32
|
-
|
33
|
-
configuration.finalize!
|
34
|
-
|
35
|
-
$container.register(
|
36
|
-
:configuration,
|
37
|
-
configuration
|
38
|
-
)
|
39
|
-
|
40
|
-
user = Tr3llo::API::User.find($container.resolve(:configuration).user_id)
|
41
|
-
$container.register(:user, user)
|
42
|
-
|
43
|
-
print_help(false)
|
44
|
-
|
45
|
-
Tr3llo::Controller.new.start
|
9
|
+
Tr3llo::Application.start(ARGV)
|
data/lib/3llo.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
|
-
require "core_ext"
|
2
1
|
require "3llo/version"
|
3
2
|
require "3llo/http/client"
|
4
|
-
require "3llo/presenter"
|
5
3
|
require "3llo/interface"
|
6
4
|
require 'container'
|
7
5
|
require 'json'
|
6
|
+
require 'erb'
|
8
7
|
|
8
|
+
require '3llo/application'
|
9
9
|
require '3llo/configuration'
|
10
|
+
require '3llo/utils'
|
10
11
|
require '3llo/controller'
|
11
12
|
require '3llo/errors'
|
12
13
|
require '3llo/api'
|
13
|
-
require '3llo/
|
14
|
-
require '3llo/
|
14
|
+
require '3llo/view'
|
15
|
+
require '3llo/command'
|
16
|
+
require '3llo/registry'
|
17
|
+
require '3llo/entities'
|
data/lib/3llo/api.rb
CHANGED
data/lib/3llo/api/board.rb
CHANGED
@@ -9,38 +9,45 @@ module Tr3llo
|
|
9
9
|
"/members/#{user_id}/boards",
|
10
10
|
key: api_key,
|
11
11
|
token: api_token,
|
12
|
-
|
13
|
-
|
14
|
-
)
|
12
|
+
filter: "open"
|
13
|
+
)
|
14
|
+
).map do |board_payload|
|
15
|
+
make_struct(board_payload)
|
16
|
+
end
|
15
17
|
end
|
16
18
|
|
17
19
|
def find(board_id)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
payload =
|
21
|
+
JSON.parse(
|
22
|
+
client.get(
|
23
|
+
"/boards/#{board_id}",
|
24
|
+
key: api_key,
|
25
|
+
token: api_token,
|
26
|
+
)
|
27
|
+
)
|
28
|
+
|
29
|
+
make_struct(payload)
|
26
30
|
end
|
27
31
|
|
28
32
|
private
|
29
33
|
|
30
34
|
def client
|
31
|
-
|
35
|
+
Application.fetch_client!()
|
32
36
|
end
|
33
37
|
|
34
38
|
def api_key
|
35
|
-
|
39
|
+
Application.fetch_configuration!().api_key
|
36
40
|
end
|
37
41
|
|
38
42
|
def api_token
|
39
|
-
|
43
|
+
Application.fetch_configuration!().api_token
|
40
44
|
end
|
41
45
|
|
42
|
-
def
|
43
|
-
|
46
|
+
def make_struct(payload)
|
47
|
+
id, name = payload.fetch_values("id", "name")
|
48
|
+
shortcut = Entities.make_shortcut(:board, id)
|
49
|
+
|
50
|
+
Entities::Board.new(id, shortcut, name)
|
44
51
|
end
|
45
52
|
end
|
46
53
|
end
|
data/lib/3llo/api/card.rb
CHANGED
@@ -3,17 +3,6 @@ module Tr3llo
|
|
3
3
|
module Card
|
4
4
|
extend self
|
5
5
|
|
6
|
-
def find_all_by_board(board_id)
|
7
|
-
JSON.parse(
|
8
|
-
client.get(
|
9
|
-
"/boards/#{board_id}/cards",
|
10
|
-
key: api_key,
|
11
|
-
token: api_token,
|
12
|
-
),
|
13
|
-
symbolize_names: true
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
6
|
def find_all_by_list(list_id)
|
18
7
|
JSON.parse(
|
19
8
|
client.get(
|
@@ -22,9 +11,10 @@ module Tr3llo
|
|
22
11
|
token: api_token,
|
23
12
|
members: 'true',
|
24
13
|
member_fields: "id,username"
|
25
|
-
)
|
26
|
-
|
27
|
-
|
14
|
+
)
|
15
|
+
).map do |card_payload|
|
16
|
+
make_struct(card_payload)
|
17
|
+
end
|
28
18
|
end
|
29
19
|
|
30
20
|
def find_all_by_user(board_id, user_id)
|
@@ -33,37 +23,37 @@ module Tr3llo
|
|
33
23
|
"/boards/#{board_id}/members/#{user_id}/cards",
|
34
24
|
list: true,
|
35
25
|
key: api_key,
|
36
|
-
token: api_token
|
37
|
-
)
|
38
|
-
|
39
|
-
|
26
|
+
token: api_token
|
27
|
+
)
|
28
|
+
).map do |card_payload|
|
29
|
+
make_struct(card_payload)
|
30
|
+
end
|
40
31
|
end
|
41
32
|
|
42
33
|
def create(name, description, list_id)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
idList: list_id
|
51
|
-
),
|
52
|
-
symbolize_names: true
|
34
|
+
client.post(
|
35
|
+
"/cards",
|
36
|
+
key: api_key,
|
37
|
+
token: api_token,
|
38
|
+
name: name,
|
39
|
+
desc: description,
|
40
|
+
idList: list_id
|
53
41
|
)
|
54
42
|
end
|
55
43
|
|
56
44
|
def find(card_id)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
45
|
+
card_payload =
|
46
|
+
JSON.parse(
|
47
|
+
client.get(
|
48
|
+
"/cards/#{card_id}",
|
49
|
+
list: true,
|
50
|
+
members: true,
|
51
|
+
key: api_key,
|
52
|
+
token: api_token
|
53
|
+
)
|
54
|
+
)
|
55
|
+
|
56
|
+
make_struct(card_payload)
|
67
57
|
end
|
68
58
|
|
69
59
|
def move_to_list(card_id, list_id)
|
@@ -74,8 +64,7 @@ module Tr3llo
|
|
74
64
|
key: api_key,
|
75
65
|
token: api_token,
|
76
66
|
value: list_id
|
77
|
-
)
|
78
|
-
symbolize_names: true
|
67
|
+
)
|
79
68
|
)
|
80
69
|
end
|
81
70
|
|
@@ -87,22 +76,36 @@ module Tr3llo
|
|
87
76
|
key: api_key,
|
88
77
|
token: api_token,
|
89
78
|
value: members.join(',')
|
90
|
-
)
|
91
|
-
symbolize_names: true
|
79
|
+
)
|
92
80
|
)
|
93
81
|
end
|
94
82
|
|
95
|
-
def
|
83
|
+
def list_comments(card_id)
|
96
84
|
url = "/cards/#{card_id}/actions"
|
85
|
+
|
97
86
|
JSON.parse(
|
98
87
|
client.get(
|
99
88
|
url,
|
100
89
|
key: api_key,
|
101
90
|
token: api_token,
|
102
91
|
filter: "commentCard",
|
103
|
-
)
|
104
|
-
|
105
|
-
|
92
|
+
)
|
93
|
+
).map do |comment_payload|
|
94
|
+
id, creator_payload, date = comment_payload.fetch_values("id", "memberCreator", "date")
|
95
|
+
text = comment_payload.dig("data", "text")
|
96
|
+
|
97
|
+
created_at = DateTime.iso8601(date)
|
98
|
+
|
99
|
+
creator_id, creator_username = creator_payload.fetch_values("id", "username")
|
100
|
+
creator = Entities::User.new(creator_id, _creator_shortcut = nil, creator_username)
|
101
|
+
|
102
|
+
Entities::Comment.new(
|
103
|
+
id: id,
|
104
|
+
creator: creator,
|
105
|
+
created_at: created_at,
|
106
|
+
text: text
|
107
|
+
)
|
108
|
+
end
|
106
109
|
end
|
107
110
|
|
108
111
|
def comment(card_id, text)
|
@@ -113,8 +116,7 @@ module Tr3llo
|
|
113
116
|
key: api_key,
|
114
117
|
token: api_token,
|
115
118
|
text: text
|
116
|
-
)
|
117
|
-
symbolize_names: true
|
119
|
+
)
|
118
120
|
)
|
119
121
|
end
|
120
122
|
|
@@ -125,23 +127,64 @@ module Tr3llo
|
|
125
127
|
url,
|
126
128
|
key: api_key,
|
127
129
|
token: api_token
|
128
|
-
)
|
129
|
-
symbolize_names: true
|
130
|
+
)
|
130
131
|
)
|
131
132
|
end
|
132
133
|
|
133
134
|
private
|
134
135
|
|
136
|
+
def make_struct(payload)
|
137
|
+
id, name, description, short_url = payload.fetch_values("id", "name", "desc", "shortUrl")
|
138
|
+
shortcut = Entities.make_shortcut(:card, id)
|
139
|
+
|
140
|
+
members =
|
141
|
+
payload
|
142
|
+
.fetch("members", [])
|
143
|
+
.map do |member_payload|
|
144
|
+
user_id, username = member_payload.fetch_values("id", "username")
|
145
|
+
|
146
|
+
Entities::User.new(user_id, _user_shortcut = nil, username)
|
147
|
+
end
|
148
|
+
|
149
|
+
labels =
|
150
|
+
payload
|
151
|
+
.fetch("labels", [])
|
152
|
+
.map do |label_payload|
|
153
|
+
label_name = label_payload.fetch("name")
|
154
|
+
label_color = label_payload["color"]
|
155
|
+
|
156
|
+
Entities::Label.new(label_name, label_color)
|
157
|
+
end
|
158
|
+
|
159
|
+
card =
|
160
|
+
Entities::Card.new(
|
161
|
+
id: id,
|
162
|
+
shortcut: shortcut,
|
163
|
+
name: name,
|
164
|
+
description: description,
|
165
|
+
short_url: short_url,
|
166
|
+
labels: labels,
|
167
|
+
members: members
|
168
|
+
)
|
169
|
+
|
170
|
+
if list_payload = payload["list"]
|
171
|
+
list_id, list_name = list_payload.fetch_values("id", "name")
|
172
|
+
card.list = Entities::List.new(list_id, _list_shortcut = nil, list_name)
|
173
|
+
end
|
174
|
+
|
175
|
+
card
|
176
|
+
end
|
177
|
+
|
135
178
|
def api_key
|
136
|
-
|
179
|
+
Application.fetch_configuration!().api_key
|
137
180
|
end
|
138
181
|
|
139
182
|
def api_token
|
140
|
-
|
183
|
+
Application.fetch_configuration!().api_token
|
141
184
|
end
|
142
185
|
|
143
186
|
def client
|
144
|
-
|
187
|
+
Application.fetch_client!()
|
145
188
|
end
|
146
189
|
end
|
147
190
|
end
|