Class: RetrieveRecords
- Inherits:
-
DataverseOperations
- Object
- DataverseOperations
- RetrieveRecords
- Defined in:
- lib/dvla/dataverse/operations/retrieve_records.rb
Instance Method Summary collapse
-
#get_records(record_name: nil, max_return: nil) ⇒ Array
Get all the records as an array.
- #setup_artifacts ⇒ Object
Methods inherited from DataverseOperations
#apply_filter, #get_url_from_config_file, #http_request_artifacts, #initialize, #send_request, #setup_http_headers
Constructor Details
This class inherits a constructor from DataverseOperations
Instance Method Details
#get_records(record_name: nil, max_return: nil) ⇒ Array
Get all the records as an array. If no records is found, this function will throw http 404 error. You can retrieve sub-records using the filter. You can only set the maximum records to be return if specify the record name
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dvla/dataverse/operations/retrieve_records.rb', line 25 def get_records(record_name: nil, max_return: nil) unless record_name.nil? apply_filter({ record_name: record_name, top: max_return }) end send_request &.body .then { |response| JSON.parse(response) if response } .then { |values| values['value'] || values } end |
#setup_artifacts ⇒ Object
5 6 7 8 9 |
# File 'lib/dvla/dataverse/operations/retrieve_records.rb', line 5 def setup_artifacts setup_http_headers http_request_artifacts.url = get_url_from_config_file http_request_artifacts.method = :get end |