Class: Dhis2::Client
- Inherits:
-
Object
- Object
- Dhis2::Client
- Defined in:
- lib/dhis2/client.rb
Instance Attribute Summary collapse
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #analytics ⇒ Object
- #attributes ⇒ Object
- #can_connect? ⇒ Boolean
- #categories ⇒ Object
- #category_combos ⇒ Object
- #category_option_combos ⇒ Object
- #category_options ⇒ Object
- #complete_data_set_registrations ⇒ Object
- #data_element_groups ⇒ Object
- #data_elements ⇒ Object
- #data_sets ⇒ Object
- #data_value_sets ⇒ Object
- #data_values ⇒ Object
- #delete(path:, query_params: {}, raw: false) ⇒ Object
- #events ⇒ Object
- #get(path:, query_params: {}, raw: false) ⇒ Object
- #indicator_groups ⇒ Object
- #indicator_types ⇒ Object
- #indicators ⇒ Object
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
- #legend_sets ⇒ Object
- #organisation_unit_group_sets ⇒ Object
- #organisation_unit_groups ⇒ Object
- #organisation_unit_levels ⇒ Object
- #organisation_units ⇒ Object
- #patch(path:, payload:, query_params: {}, raw: false) ⇒ Object
- #post(path:, payload: nil, query_params: {}, raw: false, raw_input: false) ⇒ Object
- #program_indicator_groups ⇒ Object
- #program_indicators ⇒ Object
- #programs ⇒ Object
- #put(path:, payload:, query_params: {}, raw: false) ⇒ Object
- #report_tables ⇒ Object
- #reports ⇒ Object
- #resource_tables ⇒ Object
- #system_infos ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 |
# File 'lib/dhis2/client.rb', line 7 def initialize() @base_url = .fetch(:url) @version = .fetch(:version) @verify_ssl = .fetch(:verify_ssl, OpenSSL::SSL::VERIFY_PEER) @timeout = .fetch(:timeout, 120) @debug = .fetch(:debug, false) end |
Instance Attribute Details
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/dhis2/client.rb', line 5 def version @version end |
Class Method Details
.uri(base_url, path) ⇒ Object
160 161 162 |
# File 'lib/dhis2/client.rb', line 160 def self.uri(base_url, path) File.join(base_url, API, path) end |
Instance Method Details
#analytics ⇒ Object
35 36 37 |
# File 'lib/dhis2/client.rb', line 35 def analytics @analytics ||= CollectionWrapper.new("Analytic", self) end |
#attributes ⇒ Object
39 40 41 |
# File 'lib/dhis2/client.rb', line 39 def attributes @attributes ||= CollectionWrapper.new("Attribute", self) end |
#can_connect? ⇒ Boolean
151 152 153 154 155 156 157 158 |
# File 'lib/dhis2/client.rb', line 151 def can_connect? system_infos.get true rescue ::Dhis2::Error false rescue StandardError false end |
#categories ⇒ Object
43 44 45 |
# File 'lib/dhis2/client.rb', line 43 def categories @categories ||= CollectionWrapper.new("Category", self) end |
#category_combos ⇒ Object
51 52 53 |
# File 'lib/dhis2/client.rb', line 51 def category_combos @category_combos ||= CollectionWrapper.new("CategoryCombo", self) end |
#category_option_combos ⇒ Object
55 56 57 |
# File 'lib/dhis2/client.rb', line 55 def category_option_combos @category_option_combos ||= CollectionWrapper.new("CategoryOptionCombo", self) end |
#category_options ⇒ Object
47 48 49 |
# File 'lib/dhis2/client.rb', line 47 def ||= CollectionWrapper.new("CategoryOption", self) end |
#complete_data_set_registrations ⇒ Object
59 60 61 |
# File 'lib/dhis2/client.rb', line 59 def complete_data_set_registrations @complete_data_set_registrations ||= CollectionWrapper.new("CompleteDataSetRegistration", self) end |
#data_element_groups ⇒ Object
67 68 69 |
# File 'lib/dhis2/client.rb', line 67 def data_element_groups @data_element_groups ||= CollectionWrapper.new("DataElementGroup", self) end |
#data_elements ⇒ Object
63 64 65 |
# File 'lib/dhis2/client.rb', line 63 def data_elements @data_elements ||= CollectionWrapper.new("DataElement", self) end |
#data_sets ⇒ Object
71 72 73 |
# File 'lib/dhis2/client.rb', line 71 def data_sets @data_sets ||= CollectionWrapper.new("DataSet", self) end |
#data_value_sets ⇒ Object
79 80 81 |
# File 'lib/dhis2/client.rb', line 79 def data_value_sets @data_value_sets ||= CollectionWrapper.new("DataValueSet", self) end |
#data_values ⇒ Object
75 76 77 |
# File 'lib/dhis2/client.rb', line 75 def data_values @data_values ||= CollectionWrapper.new("DataValue", self) end |
#delete(path:, query_params: {}, raw: false) ⇒ Object
23 24 25 |
# File 'lib/dhis2/client.rb', line 23 def delete(path:, query_params: {}, raw: false) execute(method_name: :delete, url: uri(path), query_params: query_params, raw: raw) end |
#events ⇒ Object
83 84 85 |
# File 'lib/dhis2/client.rb', line 83 def events @events ||= CollectionWrapper.new("Event", self) end |
#get(path:, query_params: {}, raw: false) ⇒ Object
19 20 21 |
# File 'lib/dhis2/client.rb', line 19 def get(path:, query_params: {}, raw: false) execute(method_name: :get, url: uri(path), query_params: query_params, raw: raw) end |
#indicator_groups ⇒ Object
91 92 93 |
# File 'lib/dhis2/client.rb', line 91 def indicator_groups @indicator_groups ||= CollectionWrapper.new("IndicatorGroup", self) end |
#indicator_types ⇒ Object
95 96 97 |
# File 'lib/dhis2/client.rb', line 95 def indicator_types @indicator_types ||= CollectionWrapper.new("IndicatorType", self) end |
#indicators ⇒ Object
87 88 89 |
# File 'lib/dhis2/client.rb', line 87 def indicators @indicators ||= CollectionWrapper.new("Indicator", self) end |
#legend_sets ⇒ Object
99 100 101 |
# File 'lib/dhis2/client.rb', line 99 def legend_sets @legend_sets ||= CollectionWrapper.new("LegendSet", self) end |
#organisation_unit_group_sets ⇒ Object
111 112 113 |
# File 'lib/dhis2/client.rb', line 111 def organisation_unit_group_sets @organisation_unit_group_sets ||= CollectionWrapper.new("OrganisationUnitGroupSet", self) end |
#organisation_unit_groups ⇒ Object
107 108 109 |
# File 'lib/dhis2/client.rb', line 107 def organisation_unit_groups @organisation_unit_groups ||= CollectionWrapper.new("OrganisationUnitGroup", self) end |
#organisation_unit_levels ⇒ Object
115 116 117 |
# File 'lib/dhis2/client.rb', line 115 def organisation_unit_levels @organisation_unit_levels ||= CollectionWrapper.new("OrganisationUnitLevel", self) end |
#organisation_units ⇒ Object
103 104 105 |
# File 'lib/dhis2/client.rb', line 103 def organisation_units @organisation_units ||= CollectionWrapper.new("OrganisationUnit", self) end |
#patch(path:, payload:, query_params: {}, raw: false) ⇒ Object
31 32 33 |
# File 'lib/dhis2/client.rb', line 31 def patch(path:, payload:, query_params: {}, raw: false) execute(method_name: :patch, url: uri(path), query_params: query_params, payload: payload, raw: raw) end |
#post(path:, payload: nil, query_params: {}, raw: false, raw_input: false) ⇒ Object
15 16 17 |
# File 'lib/dhis2/client.rb', line 15 def post(path:, payload: nil, query_params: {}, raw: false, raw_input: false) execute(method_name: :post, url: uri(path), query_params: query_params, payload: payload, raw: raw, raw_input: raw_input) end |
#program_indicator_groups ⇒ Object
127 128 129 |
# File 'lib/dhis2/client.rb', line 127 def program_indicator_groups @program_indicator_groups ||= CollectionWrapper.new("ProgramIndicatorGroup", self) end |
#program_indicators ⇒ Object
123 124 125 |
# File 'lib/dhis2/client.rb', line 123 def program_indicators @program_indicators ||= CollectionWrapper.new("ProgramIndicator", self) end |
#programs ⇒ Object
119 120 121 |
# File 'lib/dhis2/client.rb', line 119 def programs @programs ||= CollectionWrapper.new("Program", self) end |
#put(path:, payload:, query_params: {}, raw: false) ⇒ Object
27 28 29 |
# File 'lib/dhis2/client.rb', line 27 def put(path:, payload:, query_params: {}, raw: false) execute(method_name: :put, url: uri(path), query_params: query_params, payload: payload, raw: raw) end |
#report_tables ⇒ Object
135 136 137 |
# File 'lib/dhis2/client.rb', line 135 def report_tables @report_tables ||= CollectionWrapper.new("ReportTable", self) end |
#reports ⇒ Object
131 132 133 |
# File 'lib/dhis2/client.rb', line 131 def reports @reports ||= CollectionWrapper.new("Report", self) end |
#resource_tables ⇒ Object
139 140 141 |
# File 'lib/dhis2/client.rb', line 139 def resource_tables @resource_tables ||= CollectionWrapper.new("ResourceTable", self) end |
#system_infos ⇒ Object
143 144 145 |
# File 'lib/dhis2/client.rb', line 143 def system_infos @system_infos ||= CollectionWrapper.new("SystemInfo", self) end |
#users ⇒ Object
147 148 149 |
# File 'lib/dhis2/client.rb', line 147 def users @users ||= CollectionWrapper.new("User", self) end |