Class: Opendata::Client
- Inherits:
-
Object
- Object
- Opendata::Client
- Defined in:
- lib/client.rb
Instance Method Summary collapse
-
#dataset_list(params = {}) ⇒ Object
Makes requests for ‘logical collections’ of Dataset resources (zero-to-many potential dataset resources).
-
#dataset_list_url(params = {}) ⇒ String
Makes requests for ‘logical collections’ of Dataset resources (zero-to-many potential dataset resources).
-
#dataset_show(id, params = {}) ⇒ Object
Makes requests for a ‘logical object’ for a specific Dataset resource (zero-to-one potential dataset resources).
-
#dataset_show_url(id, params = {}) ⇒ String
Returns the url based on the id and url parameters specified.
-
#initialize(url = nil, options = {}) ⇒ Object
constructor
Constructor for Opendata::Client instances.
Constructor Details
#initialize(url = nil, options = {}) ⇒ Object
Constructor for Opendata::Client instances
13 14 15 16 |
# File 'lib/client.rb', line 13 def initialize(url = nil, = {}) opts = .merge(DEFAULT_HEADERS) @connection = Faraday.new(url, opts) end |
Instance Method Details
#dataset_list(params = {}) ⇒ Object
Makes requests for ‘logical collections’ of Dataset resources (zero-to-many potential dataset resources)
34 35 36 |
# File 'lib/client.rb', line 34 def dataset_list(params = {}) connection.get(dataset_list_url(params)) end |
#dataset_list_url(params = {}) ⇒ String
Makes requests for ‘logical collections’ of Dataset resources (zero-to-many potential dataset resources)
46 47 48 |
# File 'lib/client.rb', line 46 def dataset_list_url(params = {}) DATASETS_API_PATH + param_to_query_string(params) end |
#dataset_show(id, params = {}) ⇒ Object
Makes requests for a ‘logical object’ for a specific Dataset resource (zero-to-one potential dataset resources)
62 63 64 65 |
# File 'lib/client.rb', line 62 def dataset_show(id, params = {}) raise '#dataset_show must receive a dataset id' if id.nil? connection.get(dataset_show_url(id, params)) end |
#dataset_show_url(id, params = {}) ⇒ String
Returns the url based on the id and url parameters specified
75 76 77 |
# File 'lib/client.rb', line 75 def dataset_show_url(id, params = {}) DATASETS_API_PATH + "/#{id}" + param_to_query_string(params) end |