Sha256: 3903e1afc7a5179f7e6ff9f6dafb648e0254de4c7dde140ff11ace2e0e8bbe2d
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true module Dhis2 module Api class DataElement < Base class << self def create(client, elements, query_params = { preheat_cache: false }) elements = [elements].flatten category_combo = client.category_combos.find_by(name: "default") data_element = { data_elements: elements.map do |element| { name: element[:name], short_name: element[:short_name], code: element[:code] || element[:short_name], domain_type: element[:domain_type] || "AGGREGATE", value_type: element[:value_type] || "NUMBER", aggregation_type: element[:aggregation_type] || "SUM", type: element[:type] || "int", # for backward compatbility aggregation_operator: element[:aggregation_type] || "SUM", # for backward compatbility zero_is_significant: element[:zero_is_significant] || true, category_combo: { id: category_combo.id, name: category_combo.name } } end } response = client.post("metadata", data_element, client.class.deep_change_case(query_params, :camelize)) Dhis2::Status.new(response) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dhis2-2.3.8 | lib/dhis2/api/data_element.rb |
dhis2-2.3.7 | lib/dhis2/api/data_element.rb |
dhis2-2.3.6 | lib/dhis2/api/data_element.rb |