Module: Dhis2::Api::BulkCreatable::ClassMethods
- Defined in:
- lib/dhis2/api/bulk_creatable.rb
Constant Summary collapse
- BulkCreationStatusClass =
::Dhis2::Api::ImportSummary
Instance Method Summary collapse
-
#bulk_create(client, args, raw_input = false) ⇒ Object
args is a hash like: { data_element_groups: [{ name: “foo” }, { name: “bar” }] }.
Instance Method Details
#bulk_create(client, args, raw_input = false) ⇒ Object
args is a hash like: { data_element_groups: [{ name: “foo” }, { name: “bar” }] }
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dhis2/api/bulk_creatable.rb', line 15 def bulk_create(client, args, raw_input = false) response = client.post(path: "metadata", payload: args, raw_input: raw_input) self::BulkCreationStatusClass.new(response).tap do |summary| unless summary.bulk_success? exception = Dhis2::BulkCreationError.new("Didnt create bulk of data properly.\n Response: #{response.to_json}") exception.import_summary = summary raise exception end end end |