class DMAO::API::DatasetFile

Constants

ENDPOINT
INVALID_ENTITY_CLASS
INVALID_ENTITY_ERROR_MESSAGE
INVALID_ID_ERROR
NOT_FOUND_ERROR
VALID_ATTRIBUTES

Public Class Methods

handle_unprocessable_entity(error_response) click to toggle source
# 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) click to toggle source
# 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
new(attributes) click to toggle source
# 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