click_up-client 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +270 -5
- data/Gemfile +5 -2
- data/README.md +23 -2
- data/bin/console +8 -5
- data/click_up-client.gemspec +7 -0
- data/lib/click_up/client.rb +15 -2
- data/lib/click_up/client/http_client.rb +35 -0
- data/lib/click_up/client/version.rb +1 -1
- data/lib/click_up/tasks/factory.rb +16 -0
- data/lib/click_up/tasks/service.rb +66 -0
- data/lib/click_up/tasks/task.rb +47 -0
- data/lib/click_up/types/base.rb +11 -0
- metadata +105 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 740dac61b9ae56c7da7fb7f40b65031014c8405f6000c818b2df31908cea38d4
|
|
4
|
+
data.tar.gz: 504a6e2d30bf97bd39efc9185b04c0d30f33ab89d9314322e902da075d0b0597
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cc1a745db0edb0ec54830ecca4db2b00f0c7fe4e2f86dbaf29fa1725cf53f1c5b30fc64928652d0eaec6ee1691c452acb86aeb77b28fc11351e3025f0259e6cf
|
|
7
|
+
data.tar.gz: 3db7285faf6d987cc4348209c1f0089988ec9ee1e87f14c66b0dc9b5f887875ab9124e721a1547d2ad6e2af82b7458cd80f586ae47dd9ba6f753fb38c052064c
|
data/.rubocop.yml
CHANGED
|
@@ -1,10 +1,275 @@
|
|
|
1
|
-
|
|
1
|
+
require:
|
|
2
|
+
- rubocop-performance
|
|
3
|
+
- rubocop-rake
|
|
4
|
+
- rubocop-rspec
|
|
5
|
+
|
|
6
|
+
# Basic
|
|
7
|
+
AllCops:
|
|
8
|
+
DisplayStyleGuide: true
|
|
9
|
+
|
|
10
|
+
DisabledByDefault: true
|
|
11
|
+
NewCops: enable
|
|
12
|
+
|
|
13
|
+
Exclude:
|
|
14
|
+
- ".git/**/*"
|
|
15
|
+
- "tmp/**/*"
|
|
16
|
+
- "vendor/**/*"
|
|
17
|
+
|
|
18
|
+
TargetRubyVersion: 3.0
|
|
19
|
+
|
|
20
|
+
# Layout
|
|
21
|
+
Layout:
|
|
2
22
|
Enabled: true
|
|
3
|
-
EnforcedStyle: double_quotes
|
|
4
23
|
|
|
5
|
-
|
|
24
|
+
Layout/CaseIndentation:
|
|
25
|
+
EnforcedStyle: end
|
|
26
|
+
|
|
27
|
+
Layout/EndAlignment:
|
|
28
|
+
EnforcedStyleAlignWith: variable
|
|
29
|
+
|
|
30
|
+
Layout/MultilineMethodCallIndentation:
|
|
31
|
+
EnforcedStyle: indented
|
|
32
|
+
|
|
33
|
+
Layout/MultilineOperationIndentation:
|
|
34
|
+
EnforcedStyle: indented
|
|
35
|
+
|
|
36
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
37
|
+
Layout/SpaceBeforeBrackets: # (new in 1.7)
|
|
38
|
+
Enabled: true
|
|
39
|
+
|
|
40
|
+
# Lint
|
|
41
|
+
Lint:
|
|
42
|
+
Enabled: true
|
|
43
|
+
|
|
44
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
45
|
+
Lint/AmbiguousAssignment: # (new in 1.7)
|
|
46
|
+
Enabled: true
|
|
47
|
+
|
|
48
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
49
|
+
Lint/DeprecatedConstants: # (new in 1.8)
|
|
50
|
+
Enabled: true
|
|
51
|
+
|
|
52
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
53
|
+
Lint/DuplicateBranch: # (new in 1.3)
|
|
54
|
+
Enabled: true
|
|
55
|
+
|
|
56
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
57
|
+
Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
|
|
58
|
+
Enabled: true
|
|
59
|
+
|
|
60
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
61
|
+
Lint/EmptyBlock: # (new in 1.1)
|
|
62
|
+
Enabled: true
|
|
63
|
+
|
|
64
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
65
|
+
Lint/EmptyClass: # (new in 1.3)
|
|
66
|
+
Enabled: true
|
|
67
|
+
|
|
68
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
69
|
+
Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
|
|
70
|
+
Enabled: true
|
|
71
|
+
|
|
72
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
73
|
+
Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
|
|
74
|
+
Enabled: true
|
|
75
|
+
|
|
76
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
77
|
+
Lint/RedundantDirGlobSort: # (new in 1.8)
|
|
78
|
+
Enabled: true
|
|
79
|
+
|
|
80
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
81
|
+
Lint/ToEnumArguments: # (new in 1.1)
|
|
82
|
+
Enabled: true
|
|
83
|
+
|
|
84
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
85
|
+
Lint/UnexpectedBlockArity: # (new in 1.5)
|
|
86
|
+
Enabled: true
|
|
87
|
+
|
|
88
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
89
|
+
Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
|
|
90
|
+
Enabled: true
|
|
91
|
+
|
|
92
|
+
# Metrics
|
|
93
|
+
Metrics:
|
|
94
|
+
Enabled: true
|
|
95
|
+
|
|
96
|
+
Metrics/AbcSize:
|
|
97
|
+
CountRepeatedAttributes: false
|
|
98
|
+
|
|
99
|
+
Metrics/BlockLength:
|
|
100
|
+
Exclude:
|
|
101
|
+
- "spec/**/*_spec.rb"
|
|
102
|
+
- "spec/support/factories.rb"
|
|
103
|
+
- "test/factories.rb"
|
|
104
|
+
- "spec/factories.rb"
|
|
105
|
+
- "test/factories/*.rb"
|
|
106
|
+
- "spec/factories/*.rb"
|
|
107
|
+
- "*.gemspec"
|
|
108
|
+
|
|
109
|
+
Metrics/ClassLength:
|
|
110
|
+
Max: 500
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
Metrics/ModuleLength:
|
|
114
|
+
Max: 500
|
|
115
|
+
|
|
116
|
+
Metrics/MethodLength:
|
|
117
|
+
Max: 50
|
|
118
|
+
|
|
119
|
+
# Performance
|
|
120
|
+
Performance:
|
|
121
|
+
Enabled: true
|
|
122
|
+
|
|
123
|
+
# TODO: remove for gem rubocop-performance >= v2, once it'll become default
|
|
124
|
+
Performance/AncestorsInclude: # (new in 1.7)
|
|
125
|
+
Enabled: true
|
|
126
|
+
|
|
127
|
+
# TODO: remove for gem rubocop-performance >= v2, once it'll become default
|
|
128
|
+
Performance/BigDecimalWithNumericArgument: # (new in 1.7)
|
|
129
|
+
Enabled: true
|
|
130
|
+
|
|
131
|
+
# TODO: remove for gem rubocop-performance >= v2, once it'll become default
|
|
132
|
+
Performance/BlockGivenWithExplicitBlock: # (new in 1.9)
|
|
133
|
+
Enabled: true
|
|
134
|
+
|
|
135
|
+
# TODO: remove for gem rubocop-performance >= v2, once it'll become default
|
|
136
|
+
Performance/CollectionLiteralInLoop: # (new in 1.8)
|
|
137
|
+
Enabled: true
|
|
138
|
+
|
|
139
|
+
# TODO: remove for gem rubocop-performance >= v2, once it'll become default
|
|
140
|
+
Performance/ConstantRegexp: # (new in 1.9)
|
|
141
|
+
Enabled: true
|
|
142
|
+
|
|
143
|
+
# TODO: remove for gem rubocop-performance >= v2, once it'll become default
|
|
144
|
+
Performance/MethodObjectAsBlock: # (new in 1.9)
|
|
145
|
+
Enabled: true
|
|
146
|
+
|
|
147
|
+
# TODO: remove for gem rubocop-performance >= v2, once it'll become default
|
|
148
|
+
Performance/RedundantSortBlock: # (new in 1.7)
|
|
149
|
+
Enabled: true
|
|
150
|
+
|
|
151
|
+
# TODO: remove for gem rubocop-performance >= v2, once it'll become default
|
|
152
|
+
Performance/RedundantStringChars: # (new in 1.7)
|
|
153
|
+
Enabled: true
|
|
154
|
+
|
|
155
|
+
# TODO: remove for gem rubocop-performance >= v2, once it'll become default
|
|
156
|
+
Performance/ReverseFirst: # (new in 1.7)
|
|
157
|
+
Enabled: true
|
|
158
|
+
|
|
159
|
+
# TODO: remove for gem rubocop-performance >= v2, once it'll become default
|
|
160
|
+
Performance/SortReverse: # (new in 1.7)
|
|
161
|
+
Enabled: true
|
|
162
|
+
|
|
163
|
+
# TODO: remove for gem rubocop-performance >= v2, once it'll become default
|
|
164
|
+
Performance/Squeeze: # (new in 1.7)
|
|
165
|
+
Enabled: true
|
|
166
|
+
|
|
167
|
+
# TODO: remove for gem rubocop-performance >= v2, once it'll become default
|
|
168
|
+
Performance/StringInclude: # (new in 1.7)
|
|
169
|
+
Enabled: true
|
|
170
|
+
|
|
171
|
+
# TODO: remove for gem rubocop-performance >= v2, once it'll become default
|
|
172
|
+
Performance/Sum: # (new in 1.8)
|
|
173
|
+
Enabled: true
|
|
174
|
+
|
|
175
|
+
# Rake
|
|
176
|
+
|
|
177
|
+
Rake:
|
|
178
|
+
Enabled: true
|
|
179
|
+
|
|
180
|
+
# Rspec
|
|
181
|
+
RSpec/AnyInstance:
|
|
182
|
+
Enabled: true
|
|
183
|
+
|
|
184
|
+
RSpec/ContextWording:
|
|
185
|
+
Enabled: true
|
|
186
|
+
|
|
187
|
+
RSpec/ExampleLength:
|
|
188
|
+
Enabled: false
|
|
189
|
+
|
|
190
|
+
RSpec/MessageSpies:
|
|
191
|
+
Enabled: true
|
|
192
|
+
|
|
193
|
+
RSpec/MultipleExpectations:
|
|
194
|
+
Max: 6
|
|
195
|
+
|
|
196
|
+
RSpec/NamedSubject:
|
|
197
|
+
IgnoreSharedExamples: true
|
|
198
|
+
|
|
199
|
+
# Style
|
|
200
|
+
Style:
|
|
6
201
|
Enabled: true
|
|
202
|
+
|
|
203
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
204
|
+
Style/ArgumentsForwarding: # (new in 1.1)
|
|
205
|
+
Enabled: true
|
|
206
|
+
|
|
207
|
+
# The problem with e.g. class Foo::Bar is when Foo is not defined. Rails will try to auto-load what
|
|
208
|
+
# it thinks is the right file, which (pre-Rails 6.0) sometimes leads to it loading the wrong file,
|
|
209
|
+
# and Bar being defined in the wrong namespace. This way we can be more elastic and remove not needed nesting.
|
|
210
|
+
Style/ClassAndModuleChildren:
|
|
211
|
+
Enabled: false
|
|
212
|
+
|
|
213
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
214
|
+
Style/CollectionCompact: # (new in 1.2)
|
|
215
|
+
Enabled: true
|
|
216
|
+
|
|
217
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
218
|
+
Style/DocumentDynamicEvalDefinition: # (new in 1.1)
|
|
219
|
+
Enabled: true
|
|
220
|
+
|
|
221
|
+
Style/Documentation:
|
|
222
|
+
Enabled: false
|
|
223
|
+
|
|
224
|
+
Style/DoubleNegation:
|
|
225
|
+
Enabled: false
|
|
226
|
+
|
|
227
|
+
Style/EmptyMethod:
|
|
228
|
+
EnforcedStyle: expanded
|
|
229
|
+
|
|
230
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
231
|
+
Style/EndlessMethod: # (new in 1.8)
|
|
232
|
+
Enabled: true
|
|
233
|
+
|
|
234
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
235
|
+
Style/HashExcept: # (new in 1.7)
|
|
236
|
+
Enabled: true
|
|
237
|
+
|
|
238
|
+
Style/HashSyntax:
|
|
239
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
|
240
|
+
|
|
241
|
+
Style/ModuleFunction:
|
|
242
|
+
Enabled: false
|
|
243
|
+
|
|
244
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
245
|
+
Style/NegatedIfElseCondition: # (new in 1.2)
|
|
246
|
+
Enabled: true
|
|
247
|
+
|
|
248
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
249
|
+
Style/NilLambda: # (new in 1.3)
|
|
250
|
+
Enabled: true
|
|
251
|
+
|
|
252
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
253
|
+
Style/RedundantArgument: # (new in 1.4)
|
|
254
|
+
Enabled: true
|
|
255
|
+
|
|
256
|
+
# https://www.viget.com/articles/just-use-double-quoted-ruby-strings/
|
|
257
|
+
Style/StringLiterals:
|
|
7
258
|
EnforcedStyle: double_quotes
|
|
259
|
+
ConsistentQuotesInMultiline: true
|
|
260
|
+
|
|
261
|
+
# TODO: remove for gem rubocop >= v2, once it'll become default
|
|
262
|
+
Style/SwapValues: # (new in 1.1)
|
|
263
|
+
Enabled: true
|
|
264
|
+
|
|
265
|
+
Style/SymbolArray:
|
|
266
|
+
Enabled: false
|
|
267
|
+
|
|
268
|
+
Style/TrailingCommaInArrayLiteral:
|
|
269
|
+
Enabled: false
|
|
270
|
+
|
|
271
|
+
Style/TrailingCommaInHashLiteral:
|
|
272
|
+
Enabled: false
|
|
8
273
|
|
|
9
|
-
|
|
10
|
-
|
|
274
|
+
Style/WordArray:
|
|
275
|
+
Enabled: false
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
## ClickUp::Client
|
|
2
2
|
|
|
3
|
-
Unofficial ClickUp API Client for Ruby.
|
|
3
|
+
Unofficial ClickUp API Client for Ruby.
|
|
4
|
+
|
|
5
|
+
Supports ClickUp API 2.0 - https://clickup.com/api
|
|
6
|
+
|
|
7
|
+
Development in progress - contributions are welcome!
|
|
4
8
|
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
@@ -20,8 +24,25 @@ Or install it yourself as:
|
|
|
20
24
|
|
|
21
25
|
## Usage
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
### Tasks
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
require "click_up/client"
|
|
31
|
+
|
|
32
|
+
client = ClickUp::Client.new(api_token: YOUR_API_TOKEN)
|
|
33
|
+
tasks_client = client.tasks(list_id: YOUR_LIST_ID)
|
|
24
34
|
|
|
35
|
+
tasks_client.all # => fetches all unarchived tasks
|
|
36
|
+
tasks_client.all(archived: true) # => fetches all archived
|
|
37
|
+
|
|
38
|
+
tasks_client.find("abcd")
|
|
39
|
+
|
|
40
|
+
tasks_client.create({name: "New Task"})
|
|
41
|
+
|
|
42
|
+
tasks_client.update(task_id: "abcd", attributes: {name: "Updated Task"})
|
|
43
|
+
|
|
44
|
+
tasks_client.delete("abcd")
|
|
45
|
+
```
|
|
25
46
|
## Development
|
|
26
47
|
|
|
27
48
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/bin/console
CHANGED
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require "bundler/setup"
|
|
5
|
+
require "dotenv/load"
|
|
5
6
|
require "click_up/client"
|
|
6
7
|
|
|
8
|
+
API_TOKEN = ENV.fetch("CLICK_UP_API_TOKEN")
|
|
9
|
+
WORKSPACE_ID = ENV.fetch("CLICK_UP_WORKSPACE_ID")
|
|
10
|
+
SPACE_ID = ENV.fetch("CLICK_UP_SPACE_ID")
|
|
11
|
+
DEFAULT_LIST_ID = ENV.fetch("CLICK_UP_DEFAULT_LIST_ID")
|
|
12
|
+
|
|
7
13
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
14
|
# with your gem easier. You can also use a different console, if you like.
|
|
9
15
|
|
|
10
16
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
require "irb"
|
|
15
|
-
IRB.start(__FILE__)
|
|
17
|
+
require "pry"
|
|
18
|
+
Pry.start(__FILE__)
|
data/click_up-client.gemspec
CHANGED
|
@@ -25,7 +25,14 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
spec.require_paths = ["lib"]
|
|
26
26
|
|
|
27
27
|
spec.add_dependency "faraday", "~> 1.3"
|
|
28
|
+
spec.add_dependency "oj", "~> 3.0"
|
|
29
|
+
spec.add_dependency "dry-struct", "~> 1.4"
|
|
30
|
+
spec.add_dependency "dry-types", "~> 1.5"
|
|
28
31
|
|
|
29
32
|
spec.add_development_dependency "dotenv", "~> 2.7"
|
|
30
33
|
spec.add_development_dependency "pry", "~> 0.13"
|
|
34
|
+
spec.add_development_dependency "webmock", "~> 3.0"
|
|
35
|
+
spec.add_development_dependency "simplecov", "~> 0.21"
|
|
36
|
+
spec.add_development_dependency "faker", "~> 2"
|
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.10"
|
|
31
38
|
end
|
data/lib/click_up/client.rb
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "client/version"
|
|
4
|
-
require_relative "client/
|
|
4
|
+
require_relative "client/http_client"
|
|
5
|
+
require_relative "tasks/service"
|
|
6
|
+
require_relative "tasks/task"
|
|
7
|
+
require_relative "tasks/factory"
|
|
8
|
+
require_relative "types/base"
|
|
5
9
|
|
|
6
10
|
module ClickUp
|
|
7
11
|
class Client
|
|
8
|
-
attr_reader :api_token
|
|
12
|
+
attr_reader :api_token, :default_list_id
|
|
9
13
|
|
|
10
14
|
def initialize(options = {})
|
|
11
15
|
@api_token = options.fetch(:api_token)
|
|
16
|
+
@default_list_id = options.fetch(:default_list_id, nil)
|
|
17
|
+
|
|
18
|
+
@http_client = HttpClient.new(api_token: @api_token)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def tasks(list_id: @default_list_id)
|
|
22
|
+
raise ArgumentError, "list_id can't be nil when default_list_id was not provided" if list_id.nil?
|
|
23
|
+
|
|
24
|
+
ClickUp::Tasks::Service.new(list_id: list_id, http_client: @http_client)
|
|
12
25
|
end
|
|
13
26
|
end
|
|
14
27
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "faraday"
|
|
4
|
+
require "forwardable"
|
|
5
|
+
|
|
6
|
+
module ClickUp
|
|
7
|
+
class Client
|
|
8
|
+
class HttpClient
|
|
9
|
+
extend Forwardable
|
|
10
|
+
|
|
11
|
+
CLICK_UP_API_BASE_URL = "https://api.clickup.com/api/v2"
|
|
12
|
+
|
|
13
|
+
def initialize(api_token:)
|
|
14
|
+
@client = init_client(api_token)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def_delegators :@client, :get, :post, :put, :delete
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def init_client(api_token)
|
|
22
|
+
Faraday.new(
|
|
23
|
+
url: CLICK_UP_API_BASE_URL,
|
|
24
|
+
headers: {
|
|
25
|
+
"Authorization" => api_token,
|
|
26
|
+
"Accept" => "application/json"
|
|
27
|
+
}
|
|
28
|
+
) do |conn|
|
|
29
|
+
conn.response :logger if ENV["FARADAY_ENABLE_LOGGER"]
|
|
30
|
+
conn.response :raise_error
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "./task"
|
|
4
|
+
|
|
5
|
+
module ClickUp
|
|
6
|
+
module Tasks
|
|
7
|
+
module Factory
|
|
8
|
+
module_function
|
|
9
|
+
|
|
10
|
+
# @param items [Array] An array of objects containing Task fields
|
|
11
|
+
def build_collection(items)
|
|
12
|
+
items.map { |task| Task.new(task) }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "oj"
|
|
4
|
+
|
|
5
|
+
module ClickUp
|
|
6
|
+
module Tasks
|
|
7
|
+
class Service
|
|
8
|
+
attr_reader :list_id
|
|
9
|
+
|
|
10
|
+
# @param list_id [Integer]
|
|
11
|
+
# @param http_client [#get, #delete, #post, #put, #patch] any object implementing http requests
|
|
12
|
+
def initialize(list_id:, http_client:)
|
|
13
|
+
@list_id = list_id
|
|
14
|
+
@http_client = http_client
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# @param archived [Boolean] flag telling whether to fetch only achieved tasks or unarchived ones
|
|
18
|
+
# @return [Array<ClickUp::Tasks::Task>]
|
|
19
|
+
def all(archived: false)
|
|
20
|
+
url = "list/#{@list_id}/task?archived=#{archived}"
|
|
21
|
+
|
|
22
|
+
resp = @http_client.get(url)
|
|
23
|
+
|
|
24
|
+
body = Oj.load(resp.body)
|
|
25
|
+
tasks = body.fetch("tasks")
|
|
26
|
+
ClickUp::Tasks::Factory.build_collection(tasks)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @param task_id [String]
|
|
30
|
+
# @return [ClickUp::Tasks::Task]
|
|
31
|
+
def find(task_id)
|
|
32
|
+
resp = @http_client.get("task/#{task_id}")
|
|
33
|
+
|
|
34
|
+
Oj.load(resp.body).then { |task| Task.new(task) }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @param task_id [String]
|
|
38
|
+
def delete(task_id)
|
|
39
|
+
@http_client.delete("task/#{task_id}")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @param attributes [Hash]
|
|
43
|
+
# @return [ClickUp::Tasks::Task]
|
|
44
|
+
def create(attributes)
|
|
45
|
+
url = "list/#{@list_id}/task"
|
|
46
|
+
|
|
47
|
+
payload = Oj.dump(attributes, mode: :compat)
|
|
48
|
+
resp = @http_client.post(url, payload, { "Content-Type" => "application/json" })
|
|
49
|
+
|
|
50
|
+
Oj.load(resp.body).then { |task| Task.new(task) }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# @param task_id [String]
|
|
54
|
+
# @param attributes [Hash]
|
|
55
|
+
# @return [ClickUp::Tasks::Task]
|
|
56
|
+
def update(task_id:, attributes:)
|
|
57
|
+
url = "task/#{task_id}"
|
|
58
|
+
|
|
59
|
+
payload = Oj.dump(attributes, mode: :compat)
|
|
60
|
+
resp = @http_client.put(url, payload, { "Content-Type" => "application/json" })
|
|
61
|
+
|
|
62
|
+
Oj.load(resp.body).then { |task| Task.new(task) }
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "dry-struct"
|
|
4
|
+
require_relative "../types/base"
|
|
5
|
+
|
|
6
|
+
module ClickUp
|
|
7
|
+
module Tasks
|
|
8
|
+
class Task < Dry::Struct
|
|
9
|
+
transform_keys(&:to_sym)
|
|
10
|
+
|
|
11
|
+
attribute :id, Types::Base::String
|
|
12
|
+
attribute? :custom_id, Types::Base::String.optional
|
|
13
|
+
attribute :name, Types::Base::String
|
|
14
|
+
attribute :text_content, Types::Base::String.optional
|
|
15
|
+
attribute :description, Types::Base::String.optional
|
|
16
|
+
attribute :status, Types::Base::Hash
|
|
17
|
+
attribute :orderindex, Types::Base::Strict::String
|
|
18
|
+
attribute :date_created, Types::Base::Coercible::Integer
|
|
19
|
+
attribute :date_updated, Types::Base::Coercible::Integer.optional
|
|
20
|
+
attribute :start_date, Types::Base::Coercible::Integer.optional
|
|
21
|
+
attribute :date_closed, Types::Base::Coercible::Integer.optional
|
|
22
|
+
attribute :due_date, Types::Base::Coercible::Integer.optional
|
|
23
|
+
attribute :archived, Types::Base::Bool
|
|
24
|
+
attribute :creator, Types::Base::Hash
|
|
25
|
+
attribute :assignees, Types::Base::Array
|
|
26
|
+
attribute :watchers, Types::Base::Array
|
|
27
|
+
attribute :tags, Types::Base::Array
|
|
28
|
+
attribute :parent, Types::Base::Any
|
|
29
|
+
attribute :priority, Types::Base::Hash.optional
|
|
30
|
+
attribute :points, Types::Base::Integer.optional
|
|
31
|
+
attribute :time_estimate, Types::Base::Integer.optional
|
|
32
|
+
attribute? :time_spent, Types::Base::Integer.optional
|
|
33
|
+
attribute :custom_fields, Types::Base::Array
|
|
34
|
+
attribute :dependencies, Types::Base::Array
|
|
35
|
+
attribute :linked_tasks, Types::Base::Array
|
|
36
|
+
attribute :team_id, Types::Base::String
|
|
37
|
+
attribute :url, Types::Base::String
|
|
38
|
+
attribute :permission_level, Types::Base::String
|
|
39
|
+
attribute :list, Types::Base::Hash
|
|
40
|
+
attribute :project, Types::Base::Hash
|
|
41
|
+
attribute :folder, Types::Base::Hash
|
|
42
|
+
attribute :space, Types::Base::Hash
|
|
43
|
+
attribute? :attachments, Types::Base::Array
|
|
44
|
+
attribute :checklists, Types::Base::Array
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: click_up-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jakub Kopyś
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-02-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -24,6 +24,48 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.3'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: oj
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '3.0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '3.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: dry-struct
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.4'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.4'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: dry-types
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '1.5'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '1.5'
|
|
27
69
|
- !ruby/object:Gem::Dependency
|
|
28
70
|
name: dotenv
|
|
29
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -52,6 +94,62 @@ dependencies:
|
|
|
52
94
|
- - "~>"
|
|
53
95
|
- !ruby/object:Gem::Version
|
|
54
96
|
version: '0.13'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: webmock
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '3.0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '3.0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: simplecov
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0.21'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0.21'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: faker
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '2'
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '2'
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: rspec
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - "~>"
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '3.10'
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - "~>"
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '3.10'
|
|
55
153
|
description:
|
|
56
154
|
email:
|
|
57
155
|
- jakubkopys95@gmail.com
|
|
@@ -71,7 +169,12 @@ files:
|
|
|
71
169
|
- bin/setup
|
|
72
170
|
- click_up-client.gemspec
|
|
73
171
|
- lib/click_up/client.rb
|
|
172
|
+
- lib/click_up/client/http_client.rb
|
|
74
173
|
- lib/click_up/client/version.rb
|
|
174
|
+
- lib/click_up/tasks/factory.rb
|
|
175
|
+
- lib/click_up/tasks/service.rb
|
|
176
|
+
- lib/click_up/tasks/task.rb
|
|
177
|
+
- lib/click_up/types/base.rb
|
|
75
178
|
homepage: https://github.com/JakubKopys/click_up-client
|
|
76
179
|
licenses:
|
|
77
180
|
- MIT
|