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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9f937cdf43802f0f1a11389e495f22a8dcbbce4899bab8489305b2cd33f70f6
4
- data.tar.gz: 76d4f355d36fb2ed6e5bb9cfbc4e4f4fa89b6bb3cc03666fe12ef7699b5784d8
3
+ metadata.gz: 21706d887ab7c6356cf12b521724170cd196d432d73bca548d678240f593a0c7
4
+ data.tar.gz: 79702a4ff37002499687c5eb6d2bd52d5b5ca719ad7654a0d40ed4213af7e6a5
5
5
  SHA512:
6
- metadata.gz: eb33edfcd401c81370d6079b9d85d67036e2c27e40cd1d441ae94bc34de34c50b6609e73ccfe6bc323d38bd224d98f4420996e83a85b387956517e20256ba9c9
7
- data.tar.gz: f3021bf9fc25965c14e902f68678e41faffb3bad502ff25dd23c06504147aee5ebaa3edc5de33a07a6baf2d09665320b00c4a1c5cdcb2217b922128033483ed4
6
+ metadata.gz: cd02d1df0306c1d7c575e8dc4c782f9047599b3eb0c3820b09fc240ccaa49a708c9310115b993e8f00041069442565770beb57b744ef8c2be8f11c7bae36523d
7
+ data.tar.gz: 25c7401a3029d7d5796a416b07081a921b33d34cadb31c9a091e6f4276d6939f49a90b61f0743d8fd76795960e777c55ae019cc1adc218a3462db0853b65838a
data/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Method to query projects
13
+
10
14
  ## [0.0.2] - 2024-01-04
11
15
 
12
16
  ### Added
@@ -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
@@ -75,6 +75,7 @@ module Virtuous
75
75
  include Gift
76
76
  include RecurringGift
77
77
  include GiftDesignation
78
+ include Project
78
79
 
79
80
  ##
80
81
  # Access token used for OAuth authentication.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Virtuous
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end