kaze_client 0.3.2.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +249 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +52 -40
- data/README.md +22 -0
- data/kaze_client.gemspec +0 -1
- data/lib/kaze_client/client.rb +5 -1
- data/lib/kaze_client/data_utils.rb +4 -0
- data/lib/kaze_client/error/disabled_account.rb +7 -1
- data/lib/kaze_client/error/forbidden.rb +7 -1
- data/lib/kaze_client/error/generic.rb +6 -0
- data/lib/kaze_client/error/internal_server_error.rb +7 -1
- data/lib/kaze_client/error/invalid_credentials.rb +7 -1
- data/lib/kaze_client/error/no_endpoint.rb +6 -0
- data/lib/kaze_client/error/no_private_token.rb +7 -1
- data/lib/kaze_client/error/not_found.rb +7 -1
- data/lib/kaze_client/error/unauthorized.rb +7 -1
- data/lib/kaze_client/json_utils.rb +4 -0
- data/lib/kaze_client/request/request.rb +5 -1
- data/lib/kaze_client/request/requests/collections/collection_request.rb +4 -0
- data/lib/kaze_client/request/requests/collections/collections_request.rb +4 -0
- data/lib/kaze_client/request/requests/collections/items/create_collection_item_request.rb +4 -0
- data/lib/kaze_client/request/requests/collections/items/create_link_request.rb +8 -0
- data/lib/kaze_client/request/requests/collections/items/item_request.rb +6 -0
- data/lib/kaze_client/request/requests/collections/items/items_request.rb +6 -0
- data/lib/kaze_client/request/requests/jobs/add_tag_request.rb +4 -0
- data/lib/kaze_client/request/requests/jobs/assign_performer_request.rb +4 -0
- data/lib/kaze_client/request/requests/jobs/cancel_job_request.rb +4 -0
- data/lib/kaze_client/request/requests/jobs/complete_step_request.rb +36 -0
- data/lib/kaze_client/request/requests/jobs/create_job_request.rb +5 -1
- data/lib/kaze_client/request/requests/jobs/job_document_request.rb +4 -0
- data/lib/kaze_client/request/requests/jobs/job_request.rb +4 -0
- data/lib/kaze_client/request/requests/jobs/job_workflow_request.rb +4 -0
- data/lib/kaze_client/request/requests/jobs/job_workflows_request.rb +4 -0
- data/lib/kaze_client/request/requests/jobs/jobs_request.rb +4 -0
- data/lib/kaze_client/request/requests/jobs/update_template_request.rb +4 -0
- data/lib/kaze_client/request/requests/login_request.rb +5 -1
- data/lib/kaze_client/request/requests/partners_request.rb +4 -0
- data/lib/kaze_client/request/requests/profile_request.rb +4 -0
- data/lib/kaze_client/request/requests/tags/tag_request.rb +21 -0
- data/lib/kaze_client/request/requests/tags/tags_request.rb +20 -0
- data/lib/kaze_client/request/requests/upload_attachment_request.rb +7 -3
- data/lib/kaze_client/request/requests/upload_image_request.rb +4 -0
- data/lib/kaze_client/request/requests/users_request.rb +4 -0
- data/lib/kaze_client/request/requests/utils/authentified_request.rb +6 -0
- data/lib/kaze_client/request/requests/utils/final_request.rb +6 -0
- data/lib/kaze_client/request/requests/utils/list_request.rb +8 -4
- data/lib/kaze_client/requests.rb +7 -0
- data/lib/kaze_client/response.rb +5 -1
- data/lib/kaze_client/version.rb +3 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bad3016b37b1fcfbc04bf4882571b9d346d4c6debacf3240735abbd8d56495f
|
4
|
+
data.tar.gz: 5ae1d5dbcf3312b49a88ca829a9a81cbc563c62af259a81863981098ff513b15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df16ba5388bad0cb2cbb71f1667d617986b124100be8b2dfc815eadfd36ed487567954419e9d89ca7c03d0f3c1ec84ce6550d469817161db21f77e2148057e52
|
7
|
+
data.tar.gz: cb28147c6f5831cd82f1ed31050e0f307fc875725d0b2c0fff558b833868ed3968a4944b184a73494ee1694f631e6b5516c8e836f0d0b4f144392bfaa25b73d3
|
data/.rubocop.yml
CHANGED
@@ -1,2 +1,251 @@
|
|
1
|
+
# The behavior of RuboCop can be controlled via the .rubocop.yml
|
2
|
+
# configuration file. It makes it possible to enable/disable
|
3
|
+
# certain cops (checks) and to alter their behavior if they accept
|
4
|
+
# any parameters. The file can be placed either in your home
|
5
|
+
# directory or in some project directory.
|
6
|
+
#
|
7
|
+
# RuboCop will start looking for the configuration file in the directory
|
8
|
+
# where the inspected file is and continue its way up to the root directory.
|
9
|
+
#
|
10
|
+
# See https://docs.rubocop.org/rubocop/configuration
|
11
|
+
|
12
|
+
inherit_mode:
|
13
|
+
merge:
|
14
|
+
- Exclude
|
15
|
+
- Include
|
16
|
+
|
1
17
|
AllCops:
|
18
|
+
# Enable new cops by default
|
2
19
|
NewCops: enable
|
20
|
+
|
21
|
+
# Align target ruby version with the required ruby version in gemspec
|
22
|
+
TargetRubyVersion: 2.6
|
23
|
+
|
24
|
+
# Excluding most directories with generated files and directories with configuration files.
|
25
|
+
Exclude:
|
26
|
+
- 'bin'
|
27
|
+
- '.github'
|
28
|
+
- '**/Gemfile'
|
29
|
+
- '**/Guardfile'
|
30
|
+
- '**/Rakefile'
|
31
|
+
- 'node_modules/**/*'
|
32
|
+
- 'spec/**/*'
|
33
|
+
- 'sig/**/*'
|
34
|
+
|
35
|
+
# Checks if String literals are using single quotes when no interpolation is required
|
36
|
+
Style/StringLiterals:
|
37
|
+
Enabled: true
|
38
|
+
EnforcedStyle: single_quotes
|
39
|
+
ConsistentQuotesInMultiline: false
|
40
|
+
|
41
|
+
# Checks if the quotes used for quoted symbols are single quotes when no interpolation is required
|
42
|
+
Style/QuotedSymbols:
|
43
|
+
Enabled: true
|
44
|
+
EnforcedStyle: same_as_string_literals
|
45
|
+
|
46
|
+
# This cop checks for uses of literal strings converted to a symbol where a literal symbol could be used instead.
|
47
|
+
Lint/SymbolConversion:
|
48
|
+
Enabled: true
|
49
|
+
EnforcedStyle: strict
|
50
|
+
|
51
|
+
# Useless cop. It checks for unnecessary safe navigations.
|
52
|
+
# Example:
|
53
|
+
# obj&.a && obj.b
|
54
|
+
# Triggers rubocop error: it requires to add safe navigation for "obj.b" call => "obj&.b".
|
55
|
+
# but it is not necessary. obj&.a will return nil if obj is nil, and it will stop
|
56
|
+
# execution of the operation because `&&` right part executes only when left part is truthy.
|
57
|
+
Lint/SafeNavigationConsistency:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
# Checks for places where keyword arguments can be used instead of boolean arguments when defining methods.
|
61
|
+
# Disabled because moving from default arguments to keywords is not that easy.
|
62
|
+
Style/OptionalBooleanParameter:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
# Checks for use of the lambda.(args) syntax.
|
66
|
+
# Disabled while the Ruby team has not voted on this.
|
67
|
+
Style/LambdaCall:
|
68
|
+
Enabled: false
|
69
|
+
EnforcedStyle: braces
|
70
|
+
|
71
|
+
# Checks for presence or absence of braces around hash literal as a last array item depending on configuration.
|
72
|
+
# Disabled because it would break a lot of permitted_params definitions
|
73
|
+
Style/HashAsLastArrayItem:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
# Checks for grouping of accessors in class and module bodies.
|
77
|
+
# Useless.
|
78
|
+
Style/AccessorGrouping:
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
# Makes our lives happier: we don't need to disable it in each case/when method
|
82
|
+
# with more than 5 "when"s.
|
83
|
+
Metrics/CyclomaticComplexity:
|
84
|
+
Max: 10
|
85
|
+
|
86
|
+
# Commonly used screens these days easily fit more than 80 characters.
|
87
|
+
Layout/LineLength:
|
88
|
+
Max: 120
|
89
|
+
|
90
|
+
# Too short methods lead to extraction of single-use methods, which can make
|
91
|
+
# the code easier to read (by naming things), but can also clutter the class
|
92
|
+
Metrics/MethodLength:
|
93
|
+
Max: 25
|
94
|
+
|
95
|
+
# The guiding principle of classes is SRP, SRP can't be accurately measured by LoC
|
96
|
+
Metrics/ClassLength:
|
97
|
+
Max: 1500
|
98
|
+
|
99
|
+
# No space makes the method definition shorter and differentiates
|
100
|
+
# from a regular assignment.
|
101
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
102
|
+
EnforcedStyle: no_space
|
103
|
+
|
104
|
+
# We do not need to support Ruby 1.9, so this is good to use.
|
105
|
+
Style/SymbolArray:
|
106
|
+
Enabled: true
|
107
|
+
|
108
|
+
# Most readable form.
|
109
|
+
Layout/HashAlignment:
|
110
|
+
EnforcedHashRocketStyle: table
|
111
|
+
EnforcedColonStyle: table
|
112
|
+
|
113
|
+
# Mixing the styles looks just silly.
|
114
|
+
Style/HashSyntax:
|
115
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
116
|
+
|
117
|
+
# has_key? and has_value? are far more readable than key? and value?
|
118
|
+
Style/PreferredHashMethods:
|
119
|
+
Enabled: false
|
120
|
+
|
121
|
+
# String#% is by far the least verbose and only object oriented variant.
|
122
|
+
Style/FormatString:
|
123
|
+
EnforcedStyle: percent
|
124
|
+
|
125
|
+
# Annotated or template are too verbose and rarely needed.
|
126
|
+
Style/FormatStringToken:
|
127
|
+
EnforcedStyle: unannotated
|
128
|
+
|
129
|
+
Style/CollectionMethods:
|
130
|
+
Enabled: true
|
131
|
+
PreferredMethods:
|
132
|
+
# inject seems more common in the community.
|
133
|
+
reduce: "inject"
|
134
|
+
|
135
|
+
# Either allow this style or don't. Marking it as safe with parenthesis
|
136
|
+
# is silly. Let's try to live without them for now.
|
137
|
+
Style/ParenthesesAroundCondition:
|
138
|
+
AllowSafeAssignment: false
|
139
|
+
Lint/AssignmentInCondition:
|
140
|
+
AllowSafeAssignment: false
|
141
|
+
|
142
|
+
# A specialized exception class will take one or more arguments and construct the message from it.
|
143
|
+
# So both variants make sense.
|
144
|
+
Style/RaiseArgs:
|
145
|
+
Enabled: false
|
146
|
+
|
147
|
+
# Indenting the chained dots beneath each other is not supported by this cop,
|
148
|
+
# see https://github.com/bbatsov/rubocop/issues/1633
|
149
|
+
Layout/MultilineOperationIndentation:
|
150
|
+
Enabled: false
|
151
|
+
|
152
|
+
# Fail is an alias of raise. Avoid aliases, it's more cognitive load for no gain.
|
153
|
+
# The argument that fail should be used to abort the program is wrong too,
|
154
|
+
# there's Kernel#abort for that.
|
155
|
+
Style/SignalException:
|
156
|
+
EnforcedStyle: only_raise
|
157
|
+
|
158
|
+
# Suppressing exceptions can be perfectly fine, and be it to avoid to
|
159
|
+
# explicitly type nil into the rescue since that's what you want to return,
|
160
|
+
# or suppressing LoadError for optional dependencies
|
161
|
+
Lint/SuppressedException:
|
162
|
+
Enabled: false
|
163
|
+
|
164
|
+
# { ... } for multi-line blocks is okay, follow Weirichs rule instead:
|
165
|
+
# https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc
|
166
|
+
Style/BlockDelimiters:
|
167
|
+
Enabled: false
|
168
|
+
|
169
|
+
# do / end blocks should be used for side effects,
|
170
|
+
# methods that run a block for side effects and have
|
171
|
+
# a useful return value are rare, assign the return
|
172
|
+
# value to a local variable for those cases.
|
173
|
+
Style/MethodCalledOnDoEndBlock:
|
174
|
+
Enabled: true
|
175
|
+
|
176
|
+
# Enforcing the names of variables? To single letter ones? Just no.
|
177
|
+
Style/SingleLineBlockParams:
|
178
|
+
Enabled: false
|
179
|
+
|
180
|
+
# Shadowing outer local variables with block parameters is often useful
|
181
|
+
# to not reinvent a new name for the same thing, it highlights the relation
|
182
|
+
# between the outer variable and the parameter. The cases where it's actually
|
183
|
+
# confusing are rare, and usually bad for other reasons already, for example
|
184
|
+
# because the method is too long.
|
185
|
+
Lint/ShadowingOuterLocalVariable:
|
186
|
+
Enabled: false
|
187
|
+
|
188
|
+
# Check with yard instead.
|
189
|
+
Style/Documentation:
|
190
|
+
Enabled: false
|
191
|
+
|
192
|
+
# This is just silly. Calling the argument `other` in all cases makes no sense.
|
193
|
+
Naming/BinaryOperatorParameterName:
|
194
|
+
Enabled: false
|
195
|
+
|
196
|
+
# Disable frozen string
|
197
|
+
Style/FrozenStringLiteralComment:
|
198
|
+
Enabled: false
|
199
|
+
|
200
|
+
# Disable No ASCII char in comments
|
201
|
+
Style/AsciiComments:
|
202
|
+
Enabled: false
|
203
|
+
|
204
|
+
# Disable ordered Gems By ascii
|
205
|
+
Bundler/OrderedGems:
|
206
|
+
Enabled: false
|
207
|
+
|
208
|
+
# Change ABC max value
|
209
|
+
Metrics/AbcSize:
|
210
|
+
Max: 35
|
211
|
+
|
212
|
+
# Disable empty method in one line
|
213
|
+
Style/EmptyMethod:
|
214
|
+
EnforcedStyle: expanded
|
215
|
+
|
216
|
+
# Disable max height block
|
217
|
+
Metrics/BlockLength:
|
218
|
+
Enabled: true
|
219
|
+
Exclude:
|
220
|
+
- 'app/admin/**/*'
|
221
|
+
- 'lib/tasks/**/*'
|
222
|
+
|
223
|
+
# Checks if empty lines around the bodies of classes match the configuration.
|
224
|
+
Layout/EmptyLinesAroundClassBody:
|
225
|
+
EnforcedStyle: empty_lines
|
226
|
+
# Checks if empty lines around the bodies of modules match the configuration.
|
227
|
+
Layout/EmptyLinesAroundModuleBody:
|
228
|
+
EnforcedStyle: empty_lines
|
229
|
+
|
230
|
+
# Enforces the consistent usage of %-literal delimiters.
|
231
|
+
Style/PercentLiteralDelimiters:
|
232
|
+
PreferredDelimiters:
|
233
|
+
default: '()'
|
234
|
+
'%i': '[]'
|
235
|
+
'%I': '[]'
|
236
|
+
'%r': '{}'
|
237
|
+
'%w': '[]'
|
238
|
+
'%W': '[]'
|
239
|
+
|
240
|
+
# Unnecessary cop. In what universe "A || B && C" or "A && B || C && D" is ambiguous? looks
|
241
|
+
# like a cop for those who can't in boolean.
|
242
|
+
Lint/AmbiguousOperatorPrecedence:
|
243
|
+
Enabled: false
|
244
|
+
|
245
|
+
# Checks for simple usages of parallel assignment.
|
246
|
+
Style/ParallelAssignment:
|
247
|
+
Enabled: false
|
248
|
+
|
249
|
+
# Checks the style of children definitions at classes and modules.
|
250
|
+
Style/ClassAndModuleChildren:
|
251
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## [Unreleased]
|
4
|
+
|
5
|
+
## [0.4.0] - 2023-09-12
|
6
|
+
|
7
|
+
- Require `AddTagRequest`
|
8
|
+
- Add new requests:
|
9
|
+
- List all tags
|
10
|
+
- Get details about one tag
|
11
|
+
- Complete step
|
12
|
+
- Update bundler and dependencies
|
13
|
+
|
3
14
|
## [0.3.2.2] - 2023-05-31
|
4
15
|
|
5
16
|
- Add new requests:
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kaze_client (0.
|
4
|
+
kaze_client (0.4.0)
|
5
5
|
httparty (~> 0.18, >= 0.18.1)
|
6
6
|
jsonpath (~> 1.1, >= 1.1.2)
|
7
7
|
|
@@ -9,67 +9,79 @@ GEM
|
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
ast (2.4.2)
|
12
|
+
base64 (0.1.1)
|
12
13
|
bundler-audit (0.9.1)
|
13
14
|
bundler (>= 1.2.0, < 3)
|
14
15
|
thor (~> 1.0)
|
15
|
-
debug (1.
|
16
|
-
irb (>= 1.
|
17
|
-
reline (>= 0.
|
18
|
-
diff-lcs (1.
|
16
|
+
debug (1.8.0)
|
17
|
+
irb (>= 1.5.0)
|
18
|
+
reline (>= 0.3.1)
|
19
|
+
diff-lcs (1.5.0)
|
19
20
|
httparty (0.21.0)
|
20
21
|
mini_mime (>= 1.0.0)
|
21
22
|
multi_xml (>= 0.5.2)
|
22
|
-
io-console (0.
|
23
|
-
irb (1.
|
24
|
-
|
25
|
-
|
23
|
+
io-console (0.6.0)
|
24
|
+
irb (1.8.1)
|
25
|
+
rdoc
|
26
|
+
reline (>= 0.3.8)
|
27
|
+
json (2.6.3)
|
28
|
+
jsonpath (1.1.3)
|
26
29
|
multi_json
|
27
|
-
|
30
|
+
language_server-protocol (3.17.0.3)
|
31
|
+
mini_mime (1.1.5)
|
28
32
|
multi_json (1.15.0)
|
29
33
|
multi_xml (0.6.0)
|
30
|
-
parallel (1.
|
31
|
-
parser (3.
|
34
|
+
parallel (1.23.0)
|
35
|
+
parser (3.2.2.3)
|
32
36
|
ast (~> 2.4.1)
|
37
|
+
racc
|
38
|
+
psych (5.1.0)
|
39
|
+
stringio
|
40
|
+
racc (1.7.1)
|
33
41
|
rainbow (3.1.1)
|
34
|
-
rake (13.0.
|
35
|
-
|
36
|
-
|
42
|
+
rake (13.0.6)
|
43
|
+
rdoc (6.5.0)
|
44
|
+
psych (>= 4.0.0)
|
45
|
+
regexp_parser (2.8.1)
|
46
|
+
reline (0.3.8)
|
37
47
|
io-console (~> 0.5)
|
38
|
-
rexml (3.2.
|
39
|
-
rspec (3.
|
40
|
-
rspec-core (~> 3.
|
41
|
-
rspec-expectations (~> 3.
|
42
|
-
rspec-mocks (~> 3.
|
43
|
-
rspec-core (3.
|
44
|
-
rspec-support (~> 3.
|
45
|
-
rspec-expectations (3.
|
48
|
+
rexml (3.2.6)
|
49
|
+
rspec (3.12.0)
|
50
|
+
rspec-core (~> 3.12.0)
|
51
|
+
rspec-expectations (~> 3.12.0)
|
52
|
+
rspec-mocks (~> 3.12.0)
|
53
|
+
rspec-core (3.12.2)
|
54
|
+
rspec-support (~> 3.12.0)
|
55
|
+
rspec-expectations (3.12.3)
|
46
56
|
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
-
rspec-support (~> 3.
|
48
|
-
rspec-mocks (3.
|
57
|
+
rspec-support (~> 3.12.0)
|
58
|
+
rspec-mocks (3.12.6)
|
49
59
|
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
-
rspec-support (~> 3.
|
51
|
-
rspec-support (3.
|
52
|
-
rubocop (1.
|
60
|
+
rspec-support (~> 3.12.0)
|
61
|
+
rspec-support (3.12.1)
|
62
|
+
rubocop (1.56.3)
|
63
|
+
base64 (~> 0.1.1)
|
64
|
+
json (~> 2.3)
|
65
|
+
language_server-protocol (>= 3.17.0)
|
53
66
|
parallel (~> 1.10)
|
54
|
-
parser (>= 3.
|
67
|
+
parser (>= 3.2.2.3)
|
55
68
|
rainbow (>= 2.2.2, < 4.0)
|
56
69
|
regexp_parser (>= 1.8, < 3.0)
|
57
70
|
rexml (>= 3.2.5, < 4.0)
|
58
|
-
rubocop-ast (>= 1.
|
71
|
+
rubocop-ast (>= 1.28.1, < 2.0)
|
59
72
|
ruby-progressbar (~> 1.7)
|
60
|
-
unicode-display_width (>=
|
61
|
-
rubocop-ast (1.
|
62
|
-
parser (>= 3.
|
73
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
74
|
+
rubocop-ast (1.29.0)
|
75
|
+
parser (>= 3.2.1.0)
|
63
76
|
rubocop-rake (0.6.0)
|
64
77
|
rubocop (~> 1.0)
|
65
78
|
rubocop-rspec (2.11.1)
|
66
79
|
rubocop (~> 1.19)
|
67
|
-
ruby-progressbar (1.
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
yard (0.9.
|
72
|
-
webrick (~> 1.7.0)
|
80
|
+
ruby-progressbar (1.13.0)
|
81
|
+
stringio (3.0.8)
|
82
|
+
thor (1.2.2)
|
83
|
+
unicode-display_width (2.4.2)
|
84
|
+
yard (0.9.34)
|
73
85
|
|
74
86
|
PLATFORMS
|
75
87
|
aarch64-linux
|
@@ -87,4 +99,4 @@ DEPENDENCIES
|
|
87
99
|
yard (~> 0.9.28)
|
88
100
|
|
89
101
|
BUNDLED WITH
|
90
|
-
2.
|
102
|
+
2.4.19
|
data/README.md
CHANGED
@@ -18,6 +18,28 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install kaze_client
|
20
20
|
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Here is an example of how to chain requests:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'kaze_client'
|
27
|
+
|
28
|
+
client = KazeClient::Client.new('https://app.kaze.so', token: 'A_valid_token')
|
29
|
+
request = KazeClient::JobsRequest.new.filter_by_status('completed').filter_by_query('client_reference_42')
|
30
|
+
|
31
|
+
response = client.execute(request)
|
32
|
+
|
33
|
+
first_job = response.dig['data'].first
|
34
|
+
puts("First job id: #{first_job['id']}")
|
35
|
+
|
36
|
+
request = KazeClient::JobRequest.new(first_job['id'])
|
37
|
+
|
38
|
+
job = client.execute(request)
|
39
|
+
pickup_address = job.fetch_data_from_child('pick_up_address', field: 'city')
|
40
|
+
puts("City: #{pickup_address}")
|
41
|
+
```
|
42
|
+
|
21
43
|
## Development
|
22
44
|
|
23
45
|
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/kaze_client.gemspec
CHANGED
data/lib/kaze_client/client.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module KazeClient
|
4
|
+
|
4
5
|
# @author ciappa_m@modulotech.fr
|
5
6
|
# Execute a KazeClient::Request, stores the server's base URL, the request and the response.
|
6
7
|
# @see KazeClient::Request
|
7
8
|
# @see KazeClient::Response
|
8
9
|
# @since 0.1.0
|
9
10
|
class Client
|
11
|
+
|
10
12
|
# @return [String] The server's base URL (e.g. https://app.kaze.so)
|
11
13
|
attr_reader :base_url
|
12
14
|
# @return [String,nil] The last authentication token
|
@@ -50,7 +52,7 @@ module KazeClient
|
|
50
52
|
# @raise [KazeClient::Error::NoEndpoint] if the base URL is blank
|
51
53
|
# @raise [KazeClient::Error::Generic] if the response is not a success: not a 2xx HTTP status
|
52
54
|
# @see KazeClient::Client#do_execute
|
53
|
-
def login(login
|
55
|
+
def login(login=@login, password=@password)
|
54
56
|
# Impossible to login using nil login or password.
|
55
57
|
# The first call to #login must be given a login and a password.
|
56
58
|
raise KazeClient::Error::InvalidCredentials, 'Please set login and password' if login.nil? || password.nil?
|
@@ -106,5 +108,7 @@ module KazeClient
|
|
106
108
|
# Build the response object from the HTTParty response
|
107
109
|
Response.new(@response)
|
108
110
|
end
|
111
|
+
|
109
112
|
end
|
113
|
+
|
110
114
|
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module KazeClient
|
4
|
+
|
4
5
|
# @author richar_p@modulotech.fr
|
5
6
|
# Utility methods to interact with KazeData
|
6
7
|
# @since 0.3.2
|
7
8
|
module DataUtils
|
9
|
+
|
8
10
|
# Parse a Kaze Workflow datetime
|
9
11
|
# @param time [Integer] The datetime to parse
|
10
12
|
# @return [Time] The parsed datetime
|
@@ -16,5 +18,7 @@ module KazeClient
|
|
16
18
|
|
17
19
|
Time.at(time.to_i / 1000).utc
|
18
20
|
end
|
21
|
+
|
19
22
|
end
|
23
|
+
|
20
24
|
end
|
@@ -1,13 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module KazeClient
|
4
|
+
|
4
5
|
module Error
|
6
|
+
|
5
7
|
# @author ciappa_m@modulotech.fr
|
6
8
|
# 403 error sent by Kaze server when trying to log in with a disabled account
|
7
9
|
class DisabledAccount < Forbidden
|
8
|
-
|
10
|
+
|
11
|
+
def initialize(msg='User account was disabled by administrator')
|
9
12
|
super(msg)
|
10
13
|
end
|
14
|
+
|
11
15
|
end
|
16
|
+
|
12
17
|
end
|
18
|
+
|
13
19
|
end
|
@@ -1,13 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module KazeClient
|
4
|
+
|
4
5
|
module Error
|
6
|
+
|
5
7
|
# @author ciappa_m@modulotech.fr
|
6
8
|
# Generic 403 error sent by Kaze server
|
7
9
|
class Forbidden < Generic
|
8
|
-
|
10
|
+
|
11
|
+
def initialize(msg='403 Forbidden')
|
9
12
|
super(status: :forbidden, message: msg)
|
10
13
|
end
|
14
|
+
|
11
15
|
end
|
16
|
+
|
12
17
|
end
|
18
|
+
|
13
19
|
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module KazeClient
|
4
|
+
|
4
5
|
# @since 0.1.0
|
5
6
|
module Error
|
7
|
+
|
6
8
|
# @author ciappa_m@modulotech.fr
|
7
9
|
# Generic error raised when Kaze server send an unknown error. By default, it is considered
|
8
10
|
# to be an internal server error.
|
9
11
|
class Generic < RuntimeError
|
12
|
+
|
10
13
|
# @return [Symbol] The HTTP status sent by the server
|
11
14
|
attr_reader :status
|
12
15
|
|
@@ -24,6 +27,9 @@ module KazeClient
|
|
24
27
|
@status = status || :internal_server_error
|
25
28
|
@error = error || @status
|
26
29
|
end
|
30
|
+
|
27
31
|
end
|
32
|
+
|
28
33
|
end
|
34
|
+
|
29
35
|
end
|
@@ -1,13 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module KazeClient
|
4
|
+
|
4
5
|
module Error
|
6
|
+
|
5
7
|
# @author ciappa_m@modulotech.fr
|
6
8
|
# Generic 500 error sent by Kaze server
|
7
9
|
class InternalServerError < Generic
|
8
|
-
|
10
|
+
|
11
|
+
def initialize(msg='An unknown error occured')
|
9
12
|
super(message: msg)
|
10
13
|
end
|
14
|
+
|
11
15
|
end
|
16
|
+
|
12
17
|
end
|
18
|
+
|
13
19
|
end
|
@@ -1,13 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module KazeClient
|
4
|
+
|
4
5
|
module Error
|
6
|
+
|
5
7
|
# @author ciappa_m@modulotech.fr
|
6
8
|
# 401 error sent by Kaze server when trying to log in with invalid credentials
|
7
9
|
class InvalidCredentials < Unauthorized
|
8
|
-
|
10
|
+
|
11
|
+
def initialize(msg='Invalid Login or Password')
|
9
12
|
super(msg)
|
10
13
|
end
|
14
|
+
|
11
15
|
end
|
16
|
+
|
12
17
|
end
|
18
|
+
|
13
19
|
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module KazeClient
|
4
|
+
|
4
5
|
module Error
|
6
|
+
|
5
7
|
# @author ciappa_m@modulotech.fr
|
6
8
|
# An error raised when the base URL given to the +KazeClient::Client+ is nil
|
7
9
|
# @see KazeClient::Client
|
8
10
|
class NoEndpoint < Generic
|
11
|
+
|
9
12
|
# @return the given base URL
|
10
13
|
attr_reader :base_url
|
11
14
|
|
@@ -14,6 +17,9 @@ module KazeClient
|
|
14
17
|
|
15
18
|
@base_url = base_url
|
16
19
|
end
|
20
|
+
|
17
21
|
end
|
22
|
+
|
18
23
|
end
|
24
|
+
|
19
25
|
end
|
@@ -1,13 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module KazeClient
|
4
|
+
|
4
5
|
module Error
|
6
|
+
|
5
7
|
# @author ciappa_m@modulotech.fr
|
6
8
|
# 403 error sent by Kaze server when trying to log in and user has no token
|
7
9
|
class NoPrivateToken < Forbidden
|
8
|
-
|
10
|
+
|
11
|
+
def initialize(msg='User has no private token assigned')
|
9
12
|
super(msg)
|
10
13
|
end
|
14
|
+
|
11
15
|
end
|
16
|
+
|
12
17
|
end
|
18
|
+
|
13
19
|
end
|
@@ -1,13 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module KazeClient
|
4
|
+
|
4
5
|
module Error
|
6
|
+
|
5
7
|
# @author ciappa_m@modulotech.fr
|
6
8
|
# 404 error sent by Kaze server
|
7
9
|
class NotFound < Generic
|
8
|
-
|
10
|
+
|
11
|
+
def initialize(msg='404 Not Found')
|
9
12
|
super(status: :not_found, message: msg)
|
10
13
|
end
|
14
|
+
|
11
15
|
end
|
16
|
+
|
12
17
|
end
|
18
|
+
|
13
19
|
end
|