lib/dhis2/api/data_set.rb in dhis2-2.3.3 vs lib/dhis2/api/data_set.rb in dhis2-2.3.4
- old
+ new
@@ -4,22 +4,24 @@
class DataSet < Base
class << self
def create(client, sets)
sets = [sets].flatten
- category_combo_id = client.category_combos.find_by(name: "default").id
+ category_combo = client.category_combos.find_by(name: "default")
data_set = {
data_sets: sets.map do |set|
- {
+ dataset = {
name: set[:name],
short_name: set[:short_name],
code: set[:code],
period_type: "Monthly",
- data_elements: set[:data_element_ids] ? set[:data_element_ids].map { |id| { id: id } } : [],
+ data_elements: set[:data_element_ids] ? set[:data_element_ids].map { |id| { id: id } } : [],
organisation_units: set[:organisation_unit_ids] ? set[:organisation_unit_ids].map { |id| { id: id } } : [],
- category_combo: { id: category_combo_id }
+ category_combo: { id: category_combo.id, name: category_combo.name }
}
+
+ dataset
end
}
response = client.post("metadata", data_set)
Dhis2::Status.new(response)
end