Class: DMAO::API::DatasetFile
- Defined in:
- lib/dmao/api/dataset_file.rb
Constant Summary collapse
- ENDPOINT =
'dataset_files'- NOT_FOUND_ERROR =
DMAO::API::Errors::DatasetFileNotFound
- INVALID_ID_ERROR =
DMAO::API::Errors::InvalidDatasetFileID
- INVALID_ENTITY_CLASS =
DMAO::API::Errors::InvalidDatasetFile
- INVALID_ENTITY_ERROR_MESSAGE =
"Invalid dataset file details, please see errors."- VALID_ATTRIBUTES =
[:id, :institution_id, :name, :size, :url, :system_uuid, :system_modified_at, :dataset_id]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ DatasetFile
constructor
A new instance of DatasetFile.
Methods inherited from Entity
all, create, delete, find_by_system_uuid, get, instance_from_response, parse_error_response, raise_error_if_key, set_id_attribute_if_not_nil, update, validate_attributes, validate_id, validate_system_uuid
Methods inherited from Base
Constructor Details
#initialize(attributes) ⇒ DatasetFile
Returns a new instance of DatasetFile.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dmao/api/dataset_file.rb', line 22 def initialize(attributes) @id = attributes[:id] @institution_id = attributes[:institution_id] @name = attributes[:name] @size = attributes[:size] @url = attributes[:url] @system_uuid = attributes[:system_uuid] @system_modified_at = attributes[:system_modified_at] @dataset_id= attributes[:dataset_id] end |
Class Method Details
.handle_unprocessable_entity(error_response) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/dmao/api/dataset_file.rb', line 52 def self.handle_unprocessable_entity error_response errors = parse_error_response error_response raise_error_if_key DMAO::API::Errors::InvalidDatasetID, errors, "dataset" raise DMAO::API::Errors::InvalidDatasetFile.new("Invalid dataset file details, please see errors.", errors) end |
.instance_from_api_data(data) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/dmao/api/dataset_file.rb', line 35 def self.instance_from_api_data data attributes = { id: data["id"], institution_id: data["relationships"]["institution"]["data"]["id"], name: data["attributes"]["name"], size: data["attributes"]["size"], url: data["attributes"]["url"], system_uuid: data["attributes"]["system-uuid"], system_modified_at: data["attributes"]["system-modified-at"], dataset_id: data["relationships"]["dataset"]["data"]["id"] } new(attributes) end |