Sha256: f49f8f52d78501ef691909bdac16fd479042b64913adc140e5ad530dbd14f4e7

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module Dhis2
  module Api
    class Event < Base
      def id
        event
      end
      class << self
        def format_query_parameters(options)

          params = []
          params.push([:page, options[:page]])                    if options[:page]
          params.push([:pageSize, options[:page_size]])           if options[:page_size]
          params.push([:fields, format_fields(options[:fields])]) if options[:fields]
          params.concat(format_filter(options[:filter]))          if options[:filter]
          params.push([:program, options[:program]])               if options[:program]
          params.push([:orgUnit, options[:org_unit]])             if options[:org_unit]
          params.push([:trackedEntityInstance, options[:tracked_entity_instance]]) if options[:tracked_entity_instance]

          RestClient::ParamsArray.new(params)
        end

        def create(client, tuples)
          begin
            body = { resource_name.to_sym => tuples }
            response = client.post(resource_name, body)
          rescue RestClient::Conflict => e
            response = Dhis2::Client.deep_change_case(JSON.parse(e.response.body), :underscore)
          end
          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/event.rb
dhis2-2.3.7 lib/dhis2/api/event.rb
dhis2-2.3.6 lib/dhis2/api/event.rb