Module: Dhis2::Api::Shared::CompleteDataSetRegistration::ClassMethods
- Defined in:
- lib/dhis2/api/shared/complete_data_set_registration.rb
Instance Method Summary collapse
- #create(client, period:, organisation_unit:, data_set:, multi_ou: false) ⇒ Object
- #delete(client, period:, organisation_unit:, data_set:) ⇒ Object
- #list(client, periods:, organisation_units:, data_sets:) ⇒ Object
Instance Method Details
#create(client, period:, organisation_unit:, data_set:, multi_ou: false) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dhis2/api/shared/complete_data_set_registration.rb', line 12 def create(client, period:, organisation_unit:, data_set:, multi_ou: false) client.post( path: resource_name, payload: {"completeDataSetRegistrations": [{ organisationUnit: organisation_unit, period: period, dataSet: data_set, multiOu: multi_ou }]}, raw_input: true ) end |
#delete(client, period:, organisation_unit:, data_set:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dhis2/api/shared/complete_data_set_registration.rb', line 25 def delete(client, period:, organisation_unit:, data_set:) client.delete( path: resource_name, query_params: { ou: organisation_unit, pe: period, ds: data_set } ) end |
#list(client, periods:, organisation_units:, data_sets:) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dhis2/api/shared/complete_data_set_registration.rb', line 36 def list(client, periods:, organisation_units:, data_sets:) query_params = periods.map { |p| "period=#{p}" } query_params += organisation_units.map { |ou| "orgUnit=#{ou}" } query_params += data_sets.map { |ds| "dataSet=#{ds}" } json_response = client.get( path: "#{resource_name}?#{query_params.join('&')}" ) return [] unless json_response["complete_data_set_registrations"] json_response["complete_data_set_registrations"].map { |raw_resource| new(client, raw_resource) } end |