Sha256: 597ff9ed3bc901bb0058e7f72b27e92df6d03104d09a84c3240e38e930179bc8

Contents?: true

Size: 1.58 KB

Versions: 2

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true
require "rest-client"
require "json"
require "ostruct"
require "uri"
require "delegate"
require "cgi"

require_relative "dhis2/version"
require_relative "dhis2/configuration"
require_relative "dhis2/collection_wrapper"
require_relative "dhis2/pager"
require_relative "dhis2/paginated_array"
require_relative "dhis2/import_error"
require_relative "dhis2/status"
require_relative "dhis2/client"

require_relative "dhis2/api/base"
require_relative "dhis2/api/category_combo"
require_relative "dhis2/api/organisation_unit"
require_relative "dhis2/api/data_element"
require_relative "dhis2/api/data_element_group"
require_relative "dhis2/api/data_set"
require_relative "dhis2/api/data_value_set"
require_relative "dhis2/api/data_value"
require_relative "dhis2/api/organisation_unit_level"
require_relative "dhis2/api/indicator"
require_relative "dhis2/api/analytic"
require_relative "dhis2/api/organisation_unit_group"
require_relative "dhis2/api/system_info"
require_relative "dhis2/api/attribute"
require_relative "dhis2/api/user"

module Dhis2
  class << self
    def client
      if @client.nil?
        if config.user.nil? && config.password.nil?
          @client ||= Dhis2::Client.new(config.url)
        else
          @client ||= Dhis2::Client.new(url:      config.url,
                                        user:     config.user,
                                        password: config.password)
        end
      else
        @client
      end
    end

    def configure
      yield config
    end

    def config
      @configuration ||= Dhis2::Configuration.new
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dhis2-2.3.4 lib/dhis2.rb
dhis2-2.3.3 lib/dhis2.rb