virtuous 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/virtuous/client/project.rb +58 -0
- data/lib/virtuous/client.rb +1 -0
- data/lib/virtuous/version.rb +1 -1
- data/spec/support/fixtures/project_query_options.json +2701 -0
- data/spec/support/fixtures/projects.json +93 -0
- data/spec/support/virtuous_mock.rb +3 -1
- data/spec/virtuous/resources/project_spec.rb +70 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21706d887ab7c6356cf12b521724170cd196d432d73bca548d678240f593a0c7
|
4
|
+
data.tar.gz: 79702a4ff37002499687c5eb6d2bd52d5b5ca719ad7654a0d40ed4213af7e6a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd02d1df0306c1d7c575e8dc4c782f9047599b3eb0c3820b09fc240ccaa49a708c9310115b993e8f00041069442565770beb57b744ef8c2be8f11c7bae36523d
|
7
|
+
data.tar.gz: 25c7401a3029d7d5796a416b07081a921b33d34cadb31c9a091e6f4276d6939f49a90b61f0743d8fd76795960e777c55ae019cc1adc218a3462db0853b65838a
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
module Virtuous
|
2
|
+
class Client
|
3
|
+
module Project
|
4
|
+
##
|
5
|
+
# Queries a list of available project query options.
|
6
|
+
# @return [Hash] A list of available project query options.
|
7
|
+
def project_query_options
|
8
|
+
parse(get('api/Project/QueryOptions'))
|
9
|
+
end
|
10
|
+
|
11
|
+
##
|
12
|
+
# Queries projects.
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# client.query_projects(
|
16
|
+
# take: 5, skip: 0, sort_by: 'Id',
|
17
|
+
# conditions: [{ parameter: 'Project Code', operator: 'Is', value: 102 }]
|
18
|
+
# )
|
19
|
+
#
|
20
|
+
# @option options [Integer] :take The maximum amount of projects to query. Default: 10.
|
21
|
+
# Max is 1000.
|
22
|
+
# @option options [Integer] :skip The number of projects to skip. Default: 0.
|
23
|
+
# @option options [String] :sort_by The value to sort records by.
|
24
|
+
# @option options [Boolean] :descending If true the records will be sorted in descending
|
25
|
+
# order.
|
26
|
+
# @option options [Array] :conditions An array of conditions to filter the project.
|
27
|
+
# Use {project_query_options} to see
|
28
|
+
# a full list of available conditions.
|
29
|
+
#
|
30
|
+
# @return [Hash] A hash with a list and the total amount of projects that satisfy
|
31
|
+
# the conditions.
|
32
|
+
# @example Output
|
33
|
+
# { list: [...], total: n }
|
34
|
+
#
|
35
|
+
def query_projects(**options)
|
36
|
+
uri = URI('api/Project/Query')
|
37
|
+
query_params = options.slice(:take, :skip)
|
38
|
+
uri.query = URI.encode_www_form(query_params) unless query_params.empty?
|
39
|
+
|
40
|
+
parse(post(uri, format(query_projects_body(options))))
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def query_projects_body(options)
|
46
|
+
conditions = options[:conditions]
|
47
|
+
body = options.slice(:sort_by, :descending)
|
48
|
+
return body if conditions.nil?
|
49
|
+
|
50
|
+
body.merge({
|
51
|
+
groups: [{
|
52
|
+
conditions: conditions
|
53
|
+
}]
|
54
|
+
})
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/virtuous/client.rb
CHANGED
data/lib/virtuous/version.rb
CHANGED