dhis2 3.0.3 → 3.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca81d93073a9f85779f78fa6102bada9a6bf91cd
4
- data.tar.gz: 11ec2fba5f33d5e26d29b312f506034b99edd3f0
3
+ metadata.gz: 1aa84c5184a6aaccdbde59f8734d44c4cf615c87
4
+ data.tar.gz: ba4851e6ac597be06e479ab19faf84c87be86480
5
5
  SHA512:
6
- metadata.gz: 4e383500dd5ee00ed5bc110a5e08631e629c8856f6dbab454afe07261cc772e7e25808bf15887d1ecbb78571a7afae3e72d9b3d0ac9cd4642bea99b973f26637
7
- data.tar.gz: b7759bf306930b53143c970e38826511398cdafd8b27ebdb6467ac90b63212f8bce6a6839fdb9cf85eda0a3d8474f9679fd7f49fa2037d5b89b665d3e959c044
6
+ metadata.gz: e50be53b6a30f28461d949bbafb001ddaafb87bfe37c83c5605ef7978b7af77dbe14f79e36082ea0709a97dda1aced9bc07b9819744ddd6c8f99fe726f063279
7
+ data.tar.gz: e0468e8ccd80eb67c604d0d9467df4d7e8e6670abdd7e72787da5204b29a0b47fad7c6e8d70d1fad2b1a6a4e8aa8a52299403efbc780396a607a3717289d129d
@@ -31,6 +31,8 @@ require_relative "dhis2/api/updatable"
31
31
  require_relative "dhis2/api/query_parameters_formatter"
32
32
 
33
33
  require_relative "dhis2/api/shared/analytic"
34
+ require_relative "dhis2/api/shared/category"
35
+ require_relative "dhis2/api/shared/category_option"
34
36
  require_relative "dhis2/api/shared/category_combo"
35
37
  require_relative "dhis2/api/shared/category_option_combo"
36
38
  require_relative "dhis2/api/shared/constants"
@@ -54,8 +56,8 @@ require_relative "dhis2/api/version228/index"
54
56
 
55
57
  module Dhis2
56
58
  class << self
57
- def play(debug = false)
58
- Dhis2::Client.new(config.play_params(debug))
59
+ def play(debug = false, version: "2.28")
60
+ Dhis2::Client.new(config.play_params(debug, version))
59
61
  end
60
62
 
61
63
  def client
@@ -9,12 +9,14 @@ module Dhis2
9
9
 
10
10
  module ClassMethods
11
11
 
12
- BulkCreationStatusClass = ::Dhis2::Api::ImportSummary
12
+ def bulk_creation_status_class
13
+ ::Dhis2::Api::ImportSummary
14
+ end
13
15
 
14
16
  # args is a hash like: { data_element_groups: [{ name: "foo" }, { name: "bar" }] }
15
17
  def bulk_create(client, args, raw_input = false)
16
18
  response = client.post(path: "metadata", payload: args, raw_input: raw_input)
17
- self::BulkCreationStatusClass.new(response).tap do |summary|
19
+ bulk_creation_status_class.new(response).tap do |summary|
18
20
  unless summary.bulk_success?
19
21
  exception = Dhis2::BulkCreationError.new("Didnt create bulk of data properly.\n Response: #{response.to_json}")
20
22
  exception.import_summary = summary
@@ -53,7 +53,7 @@ module Dhis2
53
53
 
54
54
  def base_success?
55
55
  %w(ImportSummary ImportTypeSummary).include?(hash["response_type"]) &&
56
- hash["status"] == "SUCCESS" &&
56
+ %w(OK SUCCESS).include?(hash["status"]) &&
57
57
  import_count
58
58
  end
59
59
  end
@@ -0,0 +1,32 @@
1
+
2
+ # frozen_string_literal: true
3
+
4
+ module Dhis2
5
+ module Api
6
+ module Shared
7
+ module Category
8
+ def self.included(base)
9
+ base.extend(ClassMethods)
10
+ end
11
+
12
+ Schema = Dry::Validation.Schema do
13
+ required(:name).filled
14
+ required(:data_dimension_type).value(
15
+ included_in?: ::Dhis2::Api::Constants::DATA_DIMENSION_TYPES
16
+ )
17
+ end
18
+
19
+ module ClassMethods
20
+ def resource_name
21
+ "categories"
22
+ end
23
+ def creation_defaults(args)
24
+ {
25
+ data_dimension_type: "DISAGGREGATION"
26
+ }
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,20 @@
1
+
2
+ # frozen_string_literal: true
3
+
4
+ module Dhis2
5
+ module Api
6
+ module Shared
7
+ module CategoryOption
8
+ Schema = Dry::Validation.Schema do
9
+ required(:name).filled
10
+ end
11
+ def self.included(base)
12
+ base.extend(ClassMethods)
13
+ end
14
+
15
+ module ClassMethods
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dhis2
4
+ module Api
5
+ module Version224
6
+ class Category < ::Dhis2::Api::Base
7
+ include ::Dhis2::Api::Listable
8
+ include ::Dhis2::Api::Findable
9
+ include ::Dhis2::Api::Creatable
10
+ include ::Dhis2::Api::BulkCreatable
11
+ include ::Dhis2::Api::Updatable
12
+ include ::Dhis2::Api::Deletable
13
+ include ::Dhis2::Api::Version224::SaveValidator
14
+ include ::Dhis2::Api::Shared::Category
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dhis2
4
+ module Api
5
+ module Version224
6
+ class CategoryOption < ::Dhis2::Api::Base
7
+ include ::Dhis2::Api::Listable
8
+ include ::Dhis2::Api::Findable
9
+ include ::Dhis2::Api::Creatable
10
+ include ::Dhis2::Api::BulkCreatable
11
+ include ::Dhis2::Api::Updatable
12
+ include ::Dhis2::Api::Deletable
13
+ include ::Dhis2::Api::Shared::SaveValidator
14
+ include ::Dhis2::Api::Shared::CategoryOption
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -4,6 +4,8 @@ require_relative "save_validator"
4
4
  require_relative "constants"
5
5
  require_relative "analytic"
6
6
  require_relative "attribute"
7
+ require_relative "category"
8
+ require_relative "category_option"
7
9
  require_relative "category_combo"
8
10
  require_relative "category_option_combo"
9
11
  require_relative "data_element"
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dhis2
4
+ module Api
5
+ module Version225
6
+ class Category < ::Dhis2::Api::Base
7
+ include ::Dhis2::Api::Listable
8
+ include ::Dhis2::Api::Findable
9
+ include ::Dhis2::Api::Creatable
10
+ include ::Dhis2::Api::BulkCreatable
11
+ include ::Dhis2::Api::Updatable
12
+ include ::Dhis2::Api::Deletable
13
+ include ::Dhis2::Api::Shared::SaveValidator
14
+ include ::Dhis2::Api::Shared::Category
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dhis2
4
+ module Api
5
+ module Version225
6
+ class CategoryOption < ::Dhis2::Api::Base
7
+ include ::Dhis2::Api::Listable
8
+ include ::Dhis2::Api::Findable
9
+ include ::Dhis2::Api::Creatable
10
+ include ::Dhis2::Api::BulkCreatable
11
+ include ::Dhis2::Api::Updatable
12
+ include ::Dhis2::Api::Deletable
13
+ include ::Dhis2::Api::Shared::SaveValidator
14
+ include ::Dhis2::Api::Shared::CategoryOption
15
+ end
16
+ end
17
+ end
18
+ end
@@ -12,7 +12,9 @@ module Dhis2
12
12
  include ::Dhis2::Api::Shared::SaveValidator
13
13
  include ::Dhis2::Api::Shared::Event
14
14
 
15
- BulkCreationStatusClass = ::Dhis2::Api::EventCreationStatus
15
+ def bulk_creation_status_class
16
+ ::Dhis2::Api::EventCreationStatus
17
+ end
16
18
 
17
19
  # args for a program without registration
18
20
  # and a program with a program_stage
@@ -3,6 +3,8 @@
3
3
  require_relative "constants"
4
4
  require_relative "analytic"
5
5
  require_relative "attribute"
6
+ require_relative "category"
7
+ require_relative "category_option"
6
8
  require_relative "category_combo"
7
9
  require_relative "category_option_combo"
8
10
  require_relative "data_element"
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dhis2
4
+ module Api
5
+ module Version226
6
+ class Category < ::Dhis2::Api::Base
7
+ include ::Dhis2::Api::Listable
8
+ include ::Dhis2::Api::Findable
9
+ include ::Dhis2::Api::Creatable
10
+ include ::Dhis2::Api::BulkCreatable
11
+ include ::Dhis2::Api::Updatable
12
+ include ::Dhis2::Api::Deletable
13
+ include ::Dhis2::Api::Shared::SaveValidator
14
+ include ::Dhis2::Api::Shared::Category
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dhis2
4
+ module Api
5
+ module Version226
6
+ class CategoryOption < ::Dhis2::Api::Base
7
+ include ::Dhis2::Api::Listable
8
+ include ::Dhis2::Api::Findable
9
+ include ::Dhis2::Api::Creatable
10
+ include ::Dhis2::Api::BulkCreatable
11
+ include ::Dhis2::Api::Updatable
12
+ include ::Dhis2::Api::Deletable
13
+ include ::Dhis2::Api::Shared::SaveValidator
14
+ include ::Dhis2::Api::Shared::CategoryOption
15
+ end
16
+ end
17
+ end
18
+ end
@@ -12,7 +12,9 @@ module Dhis2
12
12
  include ::Dhis2::Api::Shared::SaveValidator
13
13
  include ::Dhis2::Api::Shared::Event
14
14
 
15
- BulkCreationStatusClass = ::Dhis2::Api::EventCreationStatus
15
+ def bulk_creation_status_class
16
+ ::Dhis2::Api::EventCreationStatus
17
+ end
16
18
 
17
19
  # args for a program without registration
18
20
  # and a program with a program_stage
@@ -3,6 +3,8 @@
3
3
  require_relative "constants"
4
4
  require_relative "analytic"
5
5
  require_relative "attribute"
6
+ require_relative "category"
7
+ require_relative "category_option"
6
8
  require_relative "category_combo"
7
9
  require_relative "category_option_combo"
8
10
  require_relative "data_element"
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dhis2
4
+ module Api
5
+ module Version227
6
+ class Category < ::Dhis2::Api::Base
7
+ include ::Dhis2::Api::Listable
8
+ include ::Dhis2::Api::Findable
9
+ include ::Dhis2::Api::Creatable
10
+ include ::Dhis2::Api::BulkCreatable
11
+ include ::Dhis2::Api::Updatable
12
+ include ::Dhis2::Api::Deletable
13
+ include ::Dhis2::Api::Shared::SaveValidator
14
+ include ::Dhis2::Api::Shared::Category
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dhis2
4
+ module Api
5
+ module Version227
6
+ class CategoryOption < ::Dhis2::Api::Base
7
+ include ::Dhis2::Api::Listable
8
+ include ::Dhis2::Api::Findable
9
+ include ::Dhis2::Api::Creatable
10
+ include ::Dhis2::Api::BulkCreatable
11
+ include ::Dhis2::Api::Updatable
12
+ include ::Dhis2::Api::Deletable
13
+ include ::Dhis2::Api::Shared::SaveValidator
14
+ include ::Dhis2::Api::Shared::CategoryOption
15
+ end
16
+ end
17
+ end
18
+ end
@@ -12,7 +12,9 @@ module Dhis2
12
12
  include ::Dhis2::Api::Shared::SaveValidator
13
13
  include ::Dhis2::Api::Shared::Event
14
14
 
15
- BulkCreationStatusClass = ::Dhis2::Api::EventCreationStatus
15
+ def bulk_creation_status_class
16
+ ::Dhis2::Api::EventCreationStatus
17
+ end
16
18
 
17
19
  # args for a program without registration
18
20
  # and a program with a program_stage
@@ -3,6 +3,8 @@
3
3
  require_relative "constants"
4
4
  require_relative "analytic"
5
5
  require_relative "attribute"
6
+ require_relative "category"
7
+ require_relative "category_option"
6
8
  require_relative "category_combo"
7
9
  require_relative "category_option_combo"
8
10
  require_relative "data_element"
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dhis2
4
+ module Api
5
+ module Version228
6
+ class Category < ::Dhis2::Api::Base
7
+ include ::Dhis2::Api::Listable
8
+ include ::Dhis2::Api::Findable
9
+ include ::Dhis2::Api::Creatable
10
+ include ::Dhis2::Api::BulkCreatable
11
+ include ::Dhis2::Api::Updatable
12
+ include ::Dhis2::Api::Deletable
13
+ include ::Dhis2::Api::Shared::SaveValidator
14
+ include ::Dhis2::Api::Shared::Category
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dhis2
4
+ module Api
5
+ module Version228
6
+ class CategoryOption < ::Dhis2::Api::Base
7
+ include ::Dhis2::Api::Listable
8
+ include ::Dhis2::Api::Findable
9
+ include ::Dhis2::Api::Creatable
10
+ include ::Dhis2::Api::BulkCreatable
11
+ include ::Dhis2::Api::Updatable
12
+ include ::Dhis2::Api::Deletable
13
+ include ::Dhis2::Api::Shared::SaveValidator
14
+ include ::Dhis2::Api::Shared::CategoryOption
15
+ end
16
+ end
17
+ end
18
+ end
@@ -12,7 +12,9 @@ module Dhis2
12
12
  include ::Dhis2::Api::Shared::SaveValidator
13
13
  include ::Dhis2::Api::Shared::Event
14
14
 
15
- BulkCreationStatusClass = ::Dhis2::Api::EventCreationStatus
15
+ def bulk_creation_status_class
16
+ ::Dhis2::Api::EventCreationStatus
17
+ end
16
18
 
17
19
  # args for a program without registration
18
20
  # and a program with a program_stage
@@ -3,6 +3,8 @@
3
3
  require_relative "constants"
4
4
  require_relative "analytic"
5
5
  require_relative "attribute"
6
+ require_relative "category"
7
+ require_relative "category_option"
6
8
  require_relative "category_combo"
7
9
  require_relative "category_option_combo"
8
10
  require_relative "data_element"
@@ -21,6 +21,8 @@ module Dhis2
21
21
 
22
22
  class Analytic < Versioned; end
23
23
  class Attribute < Versioned; end
24
+ class Category < Versioned; end
25
+ class CategoryOption < Versioned; end
24
26
  class CategoryCombo < Versioned; end
25
27
  class CategoryOptionCombo < Versioned; end
26
28
  class DataElement < Versioned; end
@@ -40,6 +40,14 @@ module Dhis2
40
40
  @attributes ||= CollectionWrapper.new("Attribute", self)
41
41
  end
42
42
 
43
+ def categories
44
+ @categories ||= CollectionWrapper.new("Category", self)
45
+ end
46
+
47
+ def category_options
48
+ @category_options ||= CollectionWrapper.new("CategoryOption", self)
49
+ end
50
+
43
51
  def category_combos
44
52
  @category_combos ||= CollectionWrapper.new("CategoryCombo", self)
45
53
  end
@@ -144,11 +152,13 @@ module Dhis2
144
152
  TAB = "\t"
145
153
 
146
154
  def execute(method_name:, url:, query_params: {}, payload: nil, raw: false, raw_input: false)
155
+ computed_payload = compute_payload(payload, raw_input)
156
+
147
157
  raw_response = RestClient::Request.execute(
148
158
  method: method_name,
149
159
  url: url,
150
160
  headers: headers(method_name, query_params),
151
- payload: compute_payload(payload, raw_input),
161
+ payload: computed_payload,
152
162
  verify_ssl: @verify_ssl,
153
163
  timeout: @timeout
154
164
  )
@@ -164,6 +174,7 @@ module Dhis2
164
174
  exception.response = e.response if e.respond_to?(:response)
165
175
  exception.http_code = e.http_code if e.respond_to?(:http_code)
166
176
  exception.http_body = e.http_body if e.respond_to?(:http_body)
177
+ log(exception.response.request, exception.response)
167
178
  raise exception
168
179
  end
169
180
 
@@ -184,7 +195,7 @@ module Dhis2
184
195
  end
185
196
 
186
197
  def log(request, response)
187
- puts [request.url, request.args[:payload], response].join(TAB) if @debug
198
+ puts [request.url, request.args[:payload].to_json, response.to_json].join(TAB) if @debug
188
199
  end
189
200
  end
190
201
  end
@@ -16,11 +16,11 @@ module Dhis2
16
16
  }
17
17
  end
18
18
 
19
- def play_params(with_debug)
19
+ def play_params(with_debug, version)
20
20
  {
21
- url: "https://admin:district@play.dhis2.org/2.28/",
21
+ url: "https://admin:district@play.dhis2.org/#{version}/",
22
22
  debug: with_debug,
23
- version: "2.28"
23
+ version: version
24
24
  }
25
25
  end
26
26
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dhis2
4
- VERSION = "3.0.3"
4
+ VERSION = "3.0.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dhis2
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Van Aken
@@ -191,7 +191,9 @@ files:
191
191
  - lib/dhis2/api/listable.rb
192
192
  - lib/dhis2/api/query_parameters_formatter.rb
193
193
  - lib/dhis2/api/shared/analytic.rb
194
+ - lib/dhis2/api/shared/category.rb
194
195
  - lib/dhis2/api/shared/category_combo.rb
196
+ - lib/dhis2/api/shared/category_option.rb
195
197
  - lib/dhis2/api/shared/category_option_combo.rb
196
198
  - lib/dhis2/api/shared/constants.rb
197
199
  - lib/dhis2/api/shared/data_element_group.rb
@@ -208,7 +210,9 @@ files:
208
210
  - lib/dhis2/api/updatable.rb
209
211
  - lib/dhis2/api/version224/analytic.rb
210
212
  - lib/dhis2/api/version224/attribute.rb
213
+ - lib/dhis2/api/version224/category.rb
211
214
  - lib/dhis2/api/version224/category_combo.rb
215
+ - lib/dhis2/api/version224/category_option.rb
212
216
  - lib/dhis2/api/version224/category_option_combo.rb
213
217
  - lib/dhis2/api/version224/constants.rb
214
218
  - lib/dhis2/api/version224/data_element.rb
@@ -234,7 +238,9 @@ files:
234
238
  - lib/dhis2/api/version224/user.rb
235
239
  - lib/dhis2/api/version225/analytic.rb
236
240
  - lib/dhis2/api/version225/attribute.rb
241
+ - lib/dhis2/api/version225/category.rb
237
242
  - lib/dhis2/api/version225/category_combo.rb
243
+ - lib/dhis2/api/version225/category_option.rb
238
244
  - lib/dhis2/api/version225/category_option_combo.rb
239
245
  - lib/dhis2/api/version225/constants.rb
240
246
  - lib/dhis2/api/version225/data_element.rb
@@ -259,7 +265,9 @@ files:
259
265
  - lib/dhis2/api/version225/user.rb
260
266
  - lib/dhis2/api/version226/analytic.rb
261
267
  - lib/dhis2/api/version226/attribute.rb
268
+ - lib/dhis2/api/version226/category.rb
262
269
  - lib/dhis2/api/version226/category_combo.rb
270
+ - lib/dhis2/api/version226/category_option.rb
263
271
  - lib/dhis2/api/version226/category_option_combo.rb
264
272
  - lib/dhis2/api/version226/constants.rb
265
273
  - lib/dhis2/api/version226/data_element.rb
@@ -284,7 +292,9 @@ files:
284
292
  - lib/dhis2/api/version226/user.rb
285
293
  - lib/dhis2/api/version227/analytic.rb
286
294
  - lib/dhis2/api/version227/attribute.rb
295
+ - lib/dhis2/api/version227/category.rb
287
296
  - lib/dhis2/api/version227/category_combo.rb
297
+ - lib/dhis2/api/version227/category_option.rb
288
298
  - lib/dhis2/api/version227/category_option_combo.rb
289
299
  - lib/dhis2/api/version227/constants.rb
290
300
  - lib/dhis2/api/version227/data_element.rb
@@ -309,7 +319,9 @@ files:
309
319
  - lib/dhis2/api/version227/user.rb
310
320
  - lib/dhis2/api/version228/analytic.rb
311
321
  - lib/dhis2/api/version228/attribute.rb
322
+ - lib/dhis2/api/version228/category.rb
312
323
  - lib/dhis2/api/version228/category_combo.rb
324
+ - lib/dhis2/api/version228/category_option.rb
313
325
  - lib/dhis2/api/version228/category_option_combo.rb
314
326
  - lib/dhis2/api/version228/constants.rb
315
327
  - lib/dhis2/api/version228/data_element.rb